test(stellar): merge test_xdr with test_sign_tx
What changed, and why it matters
This commit is a test-code cleanup only. It merges two Stellar-related test functions and adds a consistency check inside the main signing test. No production firmware code, cryptographic handling, or device behavior was changed. There is no security issue.
No action required. This is a benign test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change removes the standalone test_xdr function and moves its XDR parsing/round-trip assertions into test_sign_tx under a stellar.HAVE_STELLAR_SDK guard. The assertions verify that parsing an XDR envelope with the Stellar SDK and converting it back to Trezor protobuf matches the original test parameters. This is purely a refactor of device tests in tests/device_tests/stellar/test_stellar.py.
Changed components
tests/device_tests/stellar/test_stellar.pyInspect captured patch +16 / −17
diff --git a/tests/device_tests/stellar/test_stellar.py b/tests/device_tests/stellar/test_stellar.py
index e4a7ec67..1c47250d 100644
--- a/tests/device_tests/stellar/test_stellar.py
+++ b/tests/device_tests/stellar/test_stellar.py
@@ -133,6 +133,22 @@ def parameters_to_proto(session, parameters):
def test_sign_tx(session: Session, parameters, result):
tx, operations = parameters_to_proto(session, parameters)
+ # check fixture consistency
+ if stellar.HAVE_STELLAR_SDK:
+ from stellar_sdk import TransactionEnvelope
+
+ envelope = TransactionEnvelope.from_xdr(
+ parameters["xdr"], parameters["network_passphrase"]
+ )
+ tx_parsed, operations_parsed = stellar.from_envelope(envelope)
+ tx_parsed.address_n = parse_path(parameters["address_n"])
+ # payment requests are not encoded in XDR
+ tx_parsed.payment_req = tx.payment_req
+
+ assert tx == tx_parsed
+ for op, op_parsed in zip(operations, operations_parsed):
+ assert op == op_parsed
+
if "signature" in result:
response = stellar.sign_tx(
session,
@@ -152,23 +168,6 @@ def test_sign_tx(session: Session, parameters, result):
assert False, "Invalid expected result"
-@parametrize_using_common_fixtures("stellar/sign_tx.json")
-@pytest.mark.skipif(not stellar.HAVE_STELLAR_SDK, reason="requires Stellar SDK")
-def test_xdr(session: Session, parameters, result):
- from stellar_sdk import TransactionEnvelope
-
- envelope = TransactionEnvelope.from_xdr(
- parameters["xdr"], parameters["network_passphrase"]
- )
- tx, operations = stellar.from_envelope(envelope)
- tx.address_n = parse_path(parameters["address_n"])
- tx_expected, operations_expected = parameters_to_proto(session, parameters)
- tx_expected.payment_req = None # payment requests are not encoded in XDR
- assert tx == tx_expected
- for expected, actual in zip(operations_expected, operations):
- assert expected == actual
-
-
@parametrize_using_common_fixtures("stellar/get_address.json")
def test_get_address(session: Session, parameters, result):
address_n = parse_path(parameters["path"])
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.