1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-02 03:48:58 +00:00

fixup! test(core/ui): fix bitcoin signtx for T3T1

This commit is contained in:
Martin Milata 2024-05-22 16:55:14 +02:00
parent d359f81af3
commit 62b40fbca8
12 changed files with 204 additions and 150 deletions

View File

@ -339,4 +339,4 @@ def swipe_till_the_end(debug: "DebugLink", br: messages.ButtonRequest) -> None:
def is_core(client: "Client") -> bool:
return client.model in (models.T2T1, models.T2B1, models.T3T1)
return client.model is not models.T1B1

View File

@ -23,6 +23,8 @@ from trezorlib.messages import SafetyCheckLevel
from trezorlib.tools import parse_path
from ... import bip32
from ...common import is_core
from ...input_flows import InputFlowConfirmAllWarnings
def getmultisig(chain, nr, xpubs):
@ -202,6 +204,10 @@ def test_multisig(client: Client):
xpubs.append(node.xpub)
for nr in range(1, 4):
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
assert (
btc.get_address(
client,
@ -254,7 +260,10 @@ def test_multisig_missing(client: Client, show_display):
)
for multisig in (multisig1, multisig2):
with pytest.raises(TrezorFailure):
with client, pytest.raises(TrezorFailure):
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
btc.get_address(
client,
"Bitcoin",
@ -275,6 +284,10 @@ def test_bch_multisig(client: Client):
xpubs.append(node.xpub)
for nr in range(1, 4):
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
assert (
btc.get_address(
client,
@ -342,6 +355,9 @@ def test_unknown_path(client: Client):
messages.Address,
]
)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
# try again with a warning
btc.get_address(client, "Bitcoin", UNKNOWN_PATH, show_display=True)

View File

@ -21,6 +21,9 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.exceptions import TrezorFailure
from trezorlib.tools import parse_path
from ...common import is_core
from ...input_flows import InputFlowConfirmAllWarnings
def test_show_segwit(client: Client):
assert (
@ -71,6 +74,10 @@ def test_show_segwit(client: Client):
@pytest.mark.altcoin
def test_show_segwit_altcoin(client: Client):
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
assert (
btc.get_address(
client,

View File

@ -20,7 +20,9 @@ from trezorlib import btc, messages, tools
from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.exceptions import Cancelled, TrezorFailure
from ...common import is_core
from ...input_flows import (
InputFlowConfirmAllWarnings,
InputFlowShowAddressQRCode,
InputFlowShowAddressQRCodeCancel,
InputFlowShowMultisigXPUBs,
@ -148,6 +150,10 @@ def test_show_multisig_3(client: Client):
)
for i in [1, 2, 3]:
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
assert (
btc.get_address(
client,
@ -289,6 +295,10 @@ def test_show_multisig_15(client: Client):
)
for i in range(15):
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
assert (
btc.get_address(
client,

View File

@ -22,6 +22,7 @@ from trezorlib.exceptions import TrezorFailure
from trezorlib.tools import parse_path
from ...common import MNEMONIC12, is_core
from ...input_flows import InputFlowConfirmAllWarnings
from ...tx_cache import TxCache
from .signtx import (
assert_tx_matches,
@ -304,6 +305,9 @@ def test_attack_change_input(client: Client):
# Transaction can be signed without the attack processor
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
btc.sign_tx(
client,
"Testnet",

View File

@ -22,6 +22,7 @@ from trezorlib.tools import H_, parse_path
from ... import bip32
from ...common import MNEMONIC12, is_core
from ...input_flows import InputFlowConfirmAllWarnings
from ...tx_cache import TxCache
from .signtx import request_finished, request_input, request_meta, request_output
@ -243,6 +244,9 @@ def test_external_internal(client: Client):
client.set_expected_responses(
_responses(client, INP1, INP2, change=2, foreign=True)
)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
_, serialized_tx = btc.sign_tx(
client,
"Bitcoin",
@ -276,6 +280,9 @@ def test_internal_external(client: Client):
client.set_expected_responses(
_responses(client, INP1, INP2, change=1, foreign=True)
)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
_, serialized_tx = btc.sign_tx(
client,
"Bitcoin",

View File

@ -20,6 +20,7 @@ from trezorlib import btc, messages
from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.tools import parse_path
from ...common import is_core
from ...input_flows import InputFlowConfirmAllWarnings
from .signtx import forge_prevtx
@ -115,6 +116,7 @@ def test_getaddress(
):
for script_type in script_types:
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
res = btc.get_address(
@ -135,6 +137,7 @@ def test_signmessage(
):
for script_type in script_types:
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
@ -173,6 +176,7 @@ def test_signtx(
)
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
_, serialized_tx = btc.sign_tx(
@ -199,6 +203,7 @@ def test_getaddress_multisig(
multisig = messages.MultisigRedeemScriptType(pubkeys=pubs, m=2)
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
address = btc.get_address(
@ -257,6 +262,7 @@ def test_signtx_multisig(client: Client, paths: list[str], address_index: list[i
)
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
sig, _ = btc.sign_tx(

View File

@ -24,6 +24,7 @@ from trezorlib.debuglink import message_filters
from trezorlib.exceptions import Cancelled
from trezorlib.tools import parse_path
from ...common import is_core
from ...input_flows import (
InputFlowConfirmAllWarnings,
InputFlowSignMessageInfo,
@ -413,6 +414,7 @@ def test_signmessage_path_warning(client: Client):
messages.MessageSignature,
]
)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
btc.sign_message(

View File

@ -21,6 +21,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.exceptions import TrezorFailure
from trezorlib.tools import H_, parse_path
from ...common import is_core
from ...input_flows import InputFlowConfirmAllWarnings
from .signtx import forge_prevtx, request_input
@ -80,6 +81,7 @@ def test_invalid_path_prompt(client: Client):
)
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
@ -105,6 +107,7 @@ def test_invalid_path_pass_forkid(client: Client):
)
with client:
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())

View File

@ -8,6 +8,7 @@ from trezorlib import btc, messages, models, tools
from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.exceptions import TrezorFailure
from ...common import is_core
from ...input_flows import InputFlowConfirmAllWarnings
from .signtx import forge_prevtx
@ -131,6 +132,7 @@ def test_invalid_prev_hash_attack(client: Client, prev_hash):
with client, pytest.raises(TrezorFailure) as e:
client.set_filter(messages.TxAck, attack_filter)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=PREV_TXES)
@ -167,6 +169,7 @@ def test_invalid_prev_hash_in_prevtx(client: Client, prev_hash):
inp0.prev_hash = tx_hash
with client, pytest.raises(TrezorFailure) as e:
if client.model is not models.T1B1:
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
btc.sign_tx(client, "Bitcoin", [inp0], [out1], prev_txes={tx_hash: prev_tx})

View File

@ -613,6 +613,7 @@ def test_send_multisig_3_change(client: Client):
with client:
client.set_expected_responses(expected_responses)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
signatures, _ = btc.sign_tx(
@ -627,6 +628,7 @@ def test_send_multisig_3_change(client: Client):
with client:
client.set_expected_responses(expected_responses)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
_, serialized_tx = btc.sign_tx(
@ -703,6 +705,7 @@ def test_send_multisig_4_change(client: Client):
with client:
client.set_expected_responses(expected_responses)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
signatures, _ = btc.sign_tx(
@ -717,6 +720,7 @@ def test_send_multisig_4_change(client: Client):
with client:
client.set_expected_responses(expected_responses)
if is_core(client):
IF = InputFlowConfirmAllWarnings(client)
client.set_input_flow(IF.get())
_, serialized_tx = btc.sign_tx(

View File

@ -2142,9 +2142,9 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
def input_flow_tt(self) -> BRGeneratorType:
br = yield
while True:
# wait for homescreen to go away
self.debug.wait_layout()
while True:
self.client.ui._default_input_flow(br)
br = yield
@ -2153,10 +2153,10 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
def input_flow_t3t1(self) -> BRGeneratorType:
br = yield
while True:
# wait for homescreen to go away
# probably won't be needed after https://github.com/trezor/trezor-firmware/pull/3686
self.debug.wait_layout()
while True:
# Paginating (going as further as possible) and pressing Yes
if br.pages is not None:
for _ in range(br.pages - 1):
@ -2164,18 +2164,10 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
layout = self.debug.read_layout()
text = layout.text_content().lower()
# hi priority warning
if (
("wrong derivation path" in text)
or ("to a multisig" in text)
or ("multiple accounts" in text)
):
if ("wrong derivation path" in text) or ("to a multisig" in text):
self.debug.click(buttons.CORNER_BUTTON, wait=True)
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[1])
elif "receive address" in layout.title().lower():
self.debug.swipe_up()
self.debug.synchronize_at("PromptScreen")
self.debug.press_yes()
elif "swipe up" in layout.footer().lower():
self.debug.swipe_up()
else: