1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-05-21 00:08:46 +00:00

tests: update tx_cache usages

This commit is contained in:
matejcik 2020-03-03 17:29:02 +01:00
parent d2dd78f979
commit b3569a53e6
17 changed files with 38 additions and 41 deletions

View File

@ -20,7 +20,7 @@ from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, btc_hash, parse_path from trezorlib.tools import H_, CallException, btc_hash, parse_path
from ..common import MNEMONIC12 from ..common import MNEMONIC12
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TXHASH_157041 = bytes.fromhex( TXHASH_157041 = bytes.fromhex(
"1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6" "1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6"
@ -78,7 +78,7 @@ def check_sign_tx(
__tracebackhide__ = True __tracebackhide__ = True
expected_responses = [] expected_responses = []
txes = tx_cache(coin_name) txes = TxCache(coin_name)
t = proto.RequestType t = proto.RequestType
b = proto.ButtonRequestType b = proto.ButtonRequestType
@ -611,7 +611,7 @@ class TestMsgSigntx:
"Bitcoin", "Bitcoin",
[inp1, inp2], [inp1, inp2],
[out1, out2], [out1, out2],
prev_txes=tx_cache("Bitcoin"), prev_txes=TxCache("Bitcoin"),
) )
assert exc.value.args[0] in ( assert exc.value.args[0] in (
proto.FailureType.ProcessError, proto.FailureType.ProcessError,
@ -663,7 +663,7 @@ class TestMsgSigntx:
with pytest.raises(CallException) as exc: with pytest.raises(CallException) as exc:
btc.sign_tx( btc.sign_tx(
client, "Testnet", [inp1], [out1, out2], prev_txes=tx_cache("Testnet") client, "Testnet", [inp1], [out1, out2], prev_txes=TxCache("Testnet")
) )
assert exc.value.args[0] in ( assert exc.value.args[0] in (
@ -768,7 +768,7 @@ class TestMsgSigntx:
"Testnet", "Testnet",
[inp1], [inp1],
[out1, out2], [out1, out2],
prev_txes=tx_cache("Testnet"), prev_txes=TxCache("Testnet"),
) )
assert exc.value.args[0] == proto.FailureType.ProcessError assert exc.value.args[0] == proto.FailureType.ProcessError

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, parse_path from trezorlib.tools import H_, CallException, parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Bcash") TX_API = TxCache("Bcash")
@pytest.mark.altcoin @pytest.mark.altcoin

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, parse_path from trezorlib.tools import H_, CallException, parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Bgold") TX_API = TxCache("Bgold")
# All data taken from T1 # All data taken from T1

View File

@ -19,7 +19,7 @@ import pytest
from trezorlib import btc, messages from trezorlib import btc, messages
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TXHASH_3bf506 = bytes.fromhex( TXHASH_3bf506 = bytes.fromhex(
"3bf506c81ce84eda891679ddc797d162c17c60b15d6c0ac23be5e31369e7235f" "3bf506c81ce84eda891679ddc797d162c17c60b15d6c0ac23be5e31369e7235f"
@ -61,7 +61,7 @@ def test_timestamp_included(client):
[inp1, inp2], [inp1, inp2],
[out1], [out1],
details=details, details=details,
prev_txes=tx_cache("Capricoin"), prev_txes=TxCache("Capricoin"),
) )
# Accepted by network https://insight.capricoin.org/tx/1bf227e6e24fe1f8ac98849fe06a2c5b77762e906fcf7e82787675f7f3a10bb8 # Accepted by network https://insight.capricoin.org/tx/1bf227e6e24fe1f8ac98849fe06a2c5b77762e906fcf7e82787675f7f3a10bb8

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Dash") TX_API = TxCache("Dash")
@pytest.mark.altcoin @pytest.mark.altcoin

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Decred Testnet") TX_API = TxCache("Decred Testnet")
TXHASH_e16248 = bytes.fromhex( TXHASH_e16248 = bytes.fromhex(

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Groestlcoin") TX_API = TxCache("Groestlcoin")
@pytest.mark.altcoin @pytest.mark.altcoin

View File

@ -19,10 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
# KMD has no usable backends, use cached TX only TX_API = TxCache("Komodo")
TX_API = tx_cache("Komodo", allow_fetch=False)
TXHASH_2807c = bytes.fromhex( TXHASH_2807c = bytes.fromhex(
"2807c5b126ec8e2b078cab0f12e4c8b4ce1d7724905f8ebef8dca26b0c8e0f1d" "2807c5b126ec8e2b078cab0f12e4c8b4ce1d7724905f8ebef8dca26b0c8e0f1d"

View File

@ -19,7 +19,7 @@ import pytest
from trezorlib import btc, messages from trezorlib import btc, messages
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TXHASH_41b29a = bytes.fromhex( TXHASH_41b29a = bytes.fromhex(
"41b29ad615d8eea40a4654a052d18bb10cd08f203c351f4d241f88b031357d3d" "41b29ad615d8eea40a4654a052d18bb10cd08f203c351f4d241f88b031357d3d"
@ -50,7 +50,7 @@ def test_timestamp_included(client):
[inp1], [inp1],
[out1], [out1],
details=details, details=details,
prev_txes=tx_cache("Peercoin", allow_fetch=False), prev_txes=TxCache("Peercoin"),
) )
# Accepted by network https://explorer.peercoin.net/api/getrawtransaction?txid=f7e3624c143b6a170cc44f9337d0fa8ea8564a211de9c077c6889d8c78f80909&decrypt=1 # Accepted by network https://explorer.peercoin.net/api/getrawtransaction?txid=f7e3624c143b6a170cc44f9337d0fa8ea8564a211de9c077c6889d8c78f80909&decrypt=1

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, parse_path from trezorlib.tools import H_, CallException, parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Testnet") TX_API = TxCache("Testnet")
class TestMsgSigntxSegwit: class TestMsgSigntxSegwit:

View File

@ -20,9 +20,9 @@ from trezorlib import btc, messages as proto
from trezorlib.ckd_public import deserialize from trezorlib.ckd_public import deserialize
from trezorlib.tools import H_, parse_path from trezorlib.tools import H_, parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Testnet") TX_API = TxCache("Testnet")
class TestMsgSigntxSegwitNative: class TestMsgSigntxSegwitNative:

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Zcash Testnet") TX_API = TxCache("Zcash Testnet")
TXHASH_aaf51e = bytes.fromhex( TXHASH_aaf51e = bytes.fromhex(
"aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc" "aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc"

View File

@ -20,9 +20,9 @@ from trezorlib import btc, ckd_public as bip32, messages as proto
from trezorlib.tools import CallException, parse_path from trezorlib.tools import CallException, parse_path
from ..common import MNEMONIC12 from ..common import MNEMONIC12
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Bitcoin") TX_API = TxCache("Bitcoin")
TXHASH_c6091a = bytes.fromhex( TXHASH_c6091a = bytes.fromhex(
"c6091adf4c0c23982a35899a6e58ae11e703eacd7954f588ed4b9cdefc4dba52" "c6091adf4c0c23982a35899a6e58ae11e703eacd7954f588ed4b9cdefc4dba52"

View File

@ -20,9 +20,9 @@ from trezorlib import btc, ckd_public as bip32, messages as proto
from trezorlib.tools import H_, parse_path from trezorlib.tools import H_, parse_path
from ..common import MNEMONIC12 from ..common import MNEMONIC12
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Testnet") TX_API = TxCache("Testnet")
class TestMultisigChange: class TestMultisigChange:

View File

@ -19,9 +19,9 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import CallException, parse_path from trezorlib.tools import CallException, parse_path
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TX_API = tx_cache("Bitcoin") TX_API = TxCache("Bitcoin")
TXHASH_d5f65e = bytes.fromhex( TXHASH_d5f65e = bytes.fromhex(
"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"

View File

@ -20,7 +20,7 @@ from trezorlib import btc, device, messages as proto, misc
from trezorlib.exceptions import TrezorFailure from trezorlib.exceptions import TrezorFailure
from ..common import MNEMONIC12 from ..common import MNEMONIC12
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TXHASH_d5f65e = bytes.fromhex( TXHASH_d5f65e = bytes.fromhex(
"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"
@ -246,9 +246,7 @@ class TestProtectionLevels:
proto.TxRequest(request_type=proto.RequestType.TXFINISHED), proto.TxRequest(request_type=proto.RequestType.TXFINISHED),
] ]
) )
btc.sign_tx( btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TxCache("Bitcoin"))
client, "Bitcoin", [inp1], [out1], prev_txes=tx_cache("Bitcoin")
)
# def test_firmware_erase(self): # def test_firmware_erase(self):
# pass # pass

View File

@ -19,7 +19,7 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from ..common import MNEMONIC12 from ..common import MNEMONIC12
from ..tx_cache import tx_cache from ..tx_cache import TxCache
TXHASH_d5f65e = bytes.fromhex( TXHASH_d5f65e = bytes.fromhex(
"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882" "d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"
@ -46,7 +46,7 @@ class TestZerosig:
) )
_, serialized_tx = btc.sign_tx( _, serialized_tx = btc.sign_tx(
client, "Bitcoin", [inp1], [out1], prev_txes=tx_cache("Bitcoin") client, "Bitcoin", [inp1], [out1], prev_txes=TxCache("Bitcoin")
) )
siglen = serialized_tx[44] siglen = serialized_tx[44]
@ -70,7 +70,7 @@ class TestZerosig:
) )
_, serialized_tx = btc.sign_tx( _, serialized_tx = btc.sign_tx(
client, "Bitcoin", [inp1], [out1], prev_txes=tx_cache("Bitcoin") client, "Bitcoin", [inp1], [out1], prev_txes=TxCache("Bitcoin")
) )
siglen = serialized_tx[44] siglen = serialized_tx[44]