2021-04-02 10:31:50 +02:00
|
|
|
# standard imports
|
2021-04-02 10:41:38 +02:00
|
|
|
import os
|
2021-04-02 10:31:50 +02:00
|
|
|
import logging
|
|
|
|
import unittest
|
|
|
|
|
2021-04-02 10:41:38 +02:00
|
|
|
# external imports
|
|
|
|
from hexathon import (
|
|
|
|
strip_0x,
|
|
|
|
add_0x,
|
|
|
|
)
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from chainqueue.db.models.otx import Otx
|
2021-04-02 10:48:54 +02:00
|
|
|
from chainqueue.db.models.tx import TxCache
|
2021-04-02 10:41:38 +02:00
|
|
|
|
2021-04-02 10:31:50 +02:00
|
|
|
# test imports
|
|
|
|
from tests.base import TestBase
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
|
|
|
class TestBasic(TestBase):
|
|
|
|
|
|
|
|
def test_hello(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2021-04-02 10:41:38 +02:00
|
|
|
def test_otx(self):
|
|
|
|
tx_hash = add_0x(os.urandom(32).hex())
|
|
|
|
address = add_0x(os.urandom(20).hex())
|
|
|
|
tx = add_0x(os.urandom(128).hex())
|
|
|
|
nonce = 42
|
|
|
|
otx = Otx(nonce, tx_hash, tx)
|
|
|
|
self.session.add(otx)
|
|
|
|
|
|
|
|
|
2021-04-02 10:48:54 +02:00
|
|
|
def test_tx(self):
|
|
|
|
tx_hash = add_0x(os.urandom(32).hex())
|
|
|
|
tx = add_0x(os.urandom(128).hex())
|
|
|
|
nonce = 42
|
|
|
|
otx = Otx(nonce, tx_hash, tx)
|
|
|
|
self.session.add(otx)
|
|
|
|
|
|
|
|
alice = add_0x(os.urandom(20).hex())
|
|
|
|
bob = add_0x(os.urandom(20).hex())
|
|
|
|
foo_token = add_0x(os.urandom(20).hex())
|
|
|
|
bar_token = add_0x(os.urandom(20).hex())
|
|
|
|
from_value = 13
|
|
|
|
to_value = 666
|
|
|
|
|
|
|
|
block_number = 1024
|
|
|
|
tx_index = 1337
|
|
|
|
|
|
|
|
txc = TxCache(
|
|
|
|
tx_hash,
|
|
|
|
alice,
|
|
|
|
bob,
|
|
|
|
foo_token,
|
|
|
|
bar_token,
|
|
|
|
from_value,
|
|
|
|
to_value,
|
|
|
|
block_number=block_number,
|
|
|
|
tx_index=tx_index,
|
|
|
|
session=self.session,
|
|
|
|
)
|
|
|
|
self.session.add(txc)
|
|
|
|
|
2021-04-02 10:31:50 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|