cic-internal-integration/apps/cic-eth/tests/unit/db/test_db_convert_transfer.py

30 lines
720 B
Python
Raw Normal View History

2021-03-20 22:40:06 +01:00
import os
import logging
import pytest
from cic_eth.db import TxConvertTransfer
from cic_eth.db.error import UnknownConvertError
logg = logging.getLogger()
def test_convert_transfer(
init_database,
default_chain_spec,
):
tx_hash_hex = '0x' + os.urandom(32).hex()
recipient = '0x' + os.urandom(20).hex()
txct = TxConvertTransfer(tx_hash_hex, recipient, str(default_chain_spec))
init_database.add(txct)
init_database.commit()
txct = TxConvertTransfer.get(tx_hash_hex)
assert txct.convert_tx_hash == tx_hash_hex
tx_hash_bogus_hex = '0x' + os.urandom(32).hex()
with pytest.raises(UnknownConvertError):
TxConvertTransfer.get(tx_hash_bogus_hex)