mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-10 13:05:48 +00:00
29433bad9a
* Use http subscriptions instead of websocket for tests To work around this issue when subscriptions are inactive for more than 5 minutes: https://github.com/NomicFoundation/hardhat/issues/2053 Use 100 millisecond polling; default polling interval of 4 seconds is too close to the 5 second timeout for `check eventually`. * use .confirm(1) instead of confirm(0) confirm(0) doesn't wait at all, confirm(1) waits for the transaction to be mined * speed up partial payout integration test * update nim-ethers to version 0.10.0 includes fixes for http polling and .confirm() * fix timing of marketplace tests allow for a bit more time to withdraw funds * use .confirm(1) in marketplace tests to ensure that the transaction has been processed before continuing with the test * fix timing issue in validation unit test * fix proof integration test there were two logic errors in this test: - a slot is freed anyway at the end of the contract - when starting the request takes a long time, the first slot can already be freed because there were too many missing proofs * fix intermittent error in contract tests currentTime() doesn't always correctly reflect the time of the next transaction * reduce number of slots in integration test otherwise the windows runner in the CI won't be able to start the request before it expires * fix timing in purchasing test allow for a bit more time for a request to be submitted * fix timing of request submission in test windows ci is so slow, it can take up to 40 seconds just to submit a storage request to hardhat * increase proof period to 90 seconds * adjust timing of integration tests reason: with the increased period length of 90 seconds, it can take longer to wait for a stable challenge at the beginning of a period. * increase CI timeout to 2 hours * Fix slow builds on windows apparently it takes windows 2-3 seconds to resolve "localhost" to 127.0.0.1 for every json-rpc connection that we make 🤦
18 lines
753 B
Nim
18 lines
753 B
Nim
import pkg/ethers
|
|
import pkg/serde/json
|
|
|
|
proc blockTime*(provider: Provider, tag: BlockTag): Future[UInt256] {.async.} =
|
|
return (!await provider.getBlock(tag)).timestamp
|
|
|
|
proc currentTime*(provider: Provider): Future[UInt256] {.async.} =
|
|
return await provider.blockTime(BlockTag.pending)
|
|
|
|
proc advanceTime*(provider: JsonRpcProvider, seconds: UInt256) {.async.} =
|
|
discard await provider.send("evm_increaseTime", @[%("0x" & seconds.toHex)])
|
|
discard await provider.send("evm_mine")
|
|
|
|
proc advanceTimeTo*(provider: JsonRpcProvider, timestamp: UInt256) {.async.} =
|
|
if (await provider.currentTime()) != timestamp:
|
|
discard await provider.send("evm_setNextBlockTimestamp", @[%("0x" & timestamp.toHex)])
|
|
discard await provider.send("evm_mine")
|