I have a function where a specific time should be passed to run it.
function placeBid(...) {
require(auction.startedAt <= block.timestamp, "not started yet");
...
}
say startedAt is a unix value of 1648198972 I'm testing with
beforeEach(async function () {
await ethers.provider.send("evm_setNextBlockTimestamp", [parseInt(auction.startedAt)]);
await ethers.provider.send("evm_mine");
});
expect(await Auction.connect(user2).placeBid(...))});
describe("Success", function () {
it("Should send bid to previous bidder", async function () {
expect(bidder).to.equal(user2.address);
block = await ethers.provider.getBlock("latest");
console.log("current: ", block.timestamp)
});
it("....", async function () {
...
});
});
This can actually run placeBid which seems it passed the require statement, but I get an error related to timestamp!
Truth is, it always passes the first it statement, but it throws this timestamp error when it goes to the next it statement.
InvalidInputError: Timestamp 1648198972 is lower than or equal to previous block's timestamp 1648198986
what's wrong?
itstatement and that line is needed since i need to move current time to the future time i.e. 2 days later so require statement forauction.startedAtcan be passed – bbusdriver Feb 25 '22 at 11:56