Skip to content

Commit 40eec4c

Browse files
Add gating test
1 parent 80b5f51 commit 40eec4c

File tree

10 files changed

+72
-5
lines changed

10 files changed

+72
-5
lines changed
3.08 KB
Loading
5.76 KB
Loading
4.59 KB
Loading
3.53 KB
Loading
2.05 KB
Loading
3.11 KB
Loading
4.12 KB
Loading
4.35 KB
Loading

tests/ragger/test_blind_sign.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def common_blind_sign(scenario_navigator: NavigateWithScenario,
7070
test_name: str,
7171
app_client: EthAppClient,
7272
tx_params: dict,
73-
reject: bool = False):
73+
reject: bool = False,
74+
nb_warnings: int = 1) -> None:
7475
try:
7576
with app_client.sign(BIP32_PATH, tx_params):
7677
if reject:
@@ -80,9 +81,9 @@ def common_blind_sign(scenario_navigator: NavigateWithScenario,
8081
test_name += "_nonzero"
8182

8283
if reject:
83-
scenario_navigator.review_reject_with_warning(test_name=test_name)
84+
scenario_navigator.review_reject_with_warning(test_name=test_name, nb_warnings=nb_warnings)
8485
else:
85-
scenario_navigator.review_approve_with_warning(test_name=test_name)
86+
scenario_navigator.review_approve_with_warning(test_name=test_name, nb_warnings=nb_warnings)
8687

8788
except ExceptionRAPDU as e:
8889
assert reject
@@ -101,7 +102,8 @@ def test_blind_sign(navigator: Navigator,
101102
test_name: str,
102103
reject: bool,
103104
amount: float,
104-
simu_params: Optional[TxSimu] = None):
105+
simu_params: Optional[TxSimu] = None,
106+
nb_warnings: int = 1):
105107
if reject and amount > 0.0:
106108
pytest.skip()
107109

@@ -127,7 +129,8 @@ def test_blind_sign(navigator: Navigator,
127129
test_name,
128130
app_client,
129131
tx_params,
130-
reject)
132+
reject,
133+
nb_warnings)
131134

132135

133136
# Token approval, would require providing the token metadata from the CAL

tests/ragger/test_gating.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import pytest
2+
3+
from ragger.backend import BackendInterface
4+
from ragger.navigator.navigation_scenario import NavigateWithScenario
5+
6+
from test_blind_sign import test_blind_sign as blind_sign
7+
8+
from client.client import EthAppClient
9+
from client.gating import Gating
10+
from client.status_word import StatusWord
11+
12+
13+
def test_gating_descriptor(backend: BackendInterface) -> None:
14+
"""Test the Gating descriptor APDU"""
15+
16+
app_client = EthAppClient(backend)
17+
device = backend.device
18+
19+
if device.name != "apex_p":
20+
pytest.skip("TODO: ONLY APEX_P supported for now")
21+
22+
if device.is_nano:
23+
pytest.skip("Not yet supported on Nano")
24+
25+
descriptor = Gating(
26+
bytes.fromhex("Dad77910DbDFdE764fC21FCD4E74D71bBACA6D8D"),
27+
1,
28+
"Intro message",
29+
"https://tinyurl.com/example",
30+
)
31+
32+
response = app_client.provide_gating(descriptor)
33+
assert response.status == StatusWord.OK
34+
35+
36+
def test_gating_blind_signing(scenario_navigator: NavigateWithScenario) -> None:
37+
"""Test the Gating descriptor APDU with a blind signing transaction"""
38+
39+
backend = scenario_navigator.backend
40+
app_client = EthAppClient(backend)
41+
device = backend.device
42+
43+
if device.name != "apex_p":
44+
pytest.skip("TODO: ONLY APEX_P supported for now")
45+
46+
if device.is_nano:
47+
pytest.skip("Not yet supported on Nano")
48+
49+
descriptor = Gating(
50+
bytes.fromhex("Dad77910DbDFdE764fC21FCD4E74D71bBACA6D8D"),
51+
1,
52+
"To scan for threats and verify this transaction before signing, use Ledger Multisig.",
53+
"ledger.com/ledger-multisig",
54+
)
55+
56+
response = app_client.provide_gating(descriptor)
57+
assert response.status == StatusWord.OK
58+
59+
blind_sign(scenario_navigator.navigator,
60+
scenario_navigator,
61+
scenario_navigator.test_name,
62+
False,
63+
0.0,
64+
nb_warnings=2)

0 commit comments

Comments
 (0)