test_nonce.py (620B)
1 # standard imports 2 import os 3 import unittest 4 5 # local imports 6 from chainlib.eth.address import to_checksum_address 7 from chainlib.eth.nonce import OverrideNonceOracle 8 from hexathon import add_0x 9 10 # test imports 11 from tests.base import TestBase 12 13 14 class TestNonce(TestBase): 15 16 def test_nonce(self): 17 addr_bytes = os.urandom(20) 18 addr = add_0x(to_checksum_address(addr_bytes.hex())) 19 n = OverrideNonceOracle(addr, 42) 20 self.assertEqual(n.get_nonce(), 42) 21 self.assertEqual(n.next_nonce(), 42) 22 self.assertEqual(n.next_nonce(), 43) 23 24 25 if __name__ == '__main__': 26 unittest.main()