diff --git a/src/EventHandlers/Voter.ts b/src/EventHandlers/Voter.ts index 53e31cb..c847698 100644 --- a/src/EventHandlers/Voter.ts +++ b/src/EventHandlers/Voter.ts @@ -69,6 +69,7 @@ Voter.GaugeCreated.handler(async ({ event, context }) => { Voter.DistributeReward.handlerWithLoader({ loader: async ({ event, context }) => { + let poolAddress = getPoolAddressByGaugeAddress( event.chainId, event.params.gauge diff --git a/test/EventHandlers/CLPool.test.ts b/test/EventHandlers/CLPool/CLPool.test.ts similarity index 97% rename from test/EventHandlers/CLPool.test.ts rename to test/EventHandlers/CLPool/CLPool.test.ts index ec461b6..b0b4080 100644 --- a/test/EventHandlers/CLPool.test.ts +++ b/test/EventHandlers/CLPool/CLPool.test.ts @@ -1,14 +1,14 @@ import { expect } from "chai"; import sinon from "sinon"; -import { MockDb, CLPool } from "../../generated/src/TestHelpers.gen"; +import { MockDb, CLPool } from "../../../generated/src/TestHelpers.gen"; import { CLPoolAggregator, Token, CLFactory_PoolCreated, -} from "../../generated/src/Types.gen"; -import * as CLPoolAggregatorFunctions from "../../src/Aggregators/CLPoolAggregator"; -import * as PriceOracle from "../../src/PriceOracle"; -import { abs } from "../../src/Maths"; +} from "../../../generated/src/Types.gen"; +import * as CLPoolAggregatorFunctions from "../../../src/Aggregators/CLPoolAggregator"; +import * as PriceOracle from "../../../src/PriceOracle"; +import { abs } from "../../../src/Maths"; describe("CLPool Event Handlers", () => { let mockDb: any; diff --git a/test/Pool/Burn.test.ts b/test/EventHandlers/Pool/Burn.test.ts similarity index 91% rename from test/Pool/Burn.test.ts rename to test/EventHandlers/Pool/Burn.test.ts index 572874f..483a433 100644 --- a/test/Pool/Burn.test.ts +++ b/test/EventHandlers/Pool/Burn.test.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { Pool } from "../../generated/src/TestHelpers.gen"; -import { MockDb } from "../../generated/src/TestHelpers.gen"; +import { Pool } from "../../../generated/src/TestHelpers.gen"; +import { MockDb } from "../../../generated/src/TestHelpers.gen"; describe("Pool Burn Event", () => { let mockDb: any; diff --git a/test/Pool/Fees.test.ts b/test/EventHandlers/Pool/Fees.test.ts similarity index 91% rename from test/Pool/Fees.test.ts rename to test/EventHandlers/Pool/Fees.test.ts index 55ed700..9f26579 100644 --- a/test/Pool/Fees.test.ts +++ b/test/EventHandlers/Pool/Fees.test.ts @@ -1,8 +1,8 @@ import { expect } from "chai"; -import { Pool, MockDb } from "../../generated/src/TestHelpers.gen"; -import { LiquidityPoolAggregator, Token } from "../../generated/src/Types.gen"; +import { Pool, MockDb } from "../../../generated/src/TestHelpers.gen"; +import { LiquidityPoolAggregator, Token } from "../../../generated/src/Types.gen"; import { setupCommon } from "./common"; -import { TEN_TO_THE_18_BI, TEN_TO_THE_6_BI, toChecksumAddress, TokenIdByChain } from "../../src/Constants"; +import { TEN_TO_THE_18_BI, TEN_TO_THE_6_BI, toChecksumAddress, TokenIdByChain } from "../../../src/Constants"; describe("Pool Fees Event", () => { const { mockToken0Data, mockToken1Data } = setupCommon(); diff --git a/test/Pool/Mint.test.ts b/test/EventHandlers/Pool/Mint.test.ts similarity index 94% rename from test/Pool/Mint.test.ts rename to test/EventHandlers/Pool/Mint.test.ts index 9969f44..0bb5dd2 100644 --- a/test/Pool/Mint.test.ts +++ b/test/EventHandlers/Pool/Mint.test.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { Pool, MockDb } from "../../generated/src/TestHelpers.gen"; +import { Pool, MockDb } from "../../../generated/src/TestHelpers.gen"; import { setupCommon } from "./common"; describe("Pool Mint Event", () => { diff --git a/test/Pool/Swap.test.ts b/test/EventHandlers/Pool/Swap.test.ts similarity index 97% rename from test/Pool/Swap.test.ts rename to test/EventHandlers/Pool/Swap.test.ts index 2bbf0d0..3a808c2 100644 --- a/test/Pool/Swap.test.ts +++ b/test/EventHandlers/Pool/Swap.test.ts @@ -1,15 +1,15 @@ import { expect } from "chai"; -import { MockDb, Pool } from "../../generated/src/TestHelpers.gen"; -import { LiquidityPoolAggregator, Token } from "../../generated/src/Types.gen"; +import { MockDb, Pool } from "../../../generated/src/TestHelpers.gen"; +import { LiquidityPoolAggregator, Token } from "../../../generated/src/Types.gen"; import { setupCommon } from "./common"; import { TEN_TO_THE_18_BI, TEN_TO_THE_6_BI, toChecksumAddress, TokenIdByChain, -} from "../../src/Constants"; +} from "../../../src/Constants"; import sinon from "sinon"; -import * as PriceOracle from "../../src/PriceOracle"; +import * as PriceOracle from "../../../src/PriceOracle"; describe("Pool Swap Event", () => { let mockToken0Data: any; diff --git a/test/Pool/Sync.test.ts b/test/EventHandlers/Pool/Sync.test.ts similarity index 95% rename from test/Pool/Sync.test.ts rename to test/EventHandlers/Pool/Sync.test.ts index a16bef3..bf30f40 100644 --- a/test/Pool/Sync.test.ts +++ b/test/EventHandlers/Pool/Sync.test.ts @@ -1,8 +1,8 @@ import { expect } from "chai"; -import { Pool, MockDb } from "../../generated/src/TestHelpers.gen"; -import { LiquidityPoolAggregator } from "../../generated/src/Types.gen"; +import { Pool, MockDb } from "../../../generated/src/TestHelpers.gen"; +import { LiquidityPoolAggregator } from "../../../generated/src/Types.gen"; import { setupCommon } from "./common"; -import { TEN_TO_THE_18_BI, TEN_TO_THE_6_BI, toChecksumAddress, TokenIdByChain } from "../../src/Constants"; +import { TEN_TO_THE_18_BI, TEN_TO_THE_6_BI, toChecksumAddress, TokenIdByChain } from "../../../src/Constants"; describe("Pool Sync Event", () => { let mockToken0Data: any; diff --git a/test/Pool/common.ts b/test/EventHandlers/Pool/common.ts similarity index 92% rename from test/Pool/common.ts rename to test/EventHandlers/Pool/common.ts index f4fde7a..9603361 100644 --- a/test/Pool/common.ts +++ b/test/EventHandlers/Pool/common.ts @@ -1,5 +1,5 @@ -import { MockDb } from "../../generated/src/TestHelpers.gen"; -import { TEN_TO_THE_18_BI, TEN_TO_THE_6_BI, TokenIdByChain } from "../../src/Constants"; +import { MockDb } from "../../../generated/src/TestHelpers.gen"; +import { TEN_TO_THE_18_BI, TEN_TO_THE_6_BI, TokenIdByChain } from "../../../src/Constants"; export function setupCommon() { diff --git a/test/PoolFactory.test.ts b/test/EventHandlers/PoolFactory.test.ts similarity index 91% rename from test/PoolFactory.test.ts rename to test/EventHandlers/PoolFactory.test.ts index 018de6c..64ad728 100644 --- a/test/PoolFactory.test.ts +++ b/test/EventHandlers/PoolFactory.test.ts @@ -1,8 +1,8 @@ import { expect } from "chai"; -import { MockDb, PoolFactory } from "../generated/src/TestHelpers.gen"; -import { LiquidityPoolAggregator, Token } from "../generated/src/Types.gen"; -import { TEN_TO_THE_18_BI } from "../src/Constants"; -import { toChecksumAddress } from "../src/Constants"; +import { MockDb, PoolFactory } from "../../generated/src/TestHelpers.gen"; +import { LiquidityPoolAggregator, Token } from "../../generated/src/Types.gen"; +import { TEN_TO_THE_18_BI } from "../../src/Constants"; +import { toChecksumAddress } from "../../src/Constants"; describe("PoolFactory Events", () => { diff --git a/test/EventHandlers/Voter.test.ts b/test/EventHandlers/Voter.test.ts new file mode 100644 index 0000000..ea23f15 --- /dev/null +++ b/test/EventHandlers/Voter.test.ts @@ -0,0 +1,207 @@ +import { expect } from "chai"; +import { MockDb, Voter } from "../../generated/src/TestHelpers.gen"; +import { TokenIdByChain, CHAIN_CONSTANTS } from "../../src/Constants"; +import { Token, LiquidityPoolAggregator } from "../../generated/src/Types.gen"; +import * as Store from "../../src/Store"; +import sinon from "sinon"; + +describe("Voter Events", () => { + describe("WhitelistToken event", () => { + let resultDB: ReturnType; + let expectedId: string; + let mockDb: ReturnType; + let mockEvent: any; + beforeEach(async () => { + mockDb = MockDb.createMockDb(); + mockEvent = Voter.WhitelistToken.createMockEvent({ + whitelister: "0x1111111111111111111111111111111111111111", + token: "0x2222222222222222222222222222222222222222", + _bool: true, + mockEventData: { + block: { + number: 123456, + timestamp: 1000000, + hash: "0x1234567890123456789012345678901234567890123456789012345678901234", + }, + chainId: 10, + logIndex: 1, + }, + }); + }); + describe("if token is in the db", () => { + + const expectedPricePerUSDNew = BigInt(10000000); + beforeEach(async () => { + // Note token doesn't have lastUpdatedTimestamp due to bug in codegen. + // Will cast during the set call. + const token = { + id: TokenIdByChain("0x2222222222222222222222222222222222222222", 10), + address: "0x2222222222222222222222222222222222222222", + symbol: "TEST", + name: "TEST", + chainId: 10, + decimals: BigInt(18), + pricePerUSDNew: expectedPricePerUSDNew, + isWhitelisted: false, + }; + + const updatedDB1 = mockDb.entities.Token.set(token as Token); + + resultDB = await Voter.WhitelistToken.processEvent({ event: mockEvent, mockDb: updatedDB1 }); + + expectedId = `${mockEvent.chainId}_${mockEvent.block.number}_${mockEvent.logIndex}`; + }); + it("should create a new WhitelistToken entity", async () => { + const whitelistTokenEvent = resultDB.entities.Voter_WhitelistToken.get(expectedId); + expect(whitelistTokenEvent).to.not.be.undefined; + expect(whitelistTokenEvent?.whitelister).to.equal("0x1111111111111111111111111111111111111111"); + expect(whitelistTokenEvent?.token).to.equal("0x2222222222222222222222222222222222222222"); + expect(whitelistTokenEvent?.isWhitelisted).to.be.true; + expect(whitelistTokenEvent?.timestamp).to.deep.equal(new Date(1000000 * 1000)); + expect(whitelistTokenEvent?.chainId).to.equal(10); + }); + + it("should update the token entity", async () => { + const token = resultDB.entities.Token.get(TokenIdByChain("0x2222222222222222222222222222222222222222", 10)); + expect(token?.isWhitelisted).to.be.true; + expect(token?.pricePerUSDNew).to.equal(expectedPricePerUSDNew); + }); + + }); + describe("if token is not in the db", () => { + + let resultDB: ReturnType; + let expectedId: string; + beforeEach(async () => { + + resultDB = await Voter.WhitelistToken.processEvent({ event: mockEvent, mockDb: mockDb }); + + expectedId = `${mockEvent.chainId}_${mockEvent.block.number}_${mockEvent.logIndex}`; + }); + it("should create a new WhitelistToken entity", async () => { + const whitelistTokenEvent = resultDB.entities.Voter_WhitelistToken.get(expectedId); + expect(whitelistTokenEvent).to.not.be.undefined; + expect(whitelistTokenEvent?.whitelister).to.equal("0x1111111111111111111111111111111111111111"); + expect(whitelistTokenEvent?.token).to.equal("0x2222222222222222222222222222222222222222"); + expect(whitelistTokenEvent?.isWhitelisted).to.be.true; + expect(whitelistTokenEvent?.timestamp).to.deep.equal(new Date(1000000 * 1000)); + expect(whitelistTokenEvent?.chainId).to.equal(10); + }); + + it("should create a new Token entity", async () => { + const token = resultDB.entities.Token.get(TokenIdByChain("0x2222222222222222222222222222222222222222", 10)); + expect(token?.isWhitelisted).to.be.true; + expect(token?.pricePerUSDNew).to.equal(0n); + }); + + }); + }); + + describe("DistributeReward Event", () => { + let mockDb: ReturnType; + let mockEvent: ReturnType; + + /** + * Constants for the Distribute Reward event test. Note that we can use real + * poolAddress and gaugeAddresses to make the call work. + * + * @constant {number} chainId - The chain ID for Optimism. + * @constant {string} poolAddress - The address of the liquidity pool. + * @constant {string} gaugeAddress - The address of the gauge. + * + * @see {@link ../../.cache/guagetopool-10.json} for a mapping between gauge and pool that exists. + */ + const chainId = 10; // Optimism + const poolAddress = "0x904f14F9ED81d0b0a40D8169B28592aac5687158"; + const gaugeAddress = "0x91f2e5c009d3742188fa77619582402681d73f98"; + + const rewardTokenAddress = CHAIN_CONSTANTS[chainId].rewardToken.address; + + beforeEach(() => { + mockDb = MockDb.createMockDb(); + + // Setup the mock event + mockEvent = Voter.DistributeReward.createMockEvent({ + gauge: gaugeAddress, + amount: 1000n * 10n ** 18n, // 1000 tokens with 18 decimals + mockEventData: { + block: { + number: 123456, + timestamp: 1000000, + hash: "0xblockhash", + }, + chainId: chainId, + logIndex: 0, + }, + }); + + }); + + afterEach(() => { + sinon.restore(); + }); + + describe("when reward token and liquidity pool exist", () => { + let resultDB: ReturnType; + + beforeEach(async () => { + // Setup mock reward token + const rewardToken: Token = { + id: TokenIdByChain(rewardTokenAddress, chainId), + address: rewardTokenAddress, + symbol: "VELO", + name: "VELO", + chainId: chainId, + decimals: 18n, + pricePerUSDNew: 2n * 10n ** 18n, // $2 per token + isWhitelisted: true, + } as Token; + + // Setup mock liquidity pool + const liquidityPool: LiquidityPoolAggregator = { + id: poolAddress, + chainId: chainId, + name: "Test Pool", + token0_id: "token0-10", + token1_id: "token1-10", + token0_address: "0xtoken0", + token1_address: "0xtoken1", + isStable: false, + reserve0: 0n, + reserve1: 0n, + totalLiquidityUSD: 0n, + totalVolume0: 0n, + totalVolume1: 0n, + totalVolumeUSD: 0n, + totalFees0: 0n, + totalFees1: 0n, + totalFeesUSD: 0n, + numberOfSwaps: 0n, + token0Price: 0n, + token1Price: 0n, + totalEmissions: 1000n * 10n ** 18n, + totalEmissionsUSD: 2000n * 10n ** 18n, + totalBribesUSD: 0n, + } as LiquidityPoolAggregator; + + // Set entities in the mock database + const updatedDB1 = mockDb.entities.Token.set(rewardToken); + const updatedDB2 = updatedDB1.entities.LiquidityPoolAggregator.set(liquidityPool); + + // Process the event + resultDB = await Voter.DistributeReward.processEvent({ + event: mockEvent, + mockDb: updatedDB2, + }); + }); + + it("should update the liquidity pool aggregator with emissions data", () => { + const updatedPool = resultDB.entities.LiquidityPoolAggregator.get(poolAddress); + expect(updatedPool).to.not.be.undefined; + expect(updatedPool?.totalEmissions).to.equal(2000n * 10n ** 18n, "Should add 1000 tokens to existing 1000"); + expect(updatedPool?.totalEmissionsUSD).to.equal(4000n * 10n ** 18n, "Should add $2000 (1000 tokens * $2) to existing $2000"); + expect(updatedPool?.lastUpdatedTimestamp).to.deep.equal(new Date(1000000 * 1000)); + }); + }); + }); +}); diff --git a/test/EventHandlers/VotingReward.test.ts b/test/EventHandlers/VotingReward.test.ts new file mode 100644 index 0000000..cf3ecb8 --- /dev/null +++ b/test/EventHandlers/VotingReward.test.ts @@ -0,0 +1,131 @@ +import { expect } from "chai"; +import { MockDb, VotingReward } from "../../generated/src/TestHelpers.gen"; +import { TokenIdByChain } from "../../src/Constants"; +import { Token, LiquidityPoolAggregator } from "../../generated/src/Types.gen"; +import * as Store from "../../src/Store"; +import sinon from "sinon"; + +describe("VotingReward Events", () => { + describe("NotifyReward Event", () => { + let mockDb: ReturnType; + let mockEvent: ReturnType; + + /** + * Constants for the NotifyReward event test. + * + * @constant {number} chainId - The chain ID for Optimism. + * @constant {string} poolAddress - The address of the liquidity pool. + * @constant {string} bribeVotingRewardAddress - The address of the bribe voting reward contract. + * @constant {string} rewardTokenAddress - The address of the reward token being distributed. + */ + const chainId = 10; // Optimism + + const poolAddress = "0x904f14F9ED81d0b0a40D8169B28592aac5687158"; + const bribeVotingRewardAddress = "0x9afdc6c6caad5ff953e2cff9777c3af2e5d796fb"; + const rewardTokenAddress = "0x3c8B650257cFb5f272f799F5e2b4e65093a11a05"; + + beforeEach(() => { + mockDb = MockDb.createMockDb(); + + // Setup the mock event + mockEvent = VotingReward.NotifyReward.createMockEvent({ + from: "0x1234567890123456789012345678901234567890", + reward: rewardTokenAddress, + epoch: 1n, + amount: 1000n * 10n ** 18n, // 1000 tokens with 18 decimals + mockEventData: { + block: { + number: 123456, + timestamp: 1000000, + hash: "0xblockhash", + }, + chainId: chainId, + logIndex: 0, + srcAddress: bribeVotingRewardAddress, + }, + }); + + // Stub the pool lookup function + sinon.stub(Store.poolLookupStoreManager(), "getPoolAddressByBribeVotingRewardAddress") + .returns(poolAddress); + }); + + afterEach(() => { + sinon.restore(); + }); + + describe("when reward token and liquidity pool exist", () => { + let resultDB: ReturnType; + + beforeEach(async () => { + // Setup mock reward token + const rewardToken: Token = { + id: TokenIdByChain(rewardTokenAddress, chainId), + address: rewardTokenAddress, + symbol: "TEST", + name: "Test Token", + chainId: chainId, + decimals: 18n, + pricePerUSDNew: 2n * 10n ** 18n, // $2 per token + isWhitelisted: true, + } as Token; + + // Setup mock liquidity pool + const liquidityPool: LiquidityPoolAggregator = { + id: poolAddress, + chainId: chainId, + name: "Test Pool", + token0_id: "token0-10", + token1_id: "token1-10", + token0_address: "0xtoken0", + token1_address: "0xtoken1", + isStable: false, + reserve0: 0n, + reserve1: 0n, + totalLiquidityUSD: 0n, + totalVolume0: 0n, + totalVolume1: 0n, + totalVolumeUSD: 0n, + totalFees0: 0n, + totalFees1: 0n, + totalFeesUSD: 0n, + numberOfSwaps: 0n, + token0Price: 0n, + token1Price: 0n, + totalEmissions: 0n, + totalEmissionsUSD: 0n, + totalBribesUSD: 1000n * 10n ** 18n, // Starting with $1000 in bribes + } as LiquidityPoolAggregator; + + // Set entities in the mock database + const updatedDB1 = mockDb.entities.Token.set(rewardToken); + const updatedDB2 = updatedDB1.entities.LiquidityPoolAggregator.set(liquidityPool); + + // Process the event + resultDB = await VotingReward.NotifyReward.processEvent({ + event: mockEvent, + mockDb: updatedDB2, + }); + }); + + it("should create a VotingReward_NotifyReward entity", () => { + const notifyRewardEvent = resultDB.entities.VotingReward_NotifyReward.get( + `${mockEvent.chainId}_${mockEvent.block.number}_${mockEvent.logIndex}` + ); + expect(notifyRewardEvent).to.not.be.undefined; + expect(notifyRewardEvent?.from).to.equal("0x1234567890123456789012345678901234567890"); + expect(notifyRewardEvent?.reward).to.equal(rewardTokenAddress); + expect(notifyRewardEvent?.amount).to.equal(1000n * 10n ** 18n); + expect(notifyRewardEvent?.epoch).to.equal(1n); + }); + + it("should update the liquidity pool aggregator with bribes data", () => { + const updatedPool = resultDB.entities.LiquidityPoolAggregator.get(poolAddress); + expect(updatedPool).to.not.be.undefined; + expect(updatedPool?.totalBribesUSD).to.equal(3000n * 10n ** 18n, + "Should add $2000 (1000 tokens * $2) to existing $1000"); + expect(updatedPool?.lastUpdatedTimestamp).to.deep.equal(new Date(1000000 * 1000)); + }); + }); + }); +}); \ No newline at end of file diff --git a/test/Voter.test.ts b/test/Voter.test.ts deleted file mode 100644 index c09cf7f..0000000 --- a/test/Voter.test.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { expect } from "chai"; -import { MockDb, Voter } from "../generated/src/TestHelpers.gen"; -import { TokenIdByChain } from "../src/Constants"; -import { Token } from "../generated/src/Types.gen"; - -describe("Voter Events", () => { - describe("WhitelistToken event", () => { - let resultDB: ReturnType; - let expectedId: string; - let mockDb: ReturnType; - let mockEvent: any; - beforeEach(async () => { - mockDb = MockDb.createMockDb(); - mockEvent = Voter.WhitelistToken.createMockEvent({ - whitelister: "0x1111111111111111111111111111111111111111", - token: "0x2222222222222222222222222222222222222222", - _bool: true, - mockEventData: { - block: { - number: 123456, - timestamp: 1000000, - hash: "0x1234567890123456789012345678901234567890123456789012345678901234", - }, - chainId: 10, - logIndex: 1, - }, - }); - }); - describe("if token is in the db", () => { - - const expectedPricePerUSDNew = BigInt(10000000); - beforeEach(async () => { - // Note token doesn't have lastUpdatedTimestamp due to bug in codegen. - // Will cast during the set call. - const token = { - id: TokenIdByChain("0x2222222222222222222222222222222222222222", 10), - address: "0x2222222222222222222222222222222222222222", - symbol: "TEST", - name: "TEST", - chainId: 10, - decimals: BigInt(18), - pricePerUSDNew: expectedPricePerUSDNew, - isWhitelisted: false, - }; - - const updatedDB1 = mockDb.entities.Token.set(token as Token); - - resultDB = await Voter.WhitelistToken.processEvent({ event: mockEvent, mockDb: updatedDB1 }); - - expectedId = `${mockEvent.chainId}_${mockEvent.block.number}_${mockEvent.logIndex}`; - }); - it("should create a new WhitelistToken entity", async () => { - const whitelistTokenEvent = resultDB.entities.Voter_WhitelistToken.get(expectedId); - expect(whitelistTokenEvent).to.not.be.undefined; - expect(whitelistTokenEvent?.whitelister).to.equal("0x1111111111111111111111111111111111111111"); - expect(whitelistTokenEvent?.token).to.equal("0x2222222222222222222222222222222222222222"); - expect(whitelistTokenEvent?.isWhitelisted).to.be.true; - expect(whitelistTokenEvent?.timestamp).to.deep.equal(new Date(1000000 * 1000)); - expect(whitelistTokenEvent?.chainId).to.equal(10); - }); - - it("should update the token entity", async () => { - const token = resultDB.entities.Token.get(TokenIdByChain("0x2222222222222222222222222222222222222222", 10)); - expect(token?.isWhitelisted).to.be.true; - expect(token?.pricePerUSDNew).to.equal(expectedPricePerUSDNew); - }); - - }); - describe("if token is not in the db", () => { - - let resultDB: ReturnType; - let expectedId: string; - beforeEach(async () => { - - resultDB = await Voter.WhitelistToken.processEvent({ event: mockEvent, mockDb: mockDb }); - - expectedId = `${mockEvent.chainId}_${mockEvent.block.number}_${mockEvent.logIndex}`; - }); - it("should create a new WhitelistToken entity", async () => { - const whitelistTokenEvent = resultDB.entities.Voter_WhitelistToken.get(expectedId); - expect(whitelistTokenEvent).to.not.be.undefined; - expect(whitelistTokenEvent?.whitelister).to.equal("0x1111111111111111111111111111111111111111"); - expect(whitelistTokenEvent?.token).to.equal("0x2222222222222222222222222222222222222222"); - expect(whitelistTokenEvent?.isWhitelisted).to.be.true; - expect(whitelistTokenEvent?.timestamp).to.deep.equal(new Date(1000000 * 1000)); - expect(whitelistTokenEvent?.chainId).to.equal(10); - }); - - it("should create a new Token entity", async () => { - const token = resultDB.entities.Token.get(TokenIdByChain("0x2222222222222222222222222222222222222222", 10)); - expect(token?.isWhitelisted).to.be.true; - expect(token?.pricePerUSDNew).to.equal(0n); - }); - - }); - }); -});