9
9
from client .client import EthAppClient , StatusWord
10
10
from client .settings import SettingID , settings_toggle
11
11
import client .response_parser as ResponseParser
12
- from client .utils import recover_message
13
12
from client .tx_auth_7702 import TxAuth7702
14
13
15
14
BIP32_PATH = "m/44'/60'/0'/0/0"
29
28
# cast wallet sign-auth $ADDRESS --mnemonic $MNEMONIC --mnemonic-derivation-path "m/44'/60'/0'/0/0" --nonce $NONCE --chain $CHAINID
30
29
# Decoded by https://codechain-io.github.io/rlp-debugger/
31
30
31
+
32
32
def common (firmware : Firmware ,
33
33
backend : BackendInterface ,
34
34
scenario : NavigateWithScenario ,
@@ -51,25 +51,19 @@ def common(firmware: Firmware,
51
51
with app_client .sign_eip7702_authorization (BIP32_PATH , auth_params ):
52
52
scenario .review_approve (test_name = test_name , custom_screen_text = end_text )
53
53
vrs = ResponseParser .signature (app_client .response ().data )
54
- if v != None :
55
- assert v == vrs [0 ]
56
- assert r == vrs [1 ]
57
- assert s == vrs [2 ]
54
+ assert vrs == (v , r , s )
58
55
59
56
60
57
def common_rejected (firmware : Firmware ,
61
- backend : BackendInterface ,
62
- scenario : NavigateWithScenario ,
63
- test_name : str ,
64
- delegate : bytes ,
65
- nonce : int ,
66
- chain_id : int ):
58
+ backend : BackendInterface ,
59
+ scenario : NavigateWithScenario ,
60
+ test_name : str ,
61
+ delegate : bytes ,
62
+ nonce : int ,
63
+ chain_id : int ):
67
64
68
65
app_client = EthAppClient (backend )
69
66
70
- # try:
71
- # with app_client.sign_eip7702_authorization(BIP32_PATH, delegate, nonce, chain_id):
72
- # scenario.review_reject(custom_screen_text=".*7702*")
73
67
try :
74
68
auth_params = TxAuth7702 (delegate , nonce , chain_id )
75
69
with app_client .sign_eip7702_authorization (BIP32_PATH , auth_params ):
@@ -79,85 +73,115 @@ def common_rejected(firmware: Firmware,
79
73
else :
80
74
moves += [NavInsID .USE_CASE_CHOICE_REJECT ]
81
75
scenario .navigator .navigate_and_compare (scenario .screenshot_path ,
82
- test_name ,
83
- moves )
76
+ test_name ,
77
+ moves )
84
78
85
79
except ExceptionRAPDU as e :
86
80
assert e .status == StatusWord .CONDITION_NOT_SATISFIED
87
81
else :
88
82
assert False # An exception should have been raised
89
83
84
+
90
85
def test_eip7702_in_whitelist (firmware : Firmware ,
91
- backend : BackendInterface ,
92
- scenario_navigator : NavigateWithScenario ,
93
- test_name : str ):
86
+ backend : BackendInterface ,
87
+ scenario_navigator : NavigateWithScenario ,
88
+ test_name : str ):
94
89
if firmware == Firmware .NANOS :
95
90
pytest .skip ("Not supported on LNS" )
96
91
settings_toggle (firmware , scenario_navigator .navigator , [SettingID .EIP7702 ])
97
- common (firmware , backend , scenario_navigator , test_name , TEST_ADDRESS_1 , NONCE , CHAIN_ID_1 ,
98
- bytes .fromhex ("00" ),
99
- bytes .fromhex ("f82e 50a7 55fa 989f 4bb9 b36b 15af b442 4ce9 cda6 9752 fd17 a7eb 1473 7d96 3e62" ),
100
- bytes .fromhex ("07c9 c91d 6140 b45e a52f 29de 7a5e ffb9 dd34 0607 a26e 225c 4027 8e91 c405 4492" ))
92
+ common (firmware ,
93
+ backend ,
94
+ scenario_navigator ,
95
+ test_name ,
96
+ TEST_ADDRESS_1 ,
97
+ NONCE ,
98
+ CHAIN_ID_1 ,
99
+ bytes .fromhex ("00" ),
100
+ bytes .fromhex ("f82e 50a7 55fa 989f 4bb9 b36b 15af b442 4ce9 cda6 9752 fd17 a7eb 1473 7d96 3e62" ),
101
+ bytes .fromhex ("07c9 c91d 6140 b45e a52f 29de 7a5e ffb9 dd34 0607 a26e 225c 4027 8e91 c405 4492" ))
102
+
101
103
102
104
def test_eip7702_in_whitelist_all_chain_whitelisted (firmware : Firmware ,
103
- backend : BackendInterface ,
104
- scenario_navigator : NavigateWithScenario ,
105
- test_name : str ):
105
+ backend : BackendInterface ,
106
+ scenario_navigator : NavigateWithScenario ,
107
+ test_name : str ):
106
108
if firmware == Firmware .NANOS :
107
109
pytest .skip ("Not supported on LNS" )
108
110
settings_toggle (firmware , scenario_navigator .navigator , [SettingID .EIP7702 ])
109
- common (firmware , backend , scenario_navigator , test_name , TEST_ADDRESS_0 , NONCE , CHAIN_ID_2 ,
110
- bytes .fromhex ("00" ),
111
- bytes .fromhex ("0378 f7ac 482e c728 b65d 19d0 3943 bbb3 fe73 07c7 2c64 6e7d 2d0c 11be e81e b2b9" ),
112
- bytes .fromhex ("3322 66ec 3ef9 96bf 835c 50a8 3300 6b4c 8039 8d59 7d0e 6846 19db 4d51 a384 a38d" ))
111
+ common (firmware ,
112
+ backend ,
113
+ scenario_navigator ,
114
+ test_name ,
115
+ TEST_ADDRESS_0 ,
116
+ NONCE ,
117
+ CHAIN_ID_2 ,
118
+ bytes .fromhex ("00" ),
119
+ bytes .fromhex ("0378 f7ac 482e c728 b65d 19d0 3943 bbb3 fe73 07c7 2c64 6e7d 2d0c 11be e81e b2b9" ),
120
+ bytes .fromhex ("3322 66ec 3ef9 96bf 835c 50a8 3300 6b4c 8039 8d59 7d0e 6846 19db 4d51 a384 a38d" ))
121
+
113
122
114
123
def test_eip7702_in_whitelist_all_chain_param (firmware : Firmware ,
115
- backend : BackendInterface ,
116
- scenario_navigator : NavigateWithScenario ,
117
- test_name : str ):
124
+ backend : BackendInterface ,
125
+ scenario_navigator : NavigateWithScenario ,
126
+ test_name : str ):
118
127
if firmware == Firmware .NANOS :
119
128
pytest .skip ("Not supported on LNS" )
120
129
settings_toggle (firmware , scenario_navigator .navigator , [SettingID .EIP7702 ])
121
- common (firmware , backend , scenario_navigator , test_name , TEST_ADDRESS_2 , NONCE , CHAIN_ID_0 ,
122
- bytes .fromhex ("01" ),
123
- bytes .fromhex ("a24f 35ca fc6b 408c e325 39d4 bd89 a67e dd4d 6303 fc67 6dfd df93 b984 05b7 ee5e" ),
124
- bytes .fromhex ("1594 56ba be65 6692 959c a3d8 29ca 269e 8f82 387c 91e4 0a33 633d 190d da7a 3c5c" ))
130
+ common (firmware ,
131
+ backend ,
132
+ scenario_navigator ,
133
+ test_name ,
134
+ TEST_ADDRESS_2 ,
135
+ NONCE ,
136
+ CHAIN_ID_0 ,
137
+ bytes .fromhex ("01" ),
138
+ bytes .fromhex ("a24f 35ca fc6b 408c e325 39d4 bd89 a67e dd4d 6303 fc67 6dfd df93 b984 05b7 ee5e" ),
139
+ bytes .fromhex ("1594 56ba be65 6692 959c a3d8 29ca 269e 8f82 387c 91e4 0a33 633d 190d da7a 3c5c" ))
140
+
125
141
126
142
def test_eip7702_in_whitelist_max (firmware : Firmware ,
127
- backend : BackendInterface ,
128
- scenario_navigator : NavigateWithScenario ,
129
- test_name : str ):
143
+ backend : BackendInterface ,
144
+ scenario_navigator : NavigateWithScenario ,
145
+ test_name : str ):
130
146
if firmware == Firmware .NANOS :
131
147
pytest .skip ("Not supported on LNS" )
132
148
settings_toggle (firmware , scenario_navigator .navigator , [SettingID .EIP7702 ])
133
- common (firmware , backend , scenario_navigator , test_name , TEST_ADDRESS_MAX , NONCE_MAX , CHAIN_ID_MAX ,
134
- bytes .fromhex ("00" ),
135
- bytes .fromhex ("a07c 6808 9449 8c21 e80f ebb0 11ae 5d62 ede6 645d 77d7 c902 db06 5d5a 082d d220" ),
136
- bytes .fromhex ("6b5c 6222 5cf6 5a62 40c2 583d acc1 641c 8d69 2ed3 bd00 473c c3e2 8fe1 a4f5 2294" ))
149
+ common (firmware ,
150
+ backend ,
151
+ scenario_navigator ,
152
+ test_name ,
153
+ TEST_ADDRESS_MAX ,
154
+ NONCE_MAX ,
155
+ CHAIN_ID_MAX ,
156
+ bytes .fromhex ("00" ),
157
+ bytes .fromhex ("a07c 6808 9449 8c21 e80f ebb0 11ae 5d62 ede6 645d 77d7 c902 db06 5d5a 082d d220" ),
158
+ bytes .fromhex ("6b5c 6222 5cf6 5a62 40c2 583d acc1 641c 8d69 2ed3 bd00 473c c3e2 8fe1 a4f5 2294" ))
137
159
138
160
139
161
def test_eip7702_in_whitelist_wrong_chain (firmware : Firmware ,
140
- backend : BackendInterface ,
141
- scenario_navigator : NavigateWithScenario ,
142
- test_name : str ):
162
+ backend : BackendInterface ,
163
+ scenario_navigator : NavigateWithScenario ,
164
+ test_name : str ):
143
165
if firmware == Firmware .NANOS :
144
166
pytest .skip ("Not supported on LNS" )
145
167
settings_toggle (firmware , scenario_navigator .navigator , [SettingID .EIP7702 ])
146
168
common_rejected (firmware , backend , scenario_navigator , test_name , TEST_ADDRESS_2 , NONCE , CHAIN_ID_1 )
147
169
170
+
148
171
def test_eip7702_not_in_whitelist (firmware : Firmware ,
149
- backend : BackendInterface ,
150
- scenario_navigator : NavigateWithScenario ,
151
- test_name : str ):
172
+ backend : BackendInterface ,
173
+ scenario_navigator : NavigateWithScenario ,
174
+ test_name : str ):
152
175
if firmware == Firmware .NANOS :
153
176
pytest .skip ("Not supported on LNS" )
154
177
settings_toggle (firmware , scenario_navigator .navigator , [SettingID .EIP7702 ])
155
178
common_rejected (firmware , backend , scenario_navigator , test_name , TEST_ADDRESS_NO_WHITELIST , NONCE , CHAIN_ID_1 )
156
179
180
+
157
181
def test_eip7702_not_enabled (firmware : Firmware ,
158
- backend : BackendInterface ,
159
- scenario_navigator : NavigateWithScenario ,
160
- test_name : str ):
182
+ backend : BackendInterface ,
183
+ scenario_navigator : NavigateWithScenario ,
184
+ test_name : str ):
161
185
if firmware == Firmware .NANOS :
162
186
pytest .skip ("Not supported on LNS" )
163
187
common_rejected (firmware , backend , scenario_navigator , test_name , TEST_ADDRESS_1 , NONCE , CHAIN_ID_1 )
0 commit comments