test_basic.py (1582B)
1 # standard imports 2 import os 3 import logging 4 import unittest 5 6 # external imports 7 from hexathon import ( 8 strip_0x, 9 add_0x, 10 ) 11 12 # local imports 13 from chainqueue.db.models.otx import Otx 14 from chainqueue.db.models.tx import TxCache 15 16 # test imports 17 from tests.chainqueue_base import TestBase 18 19 logging.basicConfig(level=logging.DEBUG) 20 logg = logging.getLogger() 21 22 class TestBasic(TestBase): 23 24 def test_hello(self): 25 pass 26 27 28 def test_otx(self): 29 tx_hash = add_0x(os.urandom(32).hex()) 30 address = add_0x(os.urandom(20).hex()) 31 tx = add_0x(os.urandom(128).hex()) 32 nonce = 42 33 otx = Otx(nonce, tx_hash, tx) 34 self.session.add(otx) 35 36 37 def test_tx(self): 38 tx_hash = add_0x(os.urandom(32).hex()) 39 tx = add_0x(os.urandom(128).hex()) 40 nonce = 42 41 otx = Otx(nonce, tx_hash, tx) 42 otx.block = 1024 43 self.session.add(otx) 44 45 alice = add_0x(os.urandom(20).hex()) 46 bob = add_0x(os.urandom(20).hex()) 47 foo_token = add_0x(os.urandom(20).hex()) 48 bar_token = add_0x(os.urandom(20).hex()) 49 from_value = 13 50 to_value = 666 51 52 block_number = 1024 53 tx_index = 1337 54 55 txc = TxCache( 56 tx_hash, 57 alice, 58 bob, 59 foo_token, 60 bar_token, 61 from_value, 62 to_value, 63 block_number=block_number, 64 tx_index=tx_index, 65 session=self.session, 66 ) 67 self.session.add(txc) 68 69 if __name__ == '__main__': 70 unittest.main()