Skip to content

Commit

Permalink
chore: add to automine as well
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-aranha-cw committed Nov 14, 2024
1 parent 64e75f2 commit 89ad636
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions e2e/test/automine/e2e-json-rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TEST_BALANCE,
ZERO,
deployTestContractBalances,
deployTestContractBlockTimestamp,
prepareSignedTx,
send,
sendAndGetError,
Expand Down Expand Up @@ -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", () => {
Expand Down

0 comments on commit 89ad636

Please sign in to comment.