You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ganache adds challenges when testing time-dependent behaviors, because the clock is always advancing. This can be mitigated by disabling auto-mine with miner_stop and then controlling the mining process manually with evm_mine. evm_mine accepts a timestamp as an optional argument, which we can use to force the blocktimes.
Under the hood this could require some significant changes, so it probably belongs in the context of Brownie v2. I think happening in a middleware makes sense, where any call to eth_sendTransaction spawns and waits for thread that calls evm_mine.
Another benefit I see here is the issue with calls-as-transactions sometimes causing issues when the called method relies on a timestamp. For these calls we can always force the mined block to have a timestamp == that of the last transaction, and then we can trust the return value.
I'm not sure how to best expose something like this to the user. Two ideas come to mind:
chain.set_blocktime(seconds=None) where if seconds is None the clock advances normally, otherwise each block is exactly seconds apart.
As a context manager... with chain.blocktimes(seconds): ... to temporarily override the default behavior.
In implementing this, there will also need to be consideration for how chain.sleep and chain.time work.
The text was updated successfully, but these errors were encountered:
Ganache adds challenges when testing time-dependent behaviors, because the clock is always advancing. This can be mitigated by disabling auto-mine with
miner_stop
and then controlling the mining process manually withevm_mine
.evm_mine
accepts a timestamp as an optional argument, which we can use to force the blocktimes.Under the hood this could require some significant changes, so it probably belongs in the context of Brownie v2. I think happening in a middleware makes sense, where any call to
eth_sendTransaction
spawns and waits for thread that callsevm_mine
.Another benefit I see here is the issue with calls-as-transactions sometimes causing issues when the called method relies on a timestamp. For these calls we can always force the mined block to have a timestamp
==
that of the last transaction, and then we can trust the return value.I'm not sure how to best expose something like this to the user. Two ideas come to mind:
chain.set_blocktime(seconds=None)
where ifseconds
isNone
the clock advances normally, otherwise each block is exactlyseconds
apart.with chain.blocktimes(seconds): ...
to temporarily override the default behavior.In implementing this, there will also need to be consideration for how
chain.sleep
andchain.time
work.The text was updated successfully, but these errors were encountered: