1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 06:18:07 +00:00

chore(tests): account for T2B1 sending extra ConfirmOutput BR in device tests

[no changelog]
This commit is contained in:
grdddj 2023-09-14 17:55:26 +02:00 committed by Jiří Musil
parent d88da792f1
commit cae3e81337
18 changed files with 192 additions and 190 deletions

View File

@ -453,7 +453,7 @@ def test_sign_tx_spend(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
messages.ButtonRequest(code=B.Other),
@ -462,7 +462,7 @@ def test_sign_tx_spend(client: Client):
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
@ -528,7 +528,7 @@ def test_sign_tx_migration(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
messages.ButtonRequest(code=B.Other),
@ -537,7 +537,7 @@ def test_sign_tx_migration(client: Client):
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_2cc3c1),

View File

@ -72,14 +72,14 @@ def test_send_bch_change(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_bc37c2),
@ -125,14 +125,14 @@ def test_send_bch_nochange(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_502e85),
@ -184,14 +184,14 @@ def test_send_bch_oldaddr(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_502e85),
@ -255,7 +255,7 @@ def test_attack_change_input(client: Client):
return msg
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[
@ -263,7 +263,7 @@ def test_attack_change_input(client: Client):
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_bd32ff),
@ -331,13 +331,13 @@ def test_send_bch_multisig_wrongchange(client: Client):
amount=23_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_062fbd),
@ -400,13 +400,13 @@ def test_send_bch_multisig_change(client: Client):
amount=24_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -445,7 +445,7 @@ def test_send_bch_multisig_change(client: Client):
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -502,14 +502,14 @@ def test_send_bch_external_presigned(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_502e85),

View File

@ -71,14 +71,14 @@ def test_send_bitcoin_gold_change(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_6f0398),
@ -125,14 +125,14 @@ def test_send_bitcoin_gold_nochange(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_6f0398),
@ -195,7 +195,7 @@ def test_attack_change_input(client: Client):
return msg
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[
@ -203,7 +203,7 @@ def test_attack_change_input(client: Client):
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_6f0398),
@ -257,13 +257,13 @@ def test_send_btg_multisig_change(client: Client):
amount=1_252_382_934 - 24_000 - 1_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -302,7 +302,7 @@ def test_send_btg_multisig_change(client: Client):
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -351,16 +351,16 @@ def test_send_p2sh(client: Client):
amount=1_252_382_934 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_db7239),
@ -405,13 +405,13 @@ def test_send_p2sh_witness_change(client: Client):
amount=1_252_382_934 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -466,13 +466,13 @@ def test_send_multisig_1(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_7f1f6b),
@ -495,7 +495,7 @@ def test_send_multisig_1(client: Client):
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_7f1f6b),
@ -584,14 +584,14 @@ def test_send_btg_external_presigned(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_6f0398),

View File

@ -57,13 +57,13 @@ def test_send_dash(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(inp1.prev_hash),
@ -105,14 +105,14 @@ def test_send_dash_dip2_input(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(inp1.prev_hash),

View File

@ -72,13 +72,13 @@ def test_send_decred(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.FeeOverThreshold),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -194,14 +194,14 @@ def test_spend_from_stake_generation_and_revocation_decred(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_f8e2f2),
@ -276,7 +276,7 @@ def test_send_decred_change(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
@ -284,7 +284,7 @@ def test_send_decred_change(client: Client):
request_input(2),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -383,7 +383,7 @@ def test_decred_multisig_change(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
@ -391,7 +391,7 @@ def test_decred_multisig_change(client: Client):
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_9ac7d2),

View File

@ -61,13 +61,13 @@ def test_one_one_fee_sapling(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -126,16 +126,16 @@ def test_one_one_rewards_claim(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
messages.ButtonRequest(code=B.SignTx),
request_input(0),

View File

@ -83,12 +83,12 @@ def test_2_of_3(client: Client, chunkify: bool):
)
# Expected responses are the same for both two signings
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_6b07c1),

View File

@ -145,7 +145,7 @@ def _responses(
change: int = 0,
foreign: bool = False,
):
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
resp = [
request_input(0),
request_input(1),
@ -154,7 +154,7 @@ def _responses(
if change != 1:
resp.append(messages.ButtonRequest(code=B.ConfirmOutput))
if tt:
if is_core:
resp.append(messages.ButtonRequest(code=B.ConfirmOutput))
elif foreign:
resp.append(messages.ButtonRequest(code=B.UnknownDerivationPath))
@ -163,7 +163,7 @@ def _responses(
if change != 2:
resp.append(messages.ButtonRequest(code=B.ConfirmOutput))
if tt:
if is_core:
resp.append(messages.ButtonRequest(code=B.ConfirmOutput))
elif foreign:
resp.append(messages.ButtonRequest(code=B.UnknownDerivationPath))

View File

@ -63,13 +63,13 @@ def test_opreturn(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),

View File

@ -127,13 +127,13 @@ def test_one_one_fee(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_0dac36),
@ -181,13 +181,13 @@ def test_testnet_one_two_fee(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -232,13 +232,13 @@ def test_testnet_fee_high_warning(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.FeeOverThreshold),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -285,14 +285,14 @@ def test_one_two_fee(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_50f6f1),
@ -348,16 +348,16 @@ def test_one_three_fee(client: Client, chunkify: bool):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(2),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -420,7 +420,7 @@ def test_two_two(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
@ -428,7 +428,7 @@ def test_two_two(client: Client):
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_ac4ca0),
@ -565,13 +565,13 @@ def test_lots_of_change(client: Client):
request_change_outputs = [request_output(i + 1) for i in range(cnt)]
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
]
+ request_change_outputs
+ [
@ -617,13 +617,13 @@ def test_fee_high_warning(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.FeeOverThreshold),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -706,13 +706,13 @@ def test_not_enough_funds(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.Failure(code=messages.FailureType.NotEnoughFunds),
]
)
@ -737,13 +737,13 @@ def test_p2sh(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_58d56a),
@ -825,7 +825,7 @@ def test_attack_change_outputs(client: Client):
# Test if the transaction can be signed normally
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
@ -833,7 +833,7 @@ def test_attack_change_outputs(client: Client):
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_ac4ca0),
@ -993,14 +993,14 @@ def test_attack_change_input_address(client: Client):
# Now run the attack, must trigger the exception
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -1045,13 +1045,13 @@ def test_spend_coinbase(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(FAKE_TXHASH_005f6f),
@ -1104,13 +1104,13 @@ def test_two_changes(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
request_output(2),
messages.ButtonRequest(code=B.SignTx),
@ -1164,13 +1164,13 @@ def test_change_on_main_chain_allowed(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -1429,13 +1429,13 @@ def test_lock_time(client: Client, lock_time: int, sequence: int):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
messages.ButtonRequest(code=B.SignTx),
request_input(0),

View File

@ -216,20 +216,20 @@ def test_p2wpkh_in_p2sh_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(2),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
@ -268,20 +268,20 @@ def test_p2wpkh_in_p2sh_presigned(client: Client):
# Test corrupted script hash in scriptsig.
inp1.script_sig[10] ^= 1
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(2),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
@ -401,14 +401,14 @@ def test_p2wsh_external_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_ec16dc),
@ -447,14 +447,14 @@ def test_p2wsh_external_presigned(client: Client):
# Test corrupted signature in witness.
inp2.witness[10] ^= 1
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_ec16dc),
@ -513,14 +513,14 @@ def test_p2tr_external_presigned(client: Client):
script_type=messages.OutputScriptType.PAYTOTAPROOT,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(1),
@ -546,14 +546,14 @@ def test_p2tr_external_presigned(client: Client):
# Test corrupted signature in witness.
inp2.witness[10] ^= 1
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(1),
@ -617,17 +617,17 @@ def test_p2wpkh_with_proof(client: Client):
with client:
is_t1 = client.features.model == "1"
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e5b7e2),
@ -711,14 +711,14 @@ def test_p2tr_with_proof(client: Client):
with client:
is_t1 = client.features.model == "1"
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),

View File

@ -66,16 +66,16 @@ def test_send_p2sh(client: Client, chunkify: bool):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
@ -125,13 +125,13 @@ def test_send_p2sh_change(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -181,13 +181,13 @@ def test_testnet_segwit_big_amount(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(prev_hash),
@ -239,12 +239,12 @@ def test_send_multisig_1(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_338e2d),
@ -307,17 +307,17 @@ def test_attack_change_input_address(client: Client):
# Test if the transaction can be signed normally.
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
# The user is required to confirm transfer to another account.
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
@ -387,14 +387,16 @@ def test_attack_mixed_inputs(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
(tt, messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput)),
(
is_core,
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
),
(is_core, messages.ButtonRequest(code=messages.ButtonRequestType.SignTx)),
messages.ButtonRequest(code=messages.ButtonRequestType.FeeOverThreshold),
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),

View File

@ -81,16 +81,16 @@ def test_send_p2sh(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
@ -137,13 +137,13 @@ def test_send_p2sh_change(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -191,16 +191,16 @@ def test_send_native(client: Client):
amount=100_000 - 40_000 - 10_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_b36780),
@ -279,13 +279,13 @@ def test_send_native_change(client: Client):
amount=100_000 - 40_000 - 10_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -347,7 +347,7 @@ def test_send_both(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
@ -355,13 +355,13 @@ def test_send_both(client: Client):
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(2),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.SignTx)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -433,12 +433,12 @@ def test_send_multisig_1(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_b9abfa),
@ -511,12 +511,12 @@ def test_send_multisig_2(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_b9abfa),
@ -596,13 +596,13 @@ def test_send_multisig_3_change(client: Client):
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
)
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.UnknownDerivationPath),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_b9abfa),
@ -683,13 +683,13 @@ def test_send_multisig_4_change(client: Client):
script_type=messages.OutputScriptType.PAYTOWITNESS,
)
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.UnknownDerivationPath),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_b9abfa),
@ -785,18 +785,18 @@ def test_multisig_mismatch_inputs_single(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
# Ensure that the multisig output is not identified as a change output.
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_1c022d),

View File

@ -79,13 +79,13 @@ def test_send_p2tr(client: Client, chunkify: bool):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
@ -134,14 +134,14 @@ def test_send_two_with_change(client: Client):
amount=6_800 + 13_000 - 200 - 15_000,
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -224,7 +224,7 @@ def test_send_mixed(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
@ -236,18 +236,18 @@ def test_send_mixed(client: Client):
# approve outputs
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(2),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(3),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(4),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.SignTx)),
messages.ButtonRequest(code=B.SignTx),
# verify inputs
@ -358,7 +358,7 @@ def test_attack_script_type(client: Client):
return msg
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "R")
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
@ -367,7 +367,7 @@ def test_attack_script_type(client: Client):
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.SignTx)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),

View File

@ -106,13 +106,13 @@ def test_one_one_fee_sapling(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e38206),
@ -260,14 +260,14 @@ def test_external_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e38206),

View File

@ -33,7 +33,7 @@ pytestmark = [
# assertion data from T1
@pytest.mark.parametrize("chunkify", (True, False))
def test_nem_signtx_simple(client: Client, chunkify: bool):
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
with client:
client.set_expected_responses(
[
@ -42,7 +42,7 @@ def test_nem_signtx_simple(client: Client, chunkify: bool):
# Unencrypted message
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
(
tt,
is_core,
messages.ButtonRequest(
code=messages.ButtonRequestType.ConfirmOutput
),
@ -85,7 +85,7 @@ def test_nem_signtx_simple(client: Client, chunkify: bool):
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_encrypted_payload(client: Client):
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
# Confirm transfer and network fee
@ -93,7 +93,7 @@ def test_nem_signtx_encrypted_payload(client: Client):
# Ask for encryption
messages.ButtonRequest(code=messages.ButtonRequestType.ConfirmOutput),
(
tt,
is_core,
messages.ButtonRequest(
code=messages.ButtonRequestType.ConfirmOutput
),

View File

@ -362,7 +362,7 @@ def test_signtx(client: Client):
_assert_protection(client)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.use_pin_sequence([PIN4])
client.set_expected_responses(
[
@ -371,7 +371,7 @@ def test_signtx(client: Client):
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_50f6f1),

View File

@ -95,13 +95,13 @@ def test_spend_v4_input(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
@ -144,13 +144,13 @@ def test_send_to_multisig(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
@ -192,13 +192,13 @@ def test_spend_v5_input(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
@ -246,13 +246,13 @@ def test_one_two(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -305,13 +305,13 @@ def test_unified_address(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
@ -370,14 +370,14 @@ def test_external_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(1),
request_input(0),
@ -483,12 +483,12 @@ def test_spend_multisig(client: Client):
)
# Expected responses are the same for both two signings
tt = client.features.model == "T"
is_core = client.features.model in ("T", "R")
expected_responses = [
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
(is_core, messages.ButtonRequest(code=B.ConfirmOutput)),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),