2021-02-01 18:12:51 +01:00
|
|
|
import os
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2021-04-02 23:26:13 +02:00
|
|
|
from cic_eth.db.models.convert import TxConvertTransfer
|
2021-02-01 18:12:51 +01:00
|
|
|
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)
|