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:
parent
d359f81af3
commit
62b40fbca8
@ -339,4 +339,4 @@ def swipe_till_the_end(debug: "DebugLink", br: messages.ButtonRequest) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def is_core(client: "Client") -> bool:
|
def is_core(client: "Client") -> bool:
|
||||||
return client.model in (models.T2T1, models.T2B1, models.T3T1)
|
return client.model is not models.T1B1
|
||||||
|
@ -23,6 +23,8 @@ from trezorlib.messages import SafetyCheckLevel
|
|||||||
from trezorlib.tools import parse_path
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
from ... import bip32
|
from ... import bip32
|
||||||
|
from ...common import is_core
|
||||||
|
from ...input_flows import InputFlowConfirmAllWarnings
|
||||||
|
|
||||||
|
|
||||||
def getmultisig(chain, nr, xpubs):
|
def getmultisig(chain, nr, xpubs):
|
||||||
@ -202,26 +204,30 @@ def test_multisig(client: Client):
|
|||||||
xpubs.append(node.xpub)
|
xpubs.append(node.xpub)
|
||||||
|
|
||||||
for nr in range(1, 4):
|
for nr in range(1, 4):
|
||||||
assert (
|
with client:
|
||||||
btc.get_address(
|
if is_core(client):
|
||||||
client,
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
"Bitcoin",
|
client.set_input_flow(IF.get())
|
||||||
parse_path(f"m/44h/0h/{nr}h/0/0"),
|
assert (
|
||||||
show_display=(nr == 1),
|
btc.get_address(
|
||||||
multisig=getmultisig(0, 0, xpubs=xpubs),
|
client,
|
||||||
|
"Bitcoin",
|
||||||
|
parse_path(f"m/44h/0h/{nr}h/0/0"),
|
||||||
|
show_display=(nr == 1),
|
||||||
|
multisig=getmultisig(0, 0, xpubs=xpubs),
|
||||||
|
)
|
||||||
|
== "3Pdz86KtfJBuHLcSv4DysJo4aQfanTqCzG"
|
||||||
)
|
)
|
||||||
== "3Pdz86KtfJBuHLcSv4DysJo4aQfanTqCzG"
|
assert (
|
||||||
)
|
btc.get_address(
|
||||||
assert (
|
client,
|
||||||
btc.get_address(
|
"Bitcoin",
|
||||||
client,
|
parse_path(f"m/44h/0h/{nr}h/1/0"),
|
||||||
"Bitcoin",
|
show_display=(nr == 1),
|
||||||
parse_path(f"m/44h/0h/{nr}h/1/0"),
|
multisig=getmultisig(1, 0, xpubs=xpubs),
|
||||||
show_display=(nr == 1),
|
)
|
||||||
multisig=getmultisig(1, 0, xpubs=xpubs),
|
== "36gP3KVx1ooStZ9quZDXbAF3GCr42b2zzd"
|
||||||
)
|
)
|
||||||
== "36gP3KVx1ooStZ9quZDXbAF3GCr42b2zzd"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.multisig
|
@pytest.mark.multisig
|
||||||
@ -254,7 +260,10 @@ def test_multisig_missing(client: Client, show_display):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for multisig in (multisig1, multisig2):
|
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(
|
btc.get_address(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
@ -275,26 +284,30 @@ def test_bch_multisig(client: Client):
|
|||||||
xpubs.append(node.xpub)
|
xpubs.append(node.xpub)
|
||||||
|
|
||||||
for nr in range(1, 4):
|
for nr in range(1, 4):
|
||||||
assert (
|
with client:
|
||||||
btc.get_address(
|
if is_core(client):
|
||||||
client,
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
"Bcash",
|
client.set_input_flow(IF.get())
|
||||||
parse_path(f"m/44h/145h/{nr}h/0/0"),
|
assert (
|
||||||
show_display=(nr == 1),
|
btc.get_address(
|
||||||
multisig=getmultisig(0, 0, xpubs=xpubs),
|
client,
|
||||||
|
"Bcash",
|
||||||
|
parse_path(f"m/44h/145h/{nr}h/0/0"),
|
||||||
|
show_display=(nr == 1),
|
||||||
|
multisig=getmultisig(0, 0, xpubs=xpubs),
|
||||||
|
)
|
||||||
|
== "bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw"
|
||||||
)
|
)
|
||||||
== "bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw"
|
assert (
|
||||||
)
|
btc.get_address(
|
||||||
assert (
|
client,
|
||||||
btc.get_address(
|
"Bcash",
|
||||||
client,
|
parse_path(f"m/44h/145h/{nr}h/1/0"),
|
||||||
"Bcash",
|
show_display=(nr == 1),
|
||||||
parse_path(f"m/44h/145h/{nr}h/1/0"),
|
multisig=getmultisig(1, 0, xpubs=xpubs),
|
||||||
show_display=(nr == 1),
|
)
|
||||||
multisig=getmultisig(1, 0, xpubs=xpubs),
|
== "bitcoincash:pp6kcpkhua7789g2vyj0qfkcux3yvje7euhyhltn0a"
|
||||||
)
|
)
|
||||||
== "bitcoincash:pp6kcpkhua7789g2vyj0qfkcux3yvje7euhyhltn0a"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_public_ckd(client: Client):
|
def test_public_ckd(client: Client):
|
||||||
@ -342,6 +355,9 @@ def test_unknown_path(client: Client):
|
|||||||
messages.Address,
|
messages.Address,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
if is_core(client):
|
||||||
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
# try again with a warning
|
# try again with a warning
|
||||||
btc.get_address(client, "Bitcoin", UNKNOWN_PATH, show_display=True)
|
btc.get_address(client, "Bitcoin", UNKNOWN_PATH, show_display=True)
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client
|
|||||||
from trezorlib.exceptions import TrezorFailure
|
from trezorlib.exceptions import TrezorFailure
|
||||||
from trezorlib.tools import parse_path
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
|
from ...common import is_core
|
||||||
|
from ...input_flows import InputFlowConfirmAllWarnings
|
||||||
|
|
||||||
|
|
||||||
def test_show_segwit(client: Client):
|
def test_show_segwit(client: Client):
|
||||||
assert (
|
assert (
|
||||||
@ -71,61 +74,65 @@ def test_show_segwit(client: Client):
|
|||||||
|
|
||||||
@pytest.mark.altcoin
|
@pytest.mark.altcoin
|
||||||
def test_show_segwit_altcoin(client: Client):
|
def test_show_segwit_altcoin(client: Client):
|
||||||
assert (
|
with client:
|
||||||
btc.get_address(
|
if is_core(client):
|
||||||
client,
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
"Groestlcoin Testnet",
|
client.set_input_flow(IF.get())
|
||||||
parse_path("m/49h/1h/0h/1/0"),
|
assert (
|
||||||
True,
|
btc.get_address(
|
||||||
None,
|
client,
|
||||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
"Groestlcoin Testnet",
|
||||||
|
parse_path("m/49h/1h/0h/1/0"),
|
||||||
|
True,
|
||||||
|
None,
|
||||||
|
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||||
|
)
|
||||||
|
== "2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7"
|
||||||
)
|
)
|
||||||
== "2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7"
|
assert (
|
||||||
)
|
btc.get_address(
|
||||||
assert (
|
client,
|
||||||
btc.get_address(
|
"Groestlcoin Testnet",
|
||||||
client,
|
parse_path("m/49h/1h/0h/0/0"),
|
||||||
"Groestlcoin Testnet",
|
True,
|
||||||
parse_path("m/49h/1h/0h/0/0"),
|
None,
|
||||||
True,
|
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||||
None,
|
)
|
||||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
== "2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e"
|
||||||
)
|
)
|
||||||
== "2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e"
|
assert (
|
||||||
)
|
btc.get_address(
|
||||||
assert (
|
client,
|
||||||
btc.get_address(
|
"Groestlcoin Testnet",
|
||||||
client,
|
parse_path("m/44h/1h/0h/0/0"),
|
||||||
"Groestlcoin Testnet",
|
True,
|
||||||
parse_path("m/44h/1h/0h/0/0"),
|
None,
|
||||||
True,
|
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||||
None,
|
)
|
||||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
== "2N6UeBoqYEEnybg4cReFYDammpsyDzLXvCT"
|
||||||
)
|
)
|
||||||
== "2N6UeBoqYEEnybg4cReFYDammpsyDzLXvCT"
|
assert (
|
||||||
)
|
btc.get_address(
|
||||||
assert (
|
client,
|
||||||
btc.get_address(
|
"Groestlcoin Testnet",
|
||||||
client,
|
parse_path("m/44h/1h/0h/0/0"),
|
||||||
"Groestlcoin Testnet",
|
True,
|
||||||
parse_path("m/44h/1h/0h/0/0"),
|
None,
|
||||||
True,
|
script_type=messages.InputScriptType.SPENDADDRESS,
|
||||||
None,
|
)
|
||||||
script_type=messages.InputScriptType.SPENDADDRESS,
|
== "mvbu1Gdy8SUjTenqerxUaZyYjmvedc787y"
|
||||||
)
|
)
|
||||||
== "mvbu1Gdy8SUjTenqerxUaZyYjmvedc787y"
|
assert (
|
||||||
)
|
btc.get_address(
|
||||||
assert (
|
client,
|
||||||
btc.get_address(
|
"Elements",
|
||||||
client,
|
parse_path("m/49h/1h/0h/0/0"),
|
||||||
"Elements",
|
True,
|
||||||
parse_path("m/49h/1h/0h/0/0"),
|
None,
|
||||||
True,
|
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
||||||
None,
|
)
|
||||||
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
== "XNW67ZQA9K3AuXPBWvJH4zN2y5QBDTwy2Z"
|
||||||
)
|
)
|
||||||
== "XNW67ZQA9K3AuXPBWvJH4zN2y5QBDTwy2Z"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.multisig
|
@pytest.mark.multisig
|
||||||
|
@ -20,7 +20,9 @@ from trezorlib import btc, messages, tools
|
|||||||
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
||||||
from trezorlib.exceptions import Cancelled, TrezorFailure
|
from trezorlib.exceptions import Cancelled, TrezorFailure
|
||||||
|
|
||||||
|
from ...common import is_core
|
||||||
from ...input_flows import (
|
from ...input_flows import (
|
||||||
|
InputFlowConfirmAllWarnings,
|
||||||
InputFlowShowAddressQRCode,
|
InputFlowShowAddressQRCode,
|
||||||
InputFlowShowAddressQRCodeCancel,
|
InputFlowShowAddressQRCodeCancel,
|
||||||
InputFlowShowMultisigXPUBs,
|
InputFlowShowMultisigXPUBs,
|
||||||
@ -148,17 +150,21 @@ def test_show_multisig_3(client: Client):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for i in [1, 2, 3]:
|
for i in [1, 2, 3]:
|
||||||
assert (
|
with client:
|
||||||
btc.get_address(
|
if is_core(client):
|
||||||
client,
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
"Bitcoin",
|
client.set_input_flow(IF.get())
|
||||||
tools.parse_path(f"m/45h/0/0/{i}"),
|
assert (
|
||||||
show_display=True,
|
btc.get_address(
|
||||||
multisig=multisig,
|
client,
|
||||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
"Bitcoin",
|
||||||
|
tools.parse_path(f"m/45h/0/0/{i}"),
|
||||||
|
show_display=True,
|
||||||
|
multisig=multisig,
|
||||||
|
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||||
|
)
|
||||||
|
== "35Q3tgZZfr9GhVpaqz7fbDK8WXV1V1KxfD"
|
||||||
)
|
)
|
||||||
== "35Q3tgZZfr9GhVpaqz7fbDK8WXV1V1KxfD"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
VECTORS_MULTISIG = ( # script_type, bip48_type, address, xpubs, ignore_xpub_magic
|
VECTORS_MULTISIG = ( # script_type, bip48_type, address, xpubs, ignore_xpub_magic
|
||||||
@ -289,14 +295,18 @@ def test_show_multisig_15(client: Client):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for i in range(15):
|
for i in range(15):
|
||||||
assert (
|
with client:
|
||||||
btc.get_address(
|
if is_core(client):
|
||||||
client,
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
"Bitcoin",
|
client.set_input_flow(IF.get())
|
||||||
tools.parse_path(f"m/45h/0/0/{i}"),
|
assert (
|
||||||
show_display=True,
|
btc.get_address(
|
||||||
multisig=multisig,
|
client,
|
||||||
script_type=messages.InputScriptType.SPENDMULTISIG,
|
"Bitcoin",
|
||||||
|
tools.parse_path(f"m/45h/0/0/{i}"),
|
||||||
|
show_display=True,
|
||||||
|
multisig=multisig,
|
||||||
|
script_type=messages.InputScriptType.SPENDMULTISIG,
|
||||||
|
)
|
||||||
|
== "3GG78bp1hA3mu9xv1vZLXiENmeabmi7WKQ"
|
||||||
)
|
)
|
||||||
== "3GG78bp1hA3mu9xv1vZLXiENmeabmi7WKQ"
|
|
||||||
)
|
|
||||||
|
@ -22,6 +22,7 @@ from trezorlib.exceptions import TrezorFailure
|
|||||||
from trezorlib.tools import parse_path
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
from ...common import MNEMONIC12, is_core
|
from ...common import MNEMONIC12, is_core
|
||||||
|
from ...input_flows import InputFlowConfirmAllWarnings
|
||||||
from ...tx_cache import TxCache
|
from ...tx_cache import TxCache
|
||||||
from .signtx import (
|
from .signtx import (
|
||||||
assert_tx_matches,
|
assert_tx_matches,
|
||||||
@ -304,6 +305,9 @@ def test_attack_change_input(client: Client):
|
|||||||
|
|
||||||
# Transaction can be signed without the attack processor
|
# Transaction can be signed without the attack processor
|
||||||
with client:
|
with client:
|
||||||
|
if is_core(client):
|
||||||
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
btc.sign_tx(
|
btc.sign_tx(
|
||||||
client,
|
client,
|
||||||
"Testnet",
|
"Testnet",
|
||||||
|
@ -22,6 +22,7 @@ from trezorlib.tools import H_, parse_path
|
|||||||
|
|
||||||
from ... import bip32
|
from ... import bip32
|
||||||
from ...common import MNEMONIC12, is_core
|
from ...common import MNEMONIC12, is_core
|
||||||
|
from ...input_flows import InputFlowConfirmAllWarnings
|
||||||
from ...tx_cache import TxCache
|
from ...tx_cache import TxCache
|
||||||
from .signtx import request_finished, request_input, request_meta, request_output
|
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(
|
client.set_expected_responses(
|
||||||
_responses(client, INP1, INP2, change=2, foreign=True)
|
_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(
|
_, serialized_tx = btc.sign_tx(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
@ -276,6 +280,9 @@ def test_internal_external(client: Client):
|
|||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
_responses(client, INP1, INP2, change=1, foreign=True)
|
_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(
|
_, serialized_tx = btc.sign_tx(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
|
@ -20,6 +20,7 @@ from trezorlib import btc, messages
|
|||||||
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
||||||
from trezorlib.tools import parse_path
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
|
from ...common import is_core
|
||||||
from ...input_flows import InputFlowConfirmAllWarnings
|
from ...input_flows import InputFlowConfirmAllWarnings
|
||||||
from .signtx import forge_prevtx
|
from .signtx import forge_prevtx
|
||||||
|
|
||||||
@ -115,8 +116,9 @@ def test_getaddress(
|
|||||||
):
|
):
|
||||||
for script_type in script_types:
|
for script_type in script_types:
|
||||||
with client:
|
with client:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
res = btc.get_address(
|
res = btc.get_address(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
@ -135,8 +137,9 @@ def test_signmessage(
|
|||||||
):
|
):
|
||||||
for script_type in script_types:
|
for script_type in script_types:
|
||||||
with client:
|
with client:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
|
|
||||||
sig = btc.sign_message(
|
sig = btc.sign_message(
|
||||||
client,
|
client,
|
||||||
@ -173,8 +176,9 @@ def test_signtx(
|
|||||||
)
|
)
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
_, serialized_tx = btc.sign_tx(
|
_, serialized_tx = btc.sign_tx(
|
||||||
client, "Bitcoin", [inp1], [out1], prev_txes={prevhash: prevtx}
|
client, "Bitcoin", [inp1], [out1], prev_txes={prevhash: prevtx}
|
||||||
)
|
)
|
||||||
@ -199,8 +203,9 @@ def test_getaddress_multisig(
|
|||||||
multisig = messages.MultisigRedeemScriptType(pubkeys=pubs, m=2)
|
multisig = messages.MultisigRedeemScriptType(pubkeys=pubs, m=2)
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
address = btc.get_address(
|
address = btc.get_address(
|
||||||
client,
|
client,
|
||||||
"Bitcoin",
|
"Bitcoin",
|
||||||
@ -257,8 +262,9 @@ def test_signtx_multisig(client: Client, paths: list[str], address_index: list[i
|
|||||||
)
|
)
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
sig, _ = btc.sign_tx(
|
sig, _ = btc.sign_tx(
|
||||||
client, "Bitcoin", [inp1], [out1], prev_txes={prevhash: prevtx}
|
client, "Bitcoin", [inp1], [out1], prev_txes={prevhash: prevtx}
|
||||||
)
|
)
|
||||||
|
@ -24,6 +24,7 @@ from trezorlib.debuglink import message_filters
|
|||||||
from trezorlib.exceptions import Cancelled
|
from trezorlib.exceptions import Cancelled
|
||||||
from trezorlib.tools import parse_path
|
from trezorlib.tools import parse_path
|
||||||
|
|
||||||
|
from ...common import is_core
|
||||||
from ...input_flows import (
|
from ...input_flows import (
|
||||||
InputFlowConfirmAllWarnings,
|
InputFlowConfirmAllWarnings,
|
||||||
InputFlowSignMessageInfo,
|
InputFlowSignMessageInfo,
|
||||||
@ -413,8 +414,9 @@ def test_signmessage_path_warning(client: Client):
|
|||||||
messages.MessageSignature,
|
messages.MessageSignature,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
btc.sign_message(
|
btc.sign_message(
|
||||||
client,
|
client,
|
||||||
coin_name="Bitcoin",
|
coin_name="Bitcoin",
|
||||||
|
@ -21,6 +21,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client
|
|||||||
from trezorlib.exceptions import TrezorFailure
|
from trezorlib.exceptions import TrezorFailure
|
||||||
from trezorlib.tools import H_, parse_path
|
from trezorlib.tools import H_, parse_path
|
||||||
|
|
||||||
|
from ...common import is_core
|
||||||
from ...input_flows import InputFlowConfirmAllWarnings
|
from ...input_flows import InputFlowConfirmAllWarnings
|
||||||
from .signtx import forge_prevtx, request_input
|
from .signtx import forge_prevtx, request_input
|
||||||
|
|
||||||
@ -80,8 +81,9 @@ def test_invalid_path_prompt(client: Client):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
|
|
||||||
btc.sign_tx(client, "Litecoin", [inp1], [out1], prev_txes=PREV_TXES)
|
btc.sign_tx(client, "Litecoin", [inp1], [out1], prev_txes=PREV_TXES)
|
||||||
|
|
||||||
@ -105,8 +107,9 @@ def test_invalid_path_pass_forkid(client: Client):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
|
|
||||||
btc.sign_tx(client, "Bcash", [inp1], [out1], prev_txes=PREV_TXES)
|
btc.sign_tx(client, "Bcash", [inp1], [out1], prev_txes=PREV_TXES)
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ from trezorlib import btc, messages, models, tools
|
|||||||
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
||||||
from trezorlib.exceptions import TrezorFailure
|
from trezorlib.exceptions import TrezorFailure
|
||||||
|
|
||||||
|
from ...common import is_core
|
||||||
from ...input_flows import InputFlowConfirmAllWarnings
|
from ...input_flows import InputFlowConfirmAllWarnings
|
||||||
from .signtx import forge_prevtx
|
from .signtx import forge_prevtx
|
||||||
|
|
||||||
@ -131,8 +132,9 @@ def test_invalid_prev_hash_attack(client: Client, prev_hash):
|
|||||||
|
|
||||||
with client, pytest.raises(TrezorFailure) as e:
|
with client, pytest.raises(TrezorFailure) as e:
|
||||||
client.set_filter(messages.TxAck, attack_filter)
|
client.set_filter(messages.TxAck, attack_filter)
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=PREV_TXES)
|
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=PREV_TXES)
|
||||||
|
|
||||||
# check that injection was performed
|
# check that injection was performed
|
||||||
@ -167,7 +169,8 @@ def test_invalid_prev_hash_in_prevtx(client: Client, prev_hash):
|
|||||||
inp0.prev_hash = tx_hash
|
inp0.prev_hash = tx_hash
|
||||||
|
|
||||||
with client, pytest.raises(TrezorFailure) as e:
|
with client, pytest.raises(TrezorFailure) as e:
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if client.model is not models.T1B1:
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
btc.sign_tx(client, "Bitcoin", [inp0], [out1], prev_txes={tx_hash: prev_tx})
|
btc.sign_tx(client, "Bitcoin", [inp0], [out1], prev_txes={tx_hash: prev_tx})
|
||||||
_check_error_message(prev_hash, client.model, e.value.message)
|
_check_error_message(prev_hash, client.model, e.value.message)
|
||||||
|
@ -613,8 +613,9 @@ def test_send_multisig_3_change(client: Client):
|
|||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(expected_responses)
|
client.set_expected_responses(expected_responses)
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
signatures, _ = btc.sign_tx(
|
signatures, _ = btc.sign_tx(
|
||||||
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
||||||
)
|
)
|
||||||
@ -627,8 +628,9 @@ def test_send_multisig_3_change(client: Client):
|
|||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(expected_responses)
|
client.set_expected_responses(expected_responses)
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
_, serialized_tx = btc.sign_tx(
|
_, serialized_tx = btc.sign_tx(
|
||||||
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
||||||
)
|
)
|
||||||
@ -703,8 +705,9 @@ def test_send_multisig_4_change(client: Client):
|
|||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(expected_responses)
|
client.set_expected_responses(expected_responses)
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
signatures, _ = btc.sign_tx(
|
signatures, _ = btc.sign_tx(
|
||||||
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
||||||
)
|
)
|
||||||
@ -717,8 +720,9 @@ def test_send_multisig_4_change(client: Client):
|
|||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(expected_responses)
|
client.set_expected_responses(expected_responses)
|
||||||
IF = InputFlowConfirmAllWarnings(client)
|
if is_core(client):
|
||||||
client.set_input_flow(IF.get())
|
IF = InputFlowConfirmAllWarnings(client)
|
||||||
|
client.set_input_flow(IF.get())
|
||||||
_, serialized_tx = btc.sign_tx(
|
_, serialized_tx = btc.sign_tx(
|
||||||
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
||||||
)
|
)
|
||||||
|
@ -2142,9 +2142,9 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
|
|||||||
|
|
||||||
def input_flow_tt(self) -> BRGeneratorType:
|
def input_flow_tt(self) -> BRGeneratorType:
|
||||||
br = yield
|
br = yield
|
||||||
# wait for homescreen to go away
|
|
||||||
self.debug.wait_layout()
|
|
||||||
while True:
|
while True:
|
||||||
|
# wait for homescreen to go away
|
||||||
|
self.debug.wait_layout()
|
||||||
self.client.ui._default_input_flow(br)
|
self.client.ui._default_input_flow(br)
|
||||||
br = yield
|
br = yield
|
||||||
|
|
||||||
@ -2153,10 +2153,10 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
|
|||||||
|
|
||||||
def input_flow_t3t1(self) -> BRGeneratorType:
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
||||||
br = yield
|
br = yield
|
||||||
# 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:
|
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()
|
||||||
# Paginating (going as further as possible) and pressing Yes
|
# Paginating (going as further as possible) and pressing Yes
|
||||||
if br.pages is not None:
|
if br.pages is not None:
|
||||||
for _ in range(br.pages - 1):
|
for _ in range(br.pages - 1):
|
||||||
@ -2164,18 +2164,10 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
|
|||||||
layout = self.debug.read_layout()
|
layout = self.debug.read_layout()
|
||||||
text = layout.text_content().lower()
|
text = layout.text_content().lower()
|
||||||
# hi priority warning
|
# hi priority warning
|
||||||
if (
|
if ("wrong derivation path" in text) or ("to a multisig" in text):
|
||||||
("wrong derivation path" in text)
|
|
||||||
or ("to a multisig" in text)
|
|
||||||
or ("multiple accounts" in text)
|
|
||||||
):
|
|
||||||
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
self.debug.click(buttons.CORNER_BUTTON, wait=True)
|
||||||
self.debug.synchronize_at("VerticalMenu")
|
self.debug.synchronize_at("VerticalMenu")
|
||||||
self.debug.click(buttons.VERTICAL_MENU[1])
|
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():
|
elif "swipe up" in layout.footer().lower():
|
||||||
self.debug.swipe_up()
|
self.debug.swipe_up()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user