Port 'test_eip1559' from 'speculos' to 'ragger'
|
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 374 B |
|
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 296 B |
|
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 434 B |
|
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 343 B |
|
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 414 B |
BIN
tests/ragger/snapshots/nanos/test_sign_eip_1559/00007.png
Normal file
|
After Width: | Height: | Size: 349 B |
1
tests/ragger/snapshots/nanosp/test_sign_eip_1559
Symbolic link
@@ -0,0 +1 @@
|
||||
../nanox/test_sign_eip_1559
|
||||
|
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
|
Before Width: | Height: | Size: 558 B After Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 412 B After Width: | Height: | Size: 412 B |
|
Before Width: | Height: | Size: 472 B After Width: | Height: | Size: 472 B |
BIN
tests/ragger/snapshots/nanox/test_sign_eip_1559/00005.png
Normal file
|
After Width: | Height: | Size: 381 B |
BIN
tests/ragger/snapshots/stax/test_sign_eip_1559/00000.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
tests/ragger/snapshots/stax/test_sign_eip_1559/00001.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
tests/ragger/snapshots/stax/test_sign_eip_1559/00002.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
tests/ragger/snapshots/stax/test_sign_eip_1559/00003.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
62
tests/ragger/test_eip1559.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from ledger_app_clients.ethereum.client import EthAppClient
|
||||
import ledger_app_clients.ethereum.response_parser as ResponseParser
|
||||
from ledger_app_clients.ethereum.utils import recover_transaction
|
||||
|
||||
from ragger.backend import BackendInterface
|
||||
from ragger.firmware import Firmware
|
||||
from ragger.navigator import Navigator, NavInsID
|
||||
|
||||
from web3 import Web3
|
||||
|
||||
from constants import ROOT_SNAPSHOT_PATH
|
||||
|
||||
|
||||
BIP32_PATH = "m/44'/60'/0'/0/0"
|
||||
NONCE = 1
|
||||
GAS_PRICE = 40000
|
||||
GAS_LIMIT = 10
|
||||
ADDR = bytes.fromhex("cccccccccccccccccccccccccccccccccccccccc")
|
||||
AMOUNT = 0.01
|
||||
CHAIN_ID = 1
|
||||
|
||||
|
||||
def test_sign_eip_1559(firmware: Firmware,
|
||||
backend: BackendInterface,
|
||||
navigator: Navigator,
|
||||
test_name: str):
|
||||
|
||||
tx_params = {
|
||||
"nonce": NONCE,
|
||||
"gas": Web3.to_wei(GAS_PRICE, "gwei"),
|
||||
"maxFeePerGas": Web3.to_wei(GAS_LIMIT, "gwei"),
|
||||
"maxPriorityFeePerGas": Web3.to_wei(GAS_LIMIT, "gwei"),
|
||||
"to": ADDR,
|
||||
"chainId": CHAIN_ID,
|
||||
}
|
||||
|
||||
app_client = EthAppClient(backend)
|
||||
|
||||
with app_client.get_public_addr(bip32_path=BIP32_PATH, display=False):
|
||||
pass
|
||||
_, DEVICE_ADDR, _ = ResponseParser.pk_addr(app_client.response().data)
|
||||
|
||||
with app_client.sign(BIP32_PATH, tx_params):
|
||||
if firmware.device.startswith("nano"):
|
||||
next_action = NavInsID.RIGHT_CLICK
|
||||
confirm_action = NavInsID.BOTH_CLICK
|
||||
end_text = "Accept"
|
||||
else:
|
||||
next_action = NavInsID.USE_CASE_REVIEW_TAP
|
||||
confirm_action = NavInsID.USE_CASE_REVIEW_CONFIRM
|
||||
end_text = "Sign"
|
||||
|
||||
navigator.navigate_until_text_and_compare(next_action,
|
||||
[confirm_action],
|
||||
end_text,
|
||||
ROOT_SNAPSHOT_PATH,
|
||||
test_name)
|
||||
|
||||
# verify signature
|
||||
vrs = ResponseParser.signature(app_client.response().data)
|
||||
addr = recover_transaction(tx_params, vrs)
|
||||
assert addr == DEVICE_ADDR
|
||||
@@ -1,64 +0,0 @@
|
||||
from time import sleep
|
||||
|
||||
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response
|
||||
|
||||
def test_sign_eip_1559(cmd):
|
||||
result: list = []
|
||||
# with bip32_path "44'/60'/0'/0/0"
|
||||
apdu_sign_eip_1559 = bytes.fromhex("e004000088058000002c8000003c80000000000000000000000002f87001018502540be4008502540be40086246139ca800094cccccccccccccccccccccccccccccccccccccccc8000c001a0e07fb8a64ea3786c9a6649e54429e2786af3ea31c6d06165346678cf8ce44f9ba00e4a0526db1e905b7164a858fd5ebd2f1759e22e6955499448bd276a6aa62830")
|
||||
|
||||
with cmd.send_apdu_context(apdu_sign_eip_1559, result) as ex:
|
||||
sleep(0.5)
|
||||
|
||||
if cmd.model == "nanos":
|
||||
# Review transaction
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00000.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Amount
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00001.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Address 1/3, 2/3, 3/3
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00002.png")
|
||||
cmd.client.press_and_release('right')
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00003.png")
|
||||
cmd.client.press_and_release('right')
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00004.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Max Fees
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00005.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Accept and send
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00006.png")
|
||||
cmd.client.press_and_release('both')
|
||||
|
||||
if cmd.model == "nanox" or cmd.model == "nanosp":
|
||||
# Review transaction
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00000.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Amount
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00001.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Address
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00002.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Max Fees
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00003.png")
|
||||
cmd.client.press_and_release('right')
|
||||
|
||||
# Accept and send
|
||||
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00004.png")
|
||||
cmd.client.press_and_release('both')
|
||||
|
||||
response: bytes = result[0]
|
||||
v, r, s = parse_sign_response(response)
|
||||
|
||||
assert v == 0x01
|
||||
assert r.hex() == "3d6dfabc6c52374bfa34cb2c433856a0bcd9484870dd1b50249f7164a5fce052"
|
||||
assert s.hex() == "0548a774dd0b63930d83cb2e1a836fe3ef24444e8b758b00585d9a076c0e98a8"
|
||||