-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from enviodev/feature/add-superchain-factorie…
…s-testing Feature: Adds Superchain Factories Tests.
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
test/EventHandlers/SuperchainCLFactory/RootPoolCreated.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { expect } from "chai"; | ||
import { MockDb, SuperchainCLFactory } from "../../../generated/src/TestHelpers.gen"; | ||
|
||
describe("SuperchainCLFactory RootPoolCreated Event", () => { | ||
const token0Address = "0x1111111111111111111111111111111111111111"; | ||
const token1Address = "0x2222222222222222222222222222222222222222"; | ||
const poolAddress = "0x3333333333333333333333333333333333333333"; | ||
const chainId = 10; | ||
const mockPoolChainId = 5; | ||
|
||
let mockDb: ReturnType<typeof MockDb.createMockDb>; | ||
|
||
beforeEach(() => { | ||
mockDb = MockDb.createMockDb(); | ||
}); | ||
|
||
it("should create a new RootPoolCreated entity", async () => { | ||
const mockEvent = SuperchainCLFactory.RootPoolCreated.createMockEvent({ | ||
token0: token0Address, | ||
token1: token1Address, | ||
pool: poolAddress, | ||
chainid: BigInt(mockPoolChainId), | ||
tickSpacing: 10n, | ||
mockEventData: { | ||
block: { | ||
timestamp: 1000000, | ||
number: 123456, | ||
hash: "0x1234567890123456789012345678901234567890123456789012345678901234" | ||
}, | ||
chainId, | ||
logIndex: 1, | ||
} | ||
}); | ||
|
||
const result = await SuperchainCLFactory.RootPoolCreated.processEvent({ | ||
event: mockEvent, | ||
mockDb | ||
}); | ||
|
||
const createdEvent = result.entities.SuperchainCLFactory_RootPoolCreated.get(`${mockPoolChainId}_123456_1`); | ||
expect(createdEvent).to.not.be.undefined; | ||
expect(createdEvent?.token0).to.equal(token0Address); | ||
expect(createdEvent?.token1).to.equal(token1Address); | ||
expect(createdEvent?.pool).to.equal(poolAddress); | ||
expect(createdEvent?.poolChainId).to.equal(mockPoolChainId); | ||
expect(createdEvent?.tickSpacing).to.equal(10n); | ||
expect(createdEvent?.timestamp).to.deep.equal(new Date(1000000 * 1000)); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
test/EventHandlers/SuperchainPoolFactory/RootPoolCreated.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { expect } from "chai"; | ||
import { MockDb, SuperchainPoolFactory } from "../../../generated/src/TestHelpers.gen"; | ||
|
||
describe("SuperchainPoolFactory RootPoolCreated Event", () => { | ||
const token0Address = "0x1111111111111111111111111111111111111111"; | ||
const token1Address = "0x2222222222222222222222222222222222222222"; | ||
const poolAddress = "0xb01234713d278d0ae3039d5930102956861d144b"; // Using real pool address. | ||
const chainId = 10; | ||
const mockPoolChainId = 252; | ||
|
||
let mockDb: ReturnType<typeof MockDb.createMockDb>; | ||
|
||
beforeEach(() => { | ||
mockDb = MockDb.createMockDb(); | ||
}); | ||
|
||
xit("should create a new RootPoolCreated entity with chain ID from Web3 call", async () => { | ||
const mockEvent = SuperchainPoolFactory.RootPoolCreated.createMockEvent({ | ||
token0: token0Address, | ||
token1: token1Address, | ||
pool: poolAddress, | ||
stable: false, | ||
length: 2n, | ||
mockEventData: { | ||
block: { | ||
timestamp: 1000000, | ||
number: 123456, | ||
hash: "0x1234567890123456789012345678901234567890123456789012345678901234" | ||
}, | ||
chainId, | ||
logIndex: 1, | ||
} | ||
}); | ||
|
||
const result = await SuperchainPoolFactory.RootPoolCreated.processEvent({ | ||
event: mockEvent, | ||
mockDb | ||
}); | ||
|
||
const createdEvent = result.entities.SuperchainPoolFactory_RootPoolCreated.get(`${chainId}_123456_1`); | ||
expect(createdEvent).to.not.be.undefined; | ||
expect(createdEvent?.token0).to.equal(token0Address); | ||
expect(createdEvent?.token1).to.equal(token1Address); | ||
expect(createdEvent?.pool).to.equal(poolAddress); | ||
expect(createdEvent?.stable).to.be.false; | ||
expect(createdEvent?.poolChainId).to.equal(mockPoolChainId); | ||
expect(createdEvent?.length).to.equal(2n); | ||
expect(createdEvent?.timestamp).to.deep.equal(new Date(1000000 * 1000)); | ||
}); | ||
}); |