Say I have a contract that has a method that implements a time expiration via a function parameter set by the user, how can I test that the expiration works as expected in brownie by delaying the transmission and consequently execution of the transaction?
contract SimpleContract {
function doSomething(uint256 exp) external {
require(now < exp, 'Transaction Expired');
}
}
from brownie import SimpleContract, accounts
import time
def main():
account = accounts[index]
simpleContract = SimpleContract.deploy({'from': account})
now = int(time.time())
validFor = 20 # valid for 20 seconds
simpleContract.doSomething(now + validFor, {'from': account})
Since brownie immediately submits the transaction by default it won't expire, so how do I get it to delay the submission and test that the transaction fails if its execution is attempted after the specified expiration time?