Open fubuloubu opened 5 years ago
Being able to manipulate time easily would be nice. For example, let's say you have a contract that allows you to withdraw funds in 7 days (e.g. Plasma). You should be able to do this:
contract.deposit(transact={})
# Can't withdraw a deposit within 7 days
with tx_fails:
contract.withdraw(transact={})
# Set time to 7 days, minus 1 block
tester.set_time(tester.now() + tester.utils.days(7) - 15)
with tx_fails:
contract.withdraw(transact={})
# Each block is 15 seconds
tester.mine()
# Now I can withdraw!
contract.withdraw(transact={})
This fixture would be the primary access point for test environment (
tester
) functionality, which might include:tester.now()
e.g.while contract.expiration() > tester.now(): ...
with tx_fails: ...
(and reverting that block)