test(core): drop `test_descriptor_all_formatters` unit test
What changed, and why it matters
This commit simply removes a single unit test from the Trezor firmware test suite. The test covered Ethereum 'clear signing' formatting logic, and the commit message says it is being dropped because it should be covered by device tests instead. No production code was changed, so this does not introduce or fix a security vulnerability by itself.
No security action required. If reviewing for quality assurance, verify that equivalent device tests exist for the removed coverage, as the commit message claims.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff deletes 141 lines from core/tests/test_apps.ethereum.clear_signing.py, removing the test_descriptor_all_formatters unit test. The deleted test exercised descriptor-based parsing/formatting of Ethereum calldata (scalars, token amounts, arrays, path styles) using test-only fixtures. No runtime firmware code is modified. The change is tagged [no changelog] and the stated rationale is test-suite consolidation into device tests.
Changed components
core/tests/test_apps.ethereum.clear_signing.pyInspect captured patch +0 / −141
diff --git a/core/tests/test_apps.ethereum.clear_signing.py b/core/tests/test_apps.ethereum.clear_signing.py
index d8a31046..352e3d84 100644
--- a/core/tests/test_apps.ethereum.clear_signing.py
+++ b/core/tests/test_apps.ethereum.clear_signing.py
@@ -660,147 +660,6 @@ class TestEthereumClearSigning(unittest.TestCase):
with self.assertRaises(InvalidFormatDefinition):
await_result(fmt.format(1, None, None, None))
- # --- Test descriptor: every formatter / parser / path style ---
-
- def test_descriptor_all_formatters(self):
- from apps.ethereum.clear_signing_definitions import (
- TREZOR_TEST_ARRAYS_DESCRIPTOR,
- TREZOR_TEST_CONST_TOKEN,
- TREZOR_TEST_PATHS_DESCRIPTOR,
- TREZOR_TEST_SCALARS_DESCRIPTOR,
- TREZOR_TEST_TOKEN_DESCRIPTOR,
- )
-
- class _Defs:
- network = make_eth_network(chain_id=1, symbol="ETH")
-
- def get_token(self, address: bytes) -> EthereumTokenInfo:
- return make_eth_token(symbol="TST", decimals=6, address=address)
-
- def render(
- descriptor: DisplayFormat, calldata_hex: str
- ) -> dict[str, tuple[str, EthereumTokenInfo | None, bytes | None]]:
- calldata = unhexlify(calldata_hex)
- # [4:] strips the 4-byte selector; parse_calldata expects it stripped
- _, fields = await_result(
- descriptor.parse_calldata(memoryview(calldata)[4:], None, _Defs())
- )
- return {
- label: (formatted, token_, addr_)
- for (label, formatted, _), token_, addr_ in fields
- }
-
- # --- scalars: recipient 0x11.., 1 ETH, raw 42, unit 123.45, date,
- # bytes32 0x0001..1f, bool true, uint160 4660, "hello", 0xdeadbeef
- rendered = render(
- TREZOR_TEST_SCALARS_DESCRIPTOR,
- "7e577e01"
- "0000000000000000000000001111111111111111111111111111111111111111"
- "0000000000000000000000000000000000000000000000000de0b6b3a7640000"
- "000000000000000000000000000000000000000000000000000000000000002a"
- "0000000000000000000000000000000000000000000000000000000000003039"
- "000000000000000000000000000000000000000000000000000000006052fe70"
- "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
- "0000000000000000000000000000000000000000000000000000000000000001"
- "0000000000000000000000000000000000000000000000000000000000001234"
- "0000000000000000000000000000000000000000000000000000000000000140"
- "0000000000000000000000000000000000000000000000000000000000000180"
- "0000000000000000000000000000000000000000000000000000000000000005"
- "68656c6c6f000000000000000000000000000000000000000000000000000000"
- "0000000000000000000000000000000000000000000000000000000000000004"
- "deadbeef00000000000000000000000000000000000000000000000000000000",
- )
- self.assertEqual(rendered["Recipient"][0].lower(), "0x" + "11" * 20)
- self.assertEqual(rendered["Native Amount"][0], "1 ETH")
- self.assertEqual(rendered["Raw Integer"][0], "42")
- self.assertEqual(rendered["Unit Value"][0], "123.45 UNIT")
- self.assertEqual(rendered["Date"][0], "2021-03-18 07:17:04")
- self.assertEqual(
- rendered["Raw Bytes32"][0],
- "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
- )
- self.assertEqual(rendered["Raw Bool"][0], "True")
- self.assertEqual(rendered["Raw Uint160"][0], "4660")
- self.assertEqual(rendered["Raw String"][0], "hello")
- self.assertEqual(rendered["Raw Bytes"][0], "deadbeef")
-
- # --- token-amount resolution: token 0x22.., 2.0 TST (via path), 3.0 TST
- # (via constant)
- rendered = render(
- TREZOR_TEST_TOKEN_DESCRIPTOR,
- "7e577e02"
- "0000000000000000000000002222222222222222222222222222222222222222"
- "00000000000000000000000000000000000000000000000000000000001e8480"
- "00000000000000000000000000000000000000000000000000000000002dc6c0",
- )
- # token from the calldata `token` parameter
- self.assertEqual(rendered["Token (via path)"][0], "2 TST")
- self.assertEqual(rendered["Token (via path)"][2], unhexlify("22" * 20))
- # token from the literal const_token_address, not the calldata
- self.assertEqual(rendered["Token (via constant)"][0], "3 TST")
- self.assertEqual(rendered["Token (via constant)"][2], TREZOR_TEST_CONST_TOKEN)
-
- # --- multi-value arrays: amounts [1.0, 2.0], tokenAmounts [4.0, 5.0]
- # (TST units), dates [.., ..]
- rendered = render(
- TREZOR_TEST_ARRAYS_DESCRIPTOR,
- "7e577e03"
- "0000000000000000000000000000000000000000000000000000000000000060"
- "00000000000000000000000000000000000000000000000000000000000000c0"
- "0000000000000000000000000000000000000000000000000000000000000120"
- "0000000000000000000000000000000000000000000000000000000000000002"
- "00000000000000000000000000000000000000000000000000000000000f4240"
- "00000000000000000000000000000000000000000000000000000000001e8480"
- "0000000000000000000000000000000000000000000000000000000000000002"
- "00000000000000000000000000000000000000000000000000000000003d0900"
- "00000000000000000000000000000000000000000000000000000000004c4b40"
- "0000000000000000000000000000000000000000000000000000000000000002"
- "000000000000000000000000000000000000000000000000000000006052fe70"
- "000000000000000000000000000000000000000000000000000000006553f100",
- )
- self.assertEqual(rendered["Amounts (array)"][0], "1000000\n2000000")
- # multi-value tokenAmount: each element shares the one constant token
- self.assertEqual(rendered["Token Amounts (array)"][0], "4 TST\n5 TST")
- self.assertEqual(rendered["Token Amounts (array)"][2], TREZOR_TEST_CONST_TOKEN)
- self.assertEqual(
- rendered["Dates (array)"][0],
- "2021-03-18 07:17:04\n2023-11-14 22:13:20",
- )
-
- # --- composite path styles: amount 2.0 (TST units), packedPath
- # 0x44..||0x55.., swap[(0x66,0x77,6.0),(0x88,native,1 ETH)]
- rendered = render(
- TREZOR_TEST_PATHS_DESCRIPTOR,
- "7e577e04"
- "00000000000000000000000000000000000000000000000000000000001e8480"
- "0000000000000000000000000000000000000000000000000000000000000060"
- "00000000000000000000000000000000000000000000000000000000000000c0"
- "0000000000000000000000000000000000000000000000000000000000000028"
- "4444444444444444444444444444444444444444555555555555555555555555"
- "5555555555555555000000000000000000000000000000000000000000000000"
- "0000000000000000000000000000000000000000000000000000000000000002"
- "0000000000000000000000000000000000000000000000000000000000000040"
- "00000000000000000000000000000000000000000000000000000000000000a0"
- "0000000000000000000000006666666666666666666666666666666666666666"
- "0000000000000000000000007777777777777777777777777777777777777777"
- "00000000000000000000000000000000000000000000000000000000005b8d80"
- "0000000000000000000000008888888888888888888888888888888888888888"
- "0000000000000000000000000000000000000000000000000000000000000000"
- "0000000000000000000000000000000000000000000000000de0b6b3a7640000",
- )
- # token_path slicing the packed bytes blob (packedPath[0:20] / [-20:])
- self.assertEqual(rendered["Token (path[0:20] slice)"][0], "2 TST")
- self.assertEqual(rendered["Token (path[0:20] slice)"][2], unhexlify("44" * 20))
- self.assertEqual(rendered["Token (path[-20:] slice)"][0], "2 TST")
- self.assertEqual(rendered["Token (path[-20:] slice)"][2], unhexlify("55" * 20))
- # nested array-of-structs, positive index: swapData[0]
- self.assertEqual(rendered["Token (nested swap[0])"][0], "6 TST")
- self.assertEqual(rendered["Token (nested swap[0])"][2], unhexlify("66" * 20))
- # negative index + native currency: swapData[-1], receivingAssetId is the
- # native sentinel, so it renders native (no token returned)
- self.assertEqual(rendered["Token (neg index swap[-1], native)"][0], "1 ETH")
- self.assertIsNone(rendered["Token (neg index swap[-1], native)"][1])
-
if __name__ == "__main__":
unittest.main()
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.