Skip to content

Commit 1af8d1e

Browse files
committed
fix: block cache tests
1 parent 64c9d41 commit 1af8d1e

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/blockCache/sqlite.test.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,37 @@ describe("createSqliteBlockCache", () => {
4646

4747
it("should save and retrieve a block by number", async () => {
4848
await blockCache.init();
49-
const block = { chainId: 1, blockNumber: BigInt(1), timestamp: 12345 };
49+
const block = {
50+
chainId: 1,
51+
blockNumber: BigInt(1),
52+
timestampInSecs: 12345,
53+
};
5054
await blockCache.saveBlock(block);
5155

52-
const retrievedBlock = await blockCache.getBlockByNumber(1, BigInt(1));
53-
expect(retrievedBlock).toEqual(block);
56+
const timestampInSecs = await blockCache.getTimestampByBlockNumber(
57+
1,
58+
BigInt(1)
59+
);
60+
expect(timestampInSecs).toEqual(block.timestampInSecs);
5461
});
5562

5663
it("should save and retrieve a block by timestamp", async () => {
5764
await blockCache.init();
58-
const block = { chainId: 1, blockNumber: BigInt(1), timestamp: 12345 };
65+
const block = {
66+
chainId: 1,
67+
blockNumber: BigInt(1),
68+
timestampInSecs: 12345,
69+
};
5970
await blockCache.saveBlock(block);
6071

61-
const retrievedBlock = await blockCache.getBlockByTimestamp(1, 12345);
62-
expect(retrievedBlock).toEqual(block);
72+
const blockNumber = await blockCache.getBlockNumberByTimestamp(1, 12345);
73+
expect(blockNumber).toEqual(block.blockNumber);
6374
});
6475

6576
it("should get closest bounds for timestamp", async () => {
6677
await blockCache.init();
67-
const block1 = { chainId: 1, blockNumber: BigInt(1), timestamp: 10 };
68-
const block2 = { chainId: 1, blockNumber: BigInt(2), timestamp: 20 };
78+
const block1 = { chainId: 1, blockNumber: BigInt(1), timestampInSecs: 10 };
79+
const block2 = { chainId: 1, blockNumber: BigInt(2), timestampInSecs: 20 };
6980

7081
await blockCache.saveBlock(block1);
7182
await blockCache.saveBlock(block2);

0 commit comments

Comments
 (0)