clock: use wall clock in integration tests
reason: we'll need to wait for the next period in integration tests, and we can't do that if the time doesn't advance
This commit is contained in:
parent
d442cc80d7
commit
2a1ef5d9e6
|
@ -47,20 +47,6 @@ method stop*(clock: OnChainClock) {.async.} =
|
||||||
clock.started = false
|
clock.started = false
|
||||||
|
|
||||||
method now*(clock: OnChainClock): SecondsSince1970 =
|
method now*(clock: OnChainClock): SecondsSince1970 =
|
||||||
when codex_use_hardhat:
|
|
||||||
# hardhat's latest block.timestamp is usually 1s behind the block timestamp
|
|
||||||
# in the newHeads event. When testing, always return the latest block.
|
|
||||||
try:
|
|
||||||
if queriedBlock =? (waitFor clock.provider.getBlock(BlockTag.latest)):
|
|
||||||
trace "using last block timestamp for clock.now",
|
|
||||||
lastBlockTimestamp = queriedBlock.timestamp.truncate(int64),
|
|
||||||
cachedBlockTimestamp = clock.lastBlockTime.truncate(int64)
|
|
||||||
return queriedBlock.timestamp.truncate(int64)
|
|
||||||
except CatchableError as e:
|
|
||||||
warn "failed to get latest block timestamp", error = e.msg
|
|
||||||
return clock.lastBlockTime.truncate(int64)
|
|
||||||
|
|
||||||
else:
|
|
||||||
doAssert clock.started, "clock should be started before calling now()"
|
doAssert clock.started, "clock should be started before calling now()"
|
||||||
return toUnix(getTime() + clock.offset)
|
return toUnix(getTime() + clock.offset)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue