Skip to content

Commit c4fb8bf

Browse files
committed
test(7.15): assert fail-closed signing contracts
1 parent 57642ad commit c4fb8bf

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

tests/test_msg_ethereum_clear_signing.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,15 +1012,26 @@ def test_binding_happy_path_signs_and_recovers(self):
10121012
def _clearsign_flow(self, flow, chain_id=1):
10131013
"""Run one catalog flow END-TO-END with AdvancedMode ON: real tx,
10141014
per-tx-bound metadata, who/what/why annotation plus the ordinary raw
1015-
review (auto-acked), sign, and assert the signature recovers to the
1016-
device signer over this exact digest."""
1015+
review (auto-acked), then either sign and recover the exact digest or
1016+
assert the release policy's explicit fail-closed rejection."""
10171017
n = parse_path(DEVICE_PATH)
10181018
tx_hash = flow_tx_hash(flow, chain_id)
10191019
resp = self.client.ethereum_send_tx_metadata(
10201020
signed_payload=flow_blob(flow, chain_id),
10211021
metadata_version=1, key_id=TEST_KEY_ID)
10221022
self.assertEqual(resp.classification, CLASSIFICATION_VERIFIED)
10231023

1024+
if flow['key'] == 'erc20-approve-unlimited':
1025+
with self.assertRaises(CallException) as ctx:
1026+
self.client.ethereum_sign_tx(
1027+
n=n, nonce=FLOW_NONCE, gas_price=FLOW_GAS_PRICE,
1028+
gas_limit=FLOW_GAS_LIMIT, to=flow['to'],
1029+
value=flow['value'], data=flow['data'],
1030+
chain_id=chain_id)
1031+
self.assertIn('Unlimited ERC20 approval is disabled',
1032+
str(ctx.exception))
1033+
return
1034+
10241035
sig_v, sig_r, sig_s = self.client.ethereum_sign_tx(
10251036
n=n, nonce=FLOW_NONCE, gas_price=FLOW_GAS_PRICE,
10261037
gas_limit=FLOW_GAS_LIMIT, to=flow['to'], value=flow['value'],

tests/test_msg_osmosis_validation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ def _assert_missing_parameter_failure(self, ack):
3131
self.assertEqual(ret.code, proto_types.Failure_FirmwareError)
3232
self.assertEndsWith(ret.message, "missing required parameters")
3333

34-
def test_present_but_empty_amount_is_rejected_before_review(self):
34+
def test_present_but_empty_amount_is_rejected_as_invalid(self):
3535
self._start_signing()
3636
send = osmosis_proto.OsmosisMsgSend(
3737
to_address="osmo1g9el7lzjwh9yun2c4jjzhy09j98vkhfx8tzcpt",
3838
amount="",
3939
denom="uosmo",
4040
)
4141
self.assertTrue(send.HasField("amount"))
42-
self._assert_missing_parameter_failure(
43-
osmosis_proto.OsmosisMsgAck(send=send))
42+
ret = self.client.call_raw(osmosis_proto.OsmosisMsgAck(send=send))
43+
self.assertIsInstance(ret, proto.Failure)
44+
self.assertEqual(ret.code, proto_types.Failure_SyntaxError)
45+
self.assertEndsWith(ret.message,
46+
"Invalid Osmosis amount or denomination")
4447

4548
def test_ibc_omitted_amount_and_receiver_are_rejected_before_review(self):
4649
self._start_signing()

0 commit comments

Comments
 (0)