Skip to content

Commit

Permalink
add test case involving evm_increaseTime (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
zemse committed Aug 5, 2024
1 parent fea860a commit cb064a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 3 additions & 1 deletion test/fixture-projects/hardhat-project/contracts/Hello.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ contract Hello {
uint256 id2;
}

function sample(string memory input) external {}
function sample(string memory input) external {
emit WhatsUp2(block.timestamp);
}

function hi2(Info[] memory) public payable {
assembly {
Expand Down
15 changes: 7 additions & 8 deletions test/fixture-projects/hardhat-project/test/Hello.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,20 @@ describe("Hello", () => {
await hre.ethers.provider.send("debug_traceTransaction", [tx.hash]);
});

it("sample", async () => {
await hre.network.provider.send("evm_mine");

it("sample evm_increaseTime", async () => {
const contract = await hre.ethers.getContractAt(
"Hello",
"0x0000000000000000000000000000001234567890",
wallet
);
// hre.tracer.printNext = true;

const tx1 = await contract.sample("hello");
const tx2 = await contract.sample("hello2");

await hre.network.provider.send("evm_mine");
expect(hre.tracer.lastTrace()?.hash).to.eq(tx1.hash);

console.log("debug tt");
await hre.ethers.provider.send("debug_traceTransaction", [tx1.hash]);
await hre.network.provider.send("evm_increaseTime", [1000]);

const tx2 = await contract.sample("hello2");
expect(hre.tracer.lastTrace()?.hash).to.eq(tx2.hash);
});
});

0 comments on commit cb064a0

Please sign in to comment.