chore(tests): add test for back from amount
What changed, and why it matters
This commit only adds a new automated test for the Trezor hardware wallet. It simulates a user pressing the 'back' button while confirming a Bitcoin transaction amount, then completing the transaction normally. There is no change to the actual wallet firmware or production code, so it does not introduce or fix any security issue on its own.
No security action required. Treat as routine test coverage addition.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a device test, test_one_one_fee_back_from_amount, and a supporting input-flow helper, InputFlowSignTxBackFromAmount. The test exercises the UI flow for Bitcoin sign_tx on model t3w1 where the user cancels/backtracks from the amount confirmation screen and then proceeds. It verifies the resulting serialized transaction matches an expected hex/hash. No firmware source files are modified.
Changed components
tests/device_tests/bitcoin/test_signtx.pytests/input_flows.pyInspect captured patch +76 / −0
diff --git a/tests/device_tests/bitcoin/test_signtx.py b/tests/device_tests/bitcoin/test_signtx.py
index a3136e13..2af23539 100644
--- a/tests/device_tests/bitcoin/test_signtx.py
+++ b/tests/device_tests/bitcoin/test_signtx.py
@@ -27,6 +27,7 @@ from ...common import is_core
from ...input_flows import (
InputFlowLockTimeBlockHeight,
InputFlowLockTimeDatetime,
+ InputFlowSignTxBackFromAmount,
InputFlowSignTxHighFee,
InputFlowSignTxInformation,
InputFlowSignTxInformationCancel,
@@ -156,6 +157,57 @@ def test_one_one_fee(session: Session):
)
+@pytest.mark.models("t3w1")
+def test_one_one_fee_back_from_amount(session: Session):
+ # input tx: 0dac366fd8a67b2a89fbb0d31086e7acded7a5bbf9ef9daa935bc873229ef5b5
+
+ inp1 = messages.TxInputType(
+ address_n=parse_path("m/44h/0h/5h/0/9"), # 1H2CRJBrDMhkvCGZMW7T4oQwYbL8eVuh7p
+ amount=63_988,
+ prev_hash=TXHASH_0dac36,
+ prev_index=0,
+ )
+
+ out1 = messages.TxOutputType(
+ address="13Hbso8zgV5Wmqn3uA7h3QVtmPzs47wcJ7",
+ amount=50_248,
+ script_type=messages.OutputScriptType.PAYTOADDRESS,
+ )
+
+ with session.client as client:
+ IF = InputFlowSignTxBackFromAmount(session.client)
+ client.set_input_flow(IF.get())
+
+ client.set_expected_responses(
+ [
+ request_input(0),
+ request_output(0),
+ messages.ButtonRequest(code=B.ConfirmOutput),
+ (is_core(session), messages.ButtonRequest(code=B.ConfirmOutput)),
+ messages.ButtonRequest(code=B.SignTx),
+ request_input(0),
+ request_meta(TXHASH_0dac36),
+ request_input(0, TXHASH_0dac36),
+ request_output(0, TXHASH_0dac36),
+ request_output(1, TXHASH_0dac36),
+ request_input(0),
+ request_output(0),
+ request_output(0),
+ request_finished(),
+ ]
+ )
+
+ _, serialized_tx = btc.sign_tx(
+ session, "Bitcoin", [inp1], [out1], prev_txes=TX_CACHE_MAINNET
+ )
+
+ assert_tx_matches(
+ serialized_tx,
+ hash_link="https://btc1.trezor.io/api/tx/b893aeed4b12227b6f5348d7f6cb84ba2cda2ba70a41933a25f363b9d2fc2cf9",
+ tx_hex="0100000001b5f59e2273c85b93aa9deff9bba5d7deace78610d3b0fb892a7ba6d86f36ac0d000000006b483045022100dd4dd136a70371bc9884c3c51fd52f4aed9ab8ee98f3ac7367bb19e6538096e702200c56be09c4359fc7eb494b4bdf8f2b72706b0575c4021373345b593e9661c7b6012103d7f3a07085bee09697cf03125d5c8760dfed65403dba787f1d1d8b1251af2cbeffffffff0148c40000000000001976a91419140511436e947448be994ab7fda9f98623e68e88ac00000000",
+ )
+
+
def test_testnet_one_two_fee(session: Session):
# input tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
diff --git a/tests/input_flows.py b/tests/input_flows.py
index 594173b5..1a6de54e 100644
--- a/tests/input_flows.py
+++ b/tests/input_flows.py
@@ -1201,6 +1201,30 @@ def sign_tx_go_to_info_caesar(
return "\n".join(screen_texts)
+class InputFlowSignTxBackFromAmount(InputFlowBase):
+ def __init__(self, client: Client):
+ super().__init__(client)
+
+ def input_flow_eckhart(self) -> BRGeneratorType:
+ yield # confirm address
+ self.debug.read_layout()
+ self.debug.click(self.debug.screen_buttons.ok())
+
+ yield # confirm amount
+ self.debug.read_layout()
+ self.debug.click(self.debug.screen_buttons.cancel())
+
+ self.debug.read_layout()
+ self.debug.click(self.debug.screen_buttons.ok())
+
+ self.debug.read_layout()
+ self.debug.click(self.debug.screen_buttons.ok())
+
+ yield
+ self.debug.read_layout()
+ self.debug.press_yes()
+
+
class InputFlowSignTxInformation(InputFlowBase):
def __init__(self, client: Client):
super().__init__(client)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.