From 89ad636f1f44777c1597e00b6a1fbb75ce4f9a29 Mon Sep 17 00:00:00 2001 From: gabriel-aranha-cw Date: Thu, 14 Nov 2024 12:47:17 -0300 Subject: [PATCH] chore: add to automine as well --- e2e/test/automine/e2e-json-rpc.test.ts | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/e2e/test/automine/e2e-json-rpc.test.ts b/e2e/test/automine/e2e-json-rpc.test.ts index c94e10f31..3bf45591b 100644 --- a/e2e/test/automine/e2e-json-rpc.test.ts +++ b/e2e/test/automine/e2e-json-rpc.test.ts @@ -14,6 +14,7 @@ import { TEST_BALANCE, ZERO, deployTestContractBalances, + deployTestContractBlockTimestamp, prepareSignedTx, send, sendAndGetError, @@ -267,6 +268,33 @@ describe("JSON-RPC", () => { await send("evm_setNextBlockTimestamp", [0]); }); }); + + describe("Block timestamp", () => { + it("transaction executes with pending block timestamp", async () => { + await sendReset(); + + const contract = await deployTestContractBlockTimestamp(); + + // Record timestamp in contract + const tx = await contract.recordTimestamp(); + + const receipt = await tx.wait(); + + // Get the timestamp from contract event + const event = receipt.logs[0]; + const recordedTimestamp = contract.interface.parseLog({ + topics: event.topics, + data: event.data, + })?.args.timestamp; + + // Get the block timestamp + const block = await ETHERJS.getBlock(receipt.blockNumber); + const blockTimestamp = block!.timestamp; + + // Validate contract saw same timestamp as block + expect(recordedTimestamp).to.equal(blockTimestamp); + }); + }); }); describe("Subscription", () => {