evm-booking

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 5fe77549ba5a6854964a60279315b46ed78504a6
parent a4369724f4b3c3f10742699b1ccc6d9565389c73
Author: lash <dev@holbrook.no>
Date:   Fri,  2 Jun 2023 17:22:12 +0100

Add expire test

Diffstat:
Mpython/evm_booking/time.py | 1-
Mpython/evm_booking/unittest/base.py | 1-
Mpython/tests/test_base.py | 21+++++++++++++++++++++
3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/python/evm_booking/time.py b/python/evm_booking/time.py @@ -57,7 +57,6 @@ class TimeBooking(Booking): end_seconds = self.capacity_units * self.unit end_date = ref_date + datetime.timedelta(seconds=end_seconds) target_date = start_date + duration - logg.debug("ref {} {}".format(end_seconds, ref_date)) if target_date > end_date: raise ValueError('duration results in {} which is beyond end date {}'.format(target_date, end_date)) diff --git a/python/evm_booking/unittest/base.py b/python/evm_booking/unittest/base.py @@ -19,7 +19,6 @@ logg = logging.getLogger(__name__) DEFAULT_RESOLUTION = 366*24 -#class TestBooking(EthTesterCase): #TestGiftableToken): class TestBooking(TestGiftableToken): expire = 0 diff --git a/python/tests/test_base.py b/python/tests/test_base.py @@ -179,5 +179,26 @@ class TestBookingBase(TestBooking): self.assertEqual("0000000000fc7f000000000000000000e00f0000", field) + def test_expire(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.rpc) + c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.approve(self.token_address, self.accounts[0], self.address, self.initial_supply) + self.rpc.do(o) + + c = Booking(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + self.backend.time_travel(int(self.booking_expire.timestamp() + 1)) + (tx_hash_hex, o) = c.share(self.address, self.accounts[0], 42, 13) + self.rpc.do(o) + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + c = ERC20(self.chain_spec) + o = c.balance_of(self.token_address, self.accounts[0], sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = c.parse_balance_of(r) + self.assertEqual(balance, self.initial_supply) + + if __name__ == '__main__': unittest.main()