it("it should not upkeepNeeded when time is not enough", async () => {
await lottery.enterLottery({ value: lotteryEnterFee });
await network.provider.send("evm_increaseTime", [
Number(interval) - 1,
]);
await network.provider.send("evm_mine", []);
const blockTs = await lottery.getBlockTimestamp();
const lastTs = await lottery.getLastTimestamp();
console.log(`block: ${blockTs}`);
console.log(`last: ${lastTs}`);
console.log(`diff: ${blockTs - lastTs}`);
const { upkeepNeeded } = await lottery.checkUpkeep.staticCall("0x");
assert(!upkeepNeeded);
});
when I test "it should not upkeepNeeded when time is not enough", I found AssertionError. Then I print block.timestamp and lastTimestamp, and I found the lastTimestamp is not actually equals interval -1. For example, my interval is 30, so interval-1 should be 29, but after I send the evm_increaseTime, my log is:
when I test "it should not upkeepNeeded when time is not enough", I found AssertionError. Then I print block.timestamp and lastTimestamp, and I found the lastTimestamp is not actually equals interval -1. For example, my interval is 30, so interval-1 should be 29, but after I send the evm_increaseTime, my log is:
Why diff is 31?
The part of setting lastTimestamp in my contract:
Is there any kind person who can help?