Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: align current_miniblock, current_batch, current_timestamp to point to the latest entities #135

Merged
merged 9 commits into from
Sep 28, 2023
6 changes: 3 additions & 3 deletions e2e-tests/test/evm-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("evm_increaseTime", function () {
to: userWallet.address,
value: ethers.utils.parseEther("0.1"),
});
expectedTimestamp += 1; // New transaction will add a second block
expectedTimestamp += 2; // New transaction will add two blocks

// Assert
const newBlockTimestamp = (await provider.getBlock("latest")).timestamp;
Expand All @@ -60,7 +60,7 @@ describe("evm_setNextBlockTimestamp", function () {
to: userWallet.address,
value: ethers.utils.parseEther("0.1"),
});
expectedTimestamp += 1; // New transaction will add a second block
expectedTimestamp += 2; // New transaction will add two blocks

// Assert
const newBlockTimestamp = (await provider.getBlock("latest")).timestamp;
Expand All @@ -84,7 +84,7 @@ describe("evm_setTime", function () {
to: userWallet.address,
value: ethers.utils.parseEther("0.1"),
});
expectedTimestamp += 1; // New transaction will add a second block
expectedTimestamp += 2; // New transaction will add two blocks

// Assert
const newBlockTimestamp = (await provider.getBlock("latest")).timestamp;
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test/hardhat-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("hardhat_mine", function () {
const latestBlock = await provider.getBlock("latest");
expect(latestBlock.number).to.equal(startingBlock.number + numberOfBlocks, "Block number mismatch");
expect(latestBlock.timestamp).to.equal(
startingTimestamp + (numberOfBlocks - 1) * intervalInSeconds * 1000,
startingTimestamp + (numberOfBlocks - 1) * intervalInSeconds * 1000 + 1,
"Timestamp mismatch"
);
});
Expand Down
4 changes: 2 additions & 2 deletions src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ mod tests {
.expect("block exists");

assert_eq!(start_block.number + 1, current_block.number);
assert_eq!(start_block.timestamp + 1000, current_block.timestamp);
assert_eq!(start_block.timestamp + 1, current_block.timestamp);

let result = evm.evm_mine().await.expect("evm_mine");
assert_eq!(&result, "0x0");
Expand All @@ -478,6 +478,6 @@ mod tests {
.expect("block exists");

assert_eq!(start_block.number + 2, current_block.number);
assert_eq!(start_block.timestamp + 2000, current_block.timestamp);
assert_eq!(start_block.timestamp + 2, current_block.timestamp);
}
}
6 changes: 3 additions & 3 deletions src/hardhat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ mod tests {
.expect("block exists");

assert_eq!(start_block.number + 1, current_block.number);
assert_eq!(start_block.timestamp + 1000, current_block.timestamp);
assert_eq!(start_block.timestamp + 1, current_block.timestamp);
let result = hardhat
.hardhat_mine(None, None)
.await
Expand All @@ -330,7 +330,7 @@ mod tests {
.expect("block exists");

assert_eq!(start_block.number + 2, current_block.number);
assert_eq!(start_block.timestamp + 2000, current_block.timestamp);
assert_eq!(start_block.timestamp + 2, current_block.timestamp);
}

#[tokio::test]
Expand All @@ -347,7 +347,7 @@ mod tests {

let num_blocks = 5;
let interval = 3;
let start_timestamp = start_block.timestamp + 1_000;
let start_timestamp = start_block.timestamp + 1;

let result = hardhat
.hardhat_mine(Some(U64::from(num_blocks)), Some(U64::from(interval)))
Expand Down
Loading