Skip to content

Commit 310c1d8

Browse files
Align StatusWords usage
1 parent 9452b43 commit 310c1d8

16 files changed

Lines changed: 82 additions & 81 deletions

client/src/ledger_app_clients/ethereum/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ def provide_network_information(self, network_params: DynamicNetwork) -> None:
421421
network_params.icon)
422422
for chunk in chunks[:-1]:
423423
response = self._exchange(chunk)
424-
assert response.status == StatusWord.OK
424+
assert response.status == StatusWord.SWO_SUCCESS
425425
response = self._exchange(chunks[-1])
426-
assert response.status == StatusWord.OK
426+
assert response.status == StatusWord.SWO_SUCCESS
427427

428428
def provide_enum_value(self, payload: bytes) -> RAPDU:
429429
# Send ledgerPKI certificate

client/src/ledger_app_clients/ethereum/eip712/InputData.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def send_struct_def_field(typename, keyname):
113113
pass
114114

115115
response = app_client.response()
116-
assert response.status == StatusWord.OK, \
116+
assert response.status == StatusWord.SWO_SUCCESS, \
117117
f"Error sending field def {keyname} of type {typename}: {response.status}"
118118

119119
return (typename, type_enum, typesize, array_lvls)
@@ -196,7 +196,7 @@ def send_all_filtering_tokens(tokens: list[dict]):
196196
bytes.fromhex(token["addr"][2:]),
197197
token["decimals"],
198198
token["chain_id"])
199-
assert response.status == StatusWord.OK, \
199+
assert response.status == StatusWord.SWO_SUCCESS, \
200200
f"Error sending token metadata for {token['ticker']}: {response.status}"
201201

202202

@@ -284,7 +284,7 @@ def send_struct_impl_field(value, field):
284284
callback()
285285

286286
response = app_client.response()
287-
assert response.status == StatusWord.OK, \
287+
assert response.status == StatusWord.SWO_SUCCESS, \
288288
f"Error sending field {field['name']} of type {field['type']}: {response.status}"
289289

290290

@@ -297,14 +297,14 @@ def evaluate_field(structs, data, field, lvls_left, new_level=True):
297297
with app_client.eip712_send_struct_impl_array(len(data)):
298298
pass
299299
response = app_client.response()
300-
assert response.status == StatusWord.OK, \
300+
assert response.status == StatusWord.SWO_SUCCESS, \
301301
f"Error sending array {field['name']} of type {field['type']}: {response.status}"
302302
if len(data) == 0:
303303
for path in filtering_paths.keys():
304304
dpath = ".".join(current_path) + ".[]"
305305
if path.startswith(dpath):
306306
response = app_client.eip712_filtering_discarded_path(path)
307-
assert response.status == StatusWord.OK, \
307+
assert response.status == StatusWord.SWO_SUCCESS, \
308308
f"Error sending discarded path {path}: {response.status}"
309309
send_filter(path, True)
310310
idx = 0
@@ -355,7 +355,7 @@ def send_filtering_message_info(display_name: str, filters_count: int):
355355
with app_client.eip712_filtering_message_info(display_name, filters_count, sig):
356356
pass
357357
response = app_client.response()
358-
assert response.status == StatusWord.OK, \
358+
assert response.status == StatusWord.SWO_SUCCESS, \
359359
f"Error sending filtering message info for {display_name}: {response.status}"
360360

361361

@@ -367,7 +367,7 @@ def send_filtering_amount_join_token(path: str, join_id: int, discarded: bool):
367367
with app_client.eip712_filtering_amount_join_token(join_id, sig, discarded):
368368
pass
369369
response = app_client.response()
370-
assert response.status == StatusWord.OK, \
370+
assert response.status == StatusWord.SWO_SUCCESS, \
371371
f"Error sending filtering amount join token for {path} with token index {join_id}: {response.status}"
372372

373373

@@ -380,7 +380,7 @@ def send_filtering_amount_join_value(path: str, join_id: int, display_name: str,
380380
with app_client.eip712_filtering_amount_join_value(join_id, display_name, sig, discarded):
381381
pass
382382
response = app_client.response()
383-
assert response.status == StatusWord.OK, \
383+
assert response.status == StatusWord.SWO_SUCCESS, \
384384
f"Error sending filtering amount join value for {path} with token index {join_id}: {response.status}"
385385

386386

@@ -392,7 +392,7 @@ def send_filtering_datetime(path: str, display_name: str, discarded: bool):
392392
with app_client.eip712_filtering_datetime(display_name, sig, discarded):
393393
pass
394394
response = app_client.response()
395-
assert response.status == StatusWord.OK, \
395+
assert response.status == StatusWord.SWO_SUCCESS, \
396396
f"Error sending filtering datetime for {path}: {response.status}"
397397

398398

@@ -412,7 +412,7 @@ def send_filtering_trusted_name(path: str,
412412
with app_client.eip712_filtering_trusted_name(display_name, name_type, name_source, sig, discarded):
413413
pass
414414
response = app_client.response()
415-
assert response.status == StatusWord.OK, \
415+
assert response.status == StatusWord.SWO_SUCCESS, \
416416
f"Error sending filtering trusted name for {path}: {response.status}"
417417

418418

@@ -440,7 +440,7 @@ def send_filtering_calldata_info(index: int,
440440
amount_filter_flag,
441441
spender_filter_flag,
442442
sig)
443-
assert response.status == StatusWord.OK, \
443+
assert response.status == StatusWord.SWO_SUCCESS, \
444444
f"Error sending filtering calldata info : {response.status}"
445445

446446

@@ -450,7 +450,7 @@ def send_filtering_calldata_value(path: str, index: int, discarded: bool):
450450
to_sign.append(index)
451451
sig = CAL_COIN_META_PARTNER.sign(to_sign)
452452
response = app_client.eip712_filtering_calldata_value(index, sig, discarded)
453-
assert response.status == StatusWord.OK, \
453+
assert response.status == StatusWord.SWO_SUCCESS, \
454454
f"Error sending filtering calldata value for {path}: {response.status}"
455455

456456

@@ -460,7 +460,7 @@ def send_filtering_calldata_callee(path: str, index: int, discarded: bool):
460460
to_sign.append(index)
461461
sig = CAL_COIN_META_PARTNER.sign(to_sign)
462462
response = app_client.eip712_filtering_calldata_callee(index, sig, discarded)
463-
assert response.status == StatusWord.OK, \
463+
assert response.status == StatusWord.SWO_SUCCESS, \
464464
f"Error sending filtering calldata callee for {path}: {response.status}"
465465

466466

@@ -470,7 +470,7 @@ def send_filtering_calldata_chain_id(path: str, index: int, discarded: bool):
470470
to_sign.append(index)
471471
sig = CAL_COIN_META_PARTNER.sign(to_sign)
472472
response = app_client.eip712_filtering_calldata_chain_id(index, sig, discarded)
473-
assert response.status == StatusWord.OK, \
473+
assert response.status == StatusWord.SWO_SUCCESS, \
474474
f"Error sending filtering calldata callee for {path}: {response.status}"
475475

476476

@@ -480,7 +480,7 @@ def send_filtering_calldata_selector(path: str, index: int, discarded: bool):
480480
to_sign.append(index)
481481
sig = CAL_COIN_META_PARTNER.sign(to_sign)
482482
response = app_client.eip712_filtering_calldata_selector(index, sig, discarded)
483-
assert response.status == StatusWord.OK, \
483+
assert response.status == StatusWord.SWO_SUCCESS, \
484484
f"Error sending filtering calldata callee for {path}: {response.status}"
485485

486486

@@ -490,7 +490,7 @@ def send_filtering_calldata_amount(path: str, index: int, discarded: bool):
490490
to_sign.append(index)
491491
sig = CAL_COIN_META_PARTNER.sign(to_sign)
492492
response = app_client.eip712_filtering_calldata_amount(index, sig, discarded)
493-
assert response.status == StatusWord.OK, \
493+
assert response.status == StatusWord.SWO_SUCCESS, \
494494
f"Error sending filtering calldata callee for {path}: {response.status}"
495495

496496

@@ -500,7 +500,7 @@ def send_filtering_calldata_spender(path: str, index: int, discarded: bool):
500500
to_sign.append(index)
501501
sig = CAL_COIN_META_PARTNER.sign(to_sign)
502502
response = app_client.eip712_filtering_calldata_spender(index, sig, discarded)
503-
assert response.status == StatusWord.OK, \
503+
assert response.status == StatusWord.SWO_SUCCESS, \
504504
f"Error sending filtering calldata callee for {path}: {response.status}"
505505

506506

@@ -513,7 +513,7 @@ def send_filtering_raw(path: str, display_name: str, discarded: bool):
513513
with app_client.eip712_filtering_raw(display_name, sig, discarded):
514514
pass
515515
response = app_client.response()
516-
assert response.status == StatusWord.OK, \
516+
assert response.status == StatusWord.SWO_SUCCESS, \
517517
f"Error sending filtering raw for {path}: {response.status}"
518518

519519

@@ -604,7 +604,7 @@ def process_data(aclient: EthAppClient,
604604
with app_client.eip712_send_struct_def_struct_name(key):
605605
pass
606606
response = app_client.response()
607-
assert response.status == StatusWord.OK, \
607+
assert response.status == StatusWord.SWO_SUCCESS, \
608608
f"Error sending struct def {key}: {response.status}"
609609
for f in types[key]:
610610
(f["type"], f["enum"], f["typesize"], f["array_lvls"]) = \
@@ -614,7 +614,7 @@ def process_data(aclient: EthAppClient,
614614
with app_client.eip712_filtering_activate():
615615
pass
616616
response = app_client.response()
617-
assert response.status == StatusWord.OK, \
617+
assert response.status == StatusWord.SWO_SUCCESS, \
618618
f"Error activating filtering: {response.status}"
619619
prepare_filtering(data_json, filters)
620620
send_all_filtering_tokens(filtering_tokens)
@@ -626,7 +626,7 @@ def process_data(aclient: EthAppClient,
626626
with app_client.eip712_send_struct_impl_root_struct(domain_typename):
627627
pass
628628
response = app_client.response()
629-
assert response.status == StatusWord.OK, \
629+
assert response.status == StatusWord.SWO_SUCCESS, \
630630
f"Error sending domain root struct {domain_typename}: {response.status}"
631631
send_struct_impl(types, domain, domain_typename)
632632

@@ -640,6 +640,6 @@ def process_data(aclient: EthAppClient,
640640
with app_client.eip712_send_struct_impl_root_struct(message_typename):
641641
pass
642642
response = app_client.response()
643-
assert response.status == StatusWord.OK, \
643+
assert response.status == StatusWord.SWO_SUCCESS, \
644644
f"Error sending message root struct {message_typename}: {response.status}"
645645
send_struct_impl(types, message, message_typename)

tests/ragger/test_blind_sign.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def common_blind_sign(scenario_navigator: NavigateWithScenario,
8989

9090
except ExceptionRAPDU as e:
9191
assert reject
92-
assert e.status == StatusWord.CONDITION_NOT_SATISFIED
92+
assert e.status == StatusWord.SWO_CONDITIONS_NOT_SATISFIED
9393
else:
9494
assert not reject
9595
# verify signature
@@ -130,10 +130,10 @@ def test_blind_sign(navigator: Navigator,
130130
gating_params.address,
131131
)
132132
response = app_client.provide_proxy_info(proxy_info.serialize())
133-
assert response.status == StatusWord.OK
133+
assert response.status == StatusWord.SWO_SUCCESS
134134

135135
response = app_client.provide_gating(gating_params)
136-
assert response.status == StatusWord.OK
136+
assert response.status == StatusWord.SWO_SUCCESS
137137
nb_warnings += 1
138138

139139
if not reject and simu_params is not None:
@@ -142,7 +142,7 @@ def test_blind_sign(navigator: Navigator,
142142
simu_params.chain_id = tx_params["chainId"]
143143
simu_params.from_addr = DEVICE_ADDR
144144
response = app_client.provide_tx_simulation(simu_params)
145-
assert response.status == StatusWord.OK
145+
assert response.status == StatusWord.SWO_SUCCESS
146146

147147
common_blind_sign(scenario_navigator,
148148
test_name,
@@ -186,7 +186,7 @@ def test_blind_sign_reject_in_risk_review(backend: BackendInterface, navigator:
186186
with app_client.sign(BIP32_PATH, common_tx_params(0.0)):
187187
navigator.navigate(moves)
188188
except ExceptionRAPDU as e:
189-
assert e.status == StatusWord.CONDITION_NOT_SATISFIED
189+
assert e.status == StatusWord.SWO_CONDITIONS_NOT_SATISFIED
190190
else:
191191
assert False # Should have thrown
192192

@@ -250,6 +250,6 @@ def test_blind_sign_not_enabled_error(backend: BackendInterface,
250250
test_name,
251251
moves)
252252
except ExceptionRAPDU as e:
253-
assert e.status == StatusWord.INVALID_DATA
253+
assert e.status == StatusWord.SWO_INCORRECT_DATA
254254
else:
255255
assert False # Should have thrown

tests/ragger/test_eip191.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def handle_simulation(app_client: EthAppClient, msg: str, simu_params: TxSimu) -
2020
if not simu_params.tx_hash:
2121
simu_params.tx_hash = keccak.new(digest_bits=256, data=msg_to_sign).digest()
2222
response = app_client.provide_tx_simulation(simu_params)
23-
assert response.status == StatusWord.OK
23+
assert response.status == StatusWord.SWO_SUCCESS
2424

2525

2626
def common(scenario_navigator: NavigateWithScenario,
@@ -63,7 +63,7 @@ def common(scenario_navigator: NavigateWithScenario,
6363

6464
except ExceptionRAPDU as err:
6565
if simu_params and "tx_hash" in simu_params:
66-
assert err.status == StatusWord.CONDITION_NOT_SATISFIED
66+
assert err.status == StatusWord.SWO_CONDITIONS_NOT_SATISFIED
6767
else:
6868
assert False, f"Unexpected exception: {err}"
6969

@@ -107,6 +107,6 @@ def test_personal_sign_reject(scenario_navigator: NavigateWithScenario):
107107
scenario_navigator.review_reject()
108108

109109
except ExceptionRAPDU as e:
110-
assert e.status == StatusWord.CONDITION_NOT_SATISFIED
110+
assert e.status == StatusWord.SWO_CONDITIONS_NOT_SATISFIED
111111
else:
112112
assert False # An exception should have been raised

tests/ragger/test_eip712.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_eip712_v0(scenario_navigator: NavigateWithScenario, simu_params: Option
9999
simu_params.tx_hash = smsg.body
100100
simu_params.domain_hash = smsg.header
101101
response = app_client.provide_tx_simulation(simu_params)
102-
assert response.status == StatusWord.OK
102+
assert response.status == StatusWord.SWO_SUCCESS
103103

104104
with app_client.eip712_sign_legacy(BIP32_PATH, smsg.header, smsg.body):
105105
scenario_navigator.review_approve_with_warning(do_comparison=False)
@@ -171,7 +171,7 @@ def test_eip712_new(scenario_navigator: NavigateWithScenario,
171171
InputData.init_signature_context(sig_ctx, data["types"], data["domain"], filters or {})
172172
gating_params.selector = sig_ctx["schema_hash"]
173173
response = app_client.provide_gating(gating_params)
174-
assert response and response.status == StatusWord.OK
174+
assert response and response.status == StatusWord.SWO_SUCCESS
175175
nb_warnings += 1
176176
snapshots_dirname = "test_gating_eip712"
177177

@@ -534,7 +534,7 @@ def test_eip712_filtering_empty_array(scenario_navigator: NavigateWithScenario,
534534
simu_params.tx_hash = smsg.body
535535
simu_params.domain_hash = smsg.header
536536
response = app_client.provide_tx_simulation(simu_params)
537-
assert response.status == StatusWord.OK
537+
assert response.status == StatusWord.SWO_SUCCESS
538538
nb_warnings = 1
539539

540540
eip712_new_common(scenario_navigator, data, filters, scenario_navigator.test_name, nb_warnings=nb_warnings)
@@ -570,7 +570,7 @@ def test_eip712_advanced_missing_token(scenario_navigator: NavigateWithScenario,
570570

571571
test_name = scenario_navigator.test_name
572572
for token in tokens:
573-
test_name += "-%s" % token["ticker"]
573+
test_name += f"-{token['ticker']}"
574574
data = {
575575
"types": {
576576
"EIP712Domain": [
@@ -721,7 +721,7 @@ def test_eip712_advanced_trusted_name(scenario_navigator: NavigateWithScenario,
721721
def test_eip712_bs_not_activated_error(scenario_navigator: NavigateWithScenario):
722722
with pytest.raises(ExceptionRAPDU) as e:
723723
eip712_new_common(scenario_navigator, ADVANCED_DATA_SETS[0].data)
724-
assert e.value.status == StatusWord.INVALID_DATA
724+
assert e.value.status == StatusWord.SWO_INCORRECT_DATA
725725

726726

727727
def test_eip712_proxy(scenario_navigator: NavigateWithScenario):

tests/ragger/test_eip7702.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def common_error(scenario_navigator: NavigateWithScenario,
7979
moves)
8080

8181
except ExceptionRAPDU as e:
82-
assert e.status == StatusWord.COMMAND_NOT_ALLOWED
82+
assert e.status == StatusWord.SWO_COMMAND_NOT_ALLOWED
8383
else:
8484
assert False # An exception should have been raised
8585

0 commit comments

Comments
 (0)