forked from onflow/ledger-app-flow
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_app_mainmenu.py
91 lines (81 loc) · 3.19 KB
/
test_app_mainmenu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from application_client.flow_command_sender import FlowCommandSender, HashType, CryptoOptions
from ragger.navigator import NavIns, NavInsID
from ragger.bip import CurveChoice
from utils import ROOT_SCREENSHOT_PATH, util_set_slot
def test_app_mainmenu(firmware, backend, navigator, test_name):
""" Check the behavior of the device main menu """
client = FlowCommandSender(backend)
choiceIdShowAdderess = 5 if firmware.device == "stax" else 4;
# Navigate in the main menu, click "View address"
if firmware.device == "nanos":
instructions = [
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.LEFT_CLICK,
NavInsID.LEFT_CLICK,
NavInsID.BOTH_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK,
]
elif firmware.device.startswith("nano"):
instructions = [
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.LEFT_CLICK,
NavInsID.LEFT_CLICK,
NavInsID.BOTH_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK,
]
else:
instructions = [
NavIns(NavInsID.CHOICE_CHOOSE, [choiceIdShowAdderess]),
NavInsID.USE_CASE_REVIEW_TAP,
NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM,
NavInsID.USE_CASE_SETTINGS_MULTI_PAGE_EXIT
]
part = 0
navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, f"{test_name}/part{part}", instructions,
screen_change_before_first_instruction=False)
# Send the APDU - Set slot
crypto_options = CryptoOptions(CurveChoice.Secp256k1, HashType.HASH_SHA2)
address = "e467b9dd11fa00df"
path = "m/44'/539'/513'/0/0"
part += 1
util_set_slot(client, firmware, navigator, f"{test_name}/part{part}", 0, crypto_options, address, path)
# Navigate in the main menu, click "View address"
if firmware.device.startswith("nano"):
instructions = [
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK,
]
else:
instructions = [
NavIns(NavInsID.CHOICE_CHOOSE, [choiceIdShowAdderess]),
NavInsID.USE_CASE_REVIEW_TAP,
NavInsID.USE_CASE_REVIEW_TAP,
NavInsID.USE_CASE_ADDRESS_CONFIRMATION_CONFIRM,
NavInsID.USE_CASE_SETTINGS_MULTI_PAGE_EXIT,
NavInsID.USE_CASE_HOME_SETTINGS,
NavInsID.USE_CASE_SETTINGS_NEXT,
]
part += 1
navigator.navigate_and_compare(ROOT_SCREENSHOT_PATH, f"{test_name}/part{part}", instructions,
screen_change_before_first_instruction=False)