diff --git a/.changeset/violet-forks-lick.md b/.changeset/violet-forks-lick.md new file mode 100644 index 0000000..0bed5ef --- /dev/null +++ b/.changeset/violet-forks-lick.md @@ -0,0 +1,5 @@ +--- +"@delvtech/drift": patch +--- + +Fixed bigint parsing bug in `createStubBlock` diff --git a/packages/drift/src/adapter/utils/testing/createStubBlock.test.ts b/packages/drift/src/adapter/utils/testing/createStubBlock.test.ts new file mode 100644 index 0000000..bd2e2d6 --- /dev/null +++ b/packages/drift/src/adapter/utils/testing/createStubBlock.test.ts @@ -0,0 +1,30 @@ +import type { Block } from "src/adapter/types/Block"; +import { createStubBlock } from "src/exports/testing"; +import { describe, expect, it } from "vitest"; + +describe("createStubBlock", () => { + const hexRegex = /^0x[a-f0-9]*$/; + + it("creates a stub block", () => { + const block = createStubBlock(); + expect(block).toMatchObject({ + extraData: expect.stringMatching(hexRegex), + gasLimit: expect.any(BigInt), + gasUsed: expect.any(BigInt), + hash: expect.stringMatching(hexRegex), + logsBloom: expect.stringMatching(hexRegex), + miner: expect.stringMatching(hexRegex), + mixHash: expect.stringMatching(hexRegex), + nonce: expect.any(BigInt), + number: expect.any(BigInt), + parentHash: expect.stringMatching(hexRegex), + receiptsRoot: expect.stringMatching(hexRegex), + sha3Uncles: expect.stringMatching(hexRegex), + size: expect.any(BigInt), + stateRoot: expect.stringMatching(hexRegex), + timestamp: expect.any(BigInt), + transactions: expect.any(Array), + transactionsRoot: expect.stringMatching(hexRegex), + } as Block); + }); +}); diff --git a/packages/drift/src/adapter/utils/testing/createStubBlock.ts b/packages/drift/src/adapter/utils/testing/createStubBlock.ts index d0cc057..8643e08 100644 --- a/packages/drift/src/adapter/utils/testing/createStubBlock.ts +++ b/packages/drift/src/adapter/utils/testing/createStubBlock.ts @@ -22,7 +22,7 @@ export function createStubBlock(override: Partial = {}): Block { sha3Uncles: getRandomHex(), size: 100_000n, stateRoot: getRandomHex(), - timestamp: BigInt(Date.now() / 1000), + timestamp: BigInt(Date.now()) / 1000n, transactions: [], transactionsRoot: getRandomHex(), ...override,