mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 23:08:14 +00:00
tests: Test transaction with multiple change-outputs.
This commit is contained in:
parent
24bf352577
commit
c7bc945d95
@ -493,6 +493,90 @@ class TestMsgSigntx:
|
||||
== "aa0cfe57938b71db47a3992b25d4bee39f258a5de513c907727b982478648a7d"
|
||||
)
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_lots_of_change(self, client):
|
||||
# Tests if device implements prompting for multiple change addresses correctly
|
||||
|
||||
# tx: c63e24ed820c5851b60c54613fbc4bcb37df6cd49b4c96143e99580a472f79fb
|
||||
# index 1: 0.0010 BTC
|
||||
# tx: 39a29e954977662ab3879c66fb251ef753e0912223a83d1dcb009111d28265e5
|
||||
# index 1: 0.0254 BTC
|
||||
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=parse_path("44h/0h/1h/0/0"),
|
||||
# amount=100000,
|
||||
prev_hash=TXHASH_c63e24,
|
||||
prev_index=1,
|
||||
)
|
||||
|
||||
inp2 = proto.TxInputType(
|
||||
address_n=parse_path("44h/0h/1h/0/1"),
|
||||
# amount=2540000,
|
||||
prev_hash=TXHASH_39a29e,
|
||||
prev_index=1,
|
||||
)
|
||||
|
||||
outputs = [
|
||||
proto.TxOutputType(
|
||||
address="1NwN6UduuVkJi6sw3gSiKZaCY5rHgVXC2h",
|
||||
amount=500000,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
]
|
||||
|
||||
cnt = 20
|
||||
for i in range(cnt):
|
||||
out = proto.TxOutputType(
|
||||
address_n=parse_path(f"44h/0h/1h/1/{i}"),
|
||||
amount=(100000 + 2540000 - 500000 - 39000) // cnt,
|
||||
script_type=proto.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
outputs.append(out)
|
||||
|
||||
request_change_outputs = [request_output(i + 1) for i in range(cnt)]
|
||||
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_meta(TXHASH_c63e24),
|
||||
request_input(0, TXHASH_c63e24),
|
||||
request_input(1, TXHASH_c63e24),
|
||||
request_output(0, TXHASH_c63e24),
|
||||
request_output(1, TXHASH_c63e24),
|
||||
request_input(1),
|
||||
request_meta(TXHASH_39a29e),
|
||||
request_input(0, TXHASH_39a29e),
|
||||
request_output(0, TXHASH_39a29e),
|
||||
request_output(1, TXHASH_39a29e),
|
||||
request_output(0),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
]
|
||||
+ request_change_outputs
|
||||
+ [
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
]
|
||||
+ request_change_outputs
|
||||
+ [request_input(0), request_input(1), request_output(0)]
|
||||
+ request_change_outputs
|
||||
+ [request_output(0)]
|
||||
+ request_change_outputs
|
||||
+ [request_finished()]
|
||||
)
|
||||
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client, "Bitcoin", [inp1, inp2], outputs, prev_txes=TX_CACHE_MAINNET
|
||||
)
|
||||
|
||||
assert (
|
||||
tx_hash(serialized_tx).hex()
|
||||
== "fae68e4a3a4b0540eb200e2218a6d8465eac469788ccb236e0d5822d105ddde9"
|
||||
)
|
||||
|
||||
def test_fee_too_high(self, client):
|
||||
# tx: 1570416eb4302cf52979afd5e6909e37d8fdd874301f7cc87e547e509cb1caa6
|
||||
# input 0: 1.0 BTC
|
||||
@ -908,7 +992,6 @@ class TestMsgSigntx:
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
request_output(1),
|
||||
request_output(2),
|
||||
proto.ButtonRequest(code=B.ConfirmOutput),
|
||||
proto.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_output(0),
|
||||
|
@ -232,6 +232,7 @@
|
||||
"test_msg_signtx.py-test_attack_modify_change_address": "cfd5c83510c044c456622298138e222aee135a6df607bb6e5603228535f0762f",
|
||||
"test_msg_signtx.py-test_change_on_main_chain_allowed": "cfd5c83510c044c456622298138e222aee135a6df607bb6e5603228535f0762f",
|
||||
"test_msg_signtx.py-test_fee_too_high": "8cb3b31dce25fa36cd5c8322c71611dc7bc9d2290579ffd88dd67d21058bde04",
|
||||
"test_msg_signtx.py-test_lots_of_change": "9e143458b399d187b6a3060fc95b998822f5a7ed67d6915610fd02c0ccab791e",
|
||||
"test_msg_signtx.py-test_not_enough_funds": "dbaa027aa1f4b08b138a5965245593dab2a662b0f4d88dd28b82a64f88f5d7fe",
|
||||
"test_msg_signtx.py-test_one_one_fee": "f6b6662fa1384f20640522a169575f8ca26185fca8ca3bc2a3a5ccd1fa9d2f68",
|
||||
"test_msg_signtx.py-test_one_three_fee": "192d74e668c0f4345608da9f9af45f0cc2cb8ea3e532dca826c1da1fdb28c7f9",
|
||||
@ -241,7 +242,7 @@
|
||||
"test_msg_signtx.py-test_testnet_big_amount": "5b84d787542e5fa1436db4e768fbac15f92662a6a0deb580012def5a788adf12",
|
||||
"test_msg_signtx.py-test_testnet_fee_too_high": "97f1650cd03286b305db65b6aa764ba9029b53f6cb0dd334d3b866c1297136d2",
|
||||
"test_msg_signtx.py-test_testnet_one_two_fee": "cfd5c83510c044c456622298138e222aee135a6df607bb6e5603228535f0762f",
|
||||
"test_msg_signtx.py-test_two_changes": "77ac9a437f9ba258577d17528eca1c0c60791fbc273d9cf046ce193bbd9e5e56",
|
||||
"test_msg_signtx.py-test_two_changes": "832d4b168551c37c9e09cf2ce16fd062d6599bcd0473305f70c5175bd874a920",
|
||||
"test_msg_signtx.py-test_two_two": "57707ecbcb77f670148c6076724b3da2e880d27ecf86e29135af4a5aeef6fdbc",
|
||||
"test_msg_signtx_bcash.py-test_attack_change_input": "a03ee0471deeb54d51b73c0fde08795ab0ba8c37daec2d43f5637e705420b435",
|
||||
"test_msg_signtx_bcash.py-test_send_bch_change": "a03ee0471deeb54d51b73c0fde08795ab0ba8c37daec2d43f5637e705420b435",
|
||||
|
Loading…
Reference in New Issue
Block a user