Skip to content

Commit

Permalink
Remove old tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarid27 committed Feb 27, 2025
1 parent 2d9a745 commit 5dd512d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 266 deletions.
29 changes: 0 additions & 29 deletions test/EventHandlers/CLPool/CLPool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,34 +508,5 @@ describe("CLPool Event Handlers", () => {
expect(updatedLiquidityPool.token1IsWhitelisted).to.equal(mockToken1Data.isWhitelisted);
});
});

describe("when tokens do not exist", () => {
beforeEach(async () => {
let updatedDB = mockDb.entities.LiquidityPoolAggregator.set(mockLiquidityPoolData);
updatedDB = updatedDB.entities.Token.set(mockToken1Data);

await CLPool.Swap.processEvent({
event: mockEvent,
mockDb: updatedDB,
});
});

it("should handle missing token instances", async () => {
expect(updateLiquidityPoolAggregatorStub.calledOnce).to.be.true;
const [diff] = updateLiquidityPoolAggregatorStub.firstCall.args;

expect(diff.totalVolume0).to.equal(
mockLiquidityPoolData.totalVolume0 + abs(mockEvent.params.amount0)
);
expect(diff.totalVolume1).to.equal(
mockLiquidityPoolData.totalVolume1 + abs(mockEvent.params.amount1)
);
expect(diff.totalVolumeUSD).to.equal(
mockLiquidityPoolData.totalVolumeUSD +
(abs(mockEvent.params.amount1) * mockToken1Data.pricePerUSDNew) /
10n ** mockToken1Data.decimals
);
});
});
});
});
210 changes: 0 additions & 210 deletions test/EventHandlers/Pool/Swap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,216 +90,6 @@ describe("Pool Swap Event", () => {
mockPriceOracle.restore();
});

describe("when both tokens are missing", () => {
let updatedPool: any;
let modifiedMockLiquidityPoolData: any;
beforeEach(async () => {

modifiedMockLiquidityPoolData = {
...mockLiquidityPoolData,
token0_id: TokenIdByChain(
"0x9999999999999999999999999999999999999990",
10
),
token1_id: TokenIdByChain(
"0x9999999999999999999999999999999999999999",
10
),
};

const updatedDB1 = mockDb.entities.LiquidityPoolAggregator.set(
modifiedMockLiquidityPoolData as LiquidityPoolAggregator
);
const mockEvent = Pool.Swap.createMockEvent(eventData);

const postEventDB = await Pool.Swap.processEvent({
event: mockEvent,
mockDb: updatedDB1,
});

updatedPool = postEventDB.entities.LiquidityPoolAggregator.get(
toChecksumAddress(eventData.mockEventData.srcAddress)
);

});
it("should update the liquidity pool and timestamp", () => {
expect(updatedPool).to.not.be.undefined;
expect(updatedPool?.lastUpdatedTimestamp).to.deep.equal(
new Date(eventData.mockEventData.block.timestamp * 1000)
);
});
it("should update the liquidity pool with swap count", async () => {
expect(updatedPool?.numberOfSwaps).to
.equal(mockLiquidityPoolData.numberOfSwaps + 1n, "Swap count should be updated");
});
it("should update the liquidity pool with swap volume", () => {
expect(updatedPool?.totalVolume0).to.equal(
modifiedMockLiquidityPoolData.totalVolume0 + expectations.expectedNetAmount0
);
expect(updatedPool?.totalVolume1).to.equal(
modifiedMockLiquidityPoolData.totalVolume1 + expectations.expectedNetAmount1
);

});

it("should update the liquidity pool with token0IsWhitelisted as false", () => {
expect(updatedPool?.token0IsWhitelisted).to.equal(false);
});
it("should update the liquidity pool with token1IsWhitelisted as false", () => {
expect(updatedPool?.token1IsWhitelisted).to.equal(false);
});

it("shouldn't update the liquidity pool volume in USD since it has no prices", () => {
expect(updatedPool?.totalVolumeUSD).to.equal(
modifiedMockLiquidityPoolData.totalVolumeUSD
);
});
it("shouldn't update the liquidity pool volume in USD whitelisted since it has no prices", () => {
expect(updatedPool?.totalVolumeUSDWhitelisted).to.equal(
modifiedMockLiquidityPoolData.totalVolumeUSDWhitelisted
);
});
it("should not call refreshTokenPrice", () => {
expect(mockPriceOracle.calledOnce).to.be.false;
});
});
describe("when token0 is missing", () => {
let postEventDB: ReturnType<typeof MockDb.createMockDb>;

let updatedPool: any;
beforeEach(async () => {
// Set token0 to a different address not in the db tokens
mockLiquidityPoolData.token0_id = TokenIdByChain(
"0x9999999999999999999999999999999999999999",
10
);

const updatedDB1 = mockDb.entities.LiquidityPoolAggregator.set(
mockLiquidityPoolData as LiquidityPoolAggregator
);
const updatedDB2 = updatedDB1.entities.Token.set(mockToken0Data as Token);
const updatedDB3 = updatedDB2.entities.Token.set(mockToken1Data as Token);

const mockEvent = Pool.Swap.createMockEvent(eventData);

postEventDB = await Pool.Swap.processEvent({
event: mockEvent,
mockDb: updatedDB3,
});
updatedPool = postEventDB.entities.LiquidityPoolAggregator.get(
toChecksumAddress(eventData.mockEventData.srcAddress)
);
});

it('should update nominal swap volumes', () => {
expect(updatedPool?.totalVolume0).to.equal(
expectations.totalVolume0,
"Token0 nominal swap volume should be updated"
);
expect(updatedPool?.totalVolume1).to.equal(
expectations.totalVolume1,
"Token1 nominal swap volume should be updated"
);
});

it("should update the liquidity pool with token1 data only", async () => {
expect(updatedPool?.totalVolumeUSD).to.equal(
expectations.expectedLPVolumeUSD1,
"Swap volume in USD should be updated for token 1"
);

expect(updatedPool?.totalVolumeUSDWhitelisted).to.equal(
mockLiquidityPoolData.totalVolumeUSDWhitelisted,
"Total volume USD whitelisted should not be updated since token1 is not whitelisted."
);

expect(updatedPool?.numberOfSwaps).to.equal(
mockLiquidityPoolData.numberOfSwaps + 1n,
"Swap count should be updated"
);
});

it("should update the liquidity pool with token0IsWhitelisted as false", () => {
expect(updatedPool?.token0IsWhitelisted).to.equal(false);
});
it("should update the liquidity pool with token1IsWhitelisted as true", () => {
expect(updatedPool?.token1IsWhitelisted).to.equal(mockToken1Data.isWhitelisted);
});

it("should call refreshTokenPrice on token1", () => {
expect(mockPriceOracle.calledOnce).to.be.true;
const calledToken = mockPriceOracle.firstCall.args[0];
expect(calledToken.address).to.equal(mockToken1Data.address);
});
});

describe("when token1 is missing", () => {
let postEventDB: ReturnType<typeof MockDb.createMockDb>;
let updatedPool: any;

beforeEach(async () => {
mockLiquidityPoolData.token1_id = TokenIdByChain(
"0x9999999999999999999999999999999999999999",
10
);

const updatedDB1 = mockDb.entities.LiquidityPoolAggregator.set(
mockLiquidityPoolData as LiquidityPoolAggregator
);
const updatedDB2 = updatedDB1.entities.Token.set(mockToken0Data as Token);
const updatedDB3 = updatedDB2.entities.Token.set(mockToken1Data as Token);

const mockEvent = Pool.Swap.createMockEvent(eventData);

postEventDB = await Pool.Swap.processEvent({
event: mockEvent,
mockDb: updatedDB3,
});
updatedPool = postEventDB.entities.LiquidityPoolAggregator.get(
toChecksumAddress(eventData.mockEventData.srcAddress)
);
});

it('should update nominal swap volumes', () => {
expect(updatedPool?.totalVolume0).to.equal(
expectations.totalVolume0,
"Token0 nominal swap volume should be updated"
);
expect(updatedPool?.totalVolume1).to.equal(
expectations.totalVolume1,
"Token1 nominal swap volume should be updated"
);

});

it('should update swap count', () => {
expect(updatedPool?.numberOfSwaps).to.equal(
mockLiquidityPoolData.numberOfSwaps + 1n,
"Swap count should be updated"
);
});

it("should update the liquidity pool USD volume with token0 data only", async () => {
expect(updatedPool?.totalVolumeUSD).to.equal(
expectations.expectedLPVolumeUSD0,
"Total volume USD should be updated."
);

expect(updatedPool?.totalVolumeUSDWhitelisted).to.equal(
mockLiquidityPoolData.totalVolumeUSDWhitelisted,
"Total volume USD whitelisted should not be updated since token0 is not whitelisted."
);
});
it("should update the liquidity pool with token0IsWhitelisted", () => {
expect(updatedPool?.token0IsWhitelisted).to.equal(mockToken0Data.isWhitelisted);
});
it("should call refreshTokenPrice on token0", () => {
expect(mockPriceOracle.calledOnce).to.be.true;
const calledToken = mockPriceOracle.firstCall.args[0];
expect(calledToken.address).to.equal(mockToken0Data.address);
});
});

describe("when both tokens exist", () => {
let postEventDB: ReturnType<typeof MockDb.createMockDb>;
let updatedPool: any;
Expand Down
27 changes: 0 additions & 27 deletions test/EventHandlers/Pool/Sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,6 @@ describe("Pool Sync Event", () => {
mockDb = MockDb.createMockDb();
});

describe("when both tokens are missing", () => {
it("should update LiquidityPool reserves, but not liquidity USD", async () => {
const modifiedMockLiquidityPoolData = {
...mockLiquidityPoolData,
token0_id: TokenIdByChain("0x9999999999999999999999999999999999999990", 10),
token1_id: TokenIdByChain("0x9999999999999999999999999999999999999999", 10),
};

const updatedDB1 = mockDb.entities.LiquidityPoolAggregator.set(modifiedMockLiquidityPoolData as LiquidityPoolAggregator);
const mockEvent = Pool.Sync.createMockEvent(eventData);

const postEventDB = await Pool.Sync.processEvent({
event: mockEvent,
mockDb: updatedDB1,
});

const updatedPool = postEventDB.entities.LiquidityPoolAggregator.get(
toChecksumAddress(eventData.mockEventData.srcAddress)
);
expect(updatedPool).to.not.be.undefined;
expect(updatedPool?.reserve0).to.equal(expectations.expectedReserve0InMissing);
expect(updatedPool?.reserve1).to.equal(expectations.expectedReserve1InMissing);
expect(updatedPool?.totalLiquidityUSD)
.to.equal(mockLiquidityPoolData.totalLiquidityUSD, "totalLiquidityUSD should be the same as the original value");
});
});

describe("when both tokens exist", () => {
let postEventDB: ReturnType<typeof MockDb.createMockDb>;

Expand Down

0 comments on commit 5dd512d

Please sign in to comment.