New blind-sign ragger test
@@ -1,3 +1,5 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
|
||||||
ROOT_SNAPSHOT_PATH = Path(__file__).parent
|
ROOT_SNAPSHOT_PATH = Path(__file__).parent
|
||||||
|
ABIS_FOLDER = "%s/abis" % (os.path.dirname(__file__))
|
||||||
|
|||||||
BIN
tests/ragger/snapshots/nanos/blind-signed_approval/00000.png
Normal file
|
After Width: | Height: | Size: 428 B |
BIN
tests/ragger/snapshots/nanos/blind-signed_approval/00001.png
Normal file
|
After Width: | Height: | Size: 419 B |
BIN
tests/ragger/snapshots/nanos/blind-signed_approval/00002.png
Normal file
|
After Width: | Height: | Size: 349 B |
BIN
tests/ragger/snapshots/nanosp/blind-signed_approval/00000.png
Normal file
|
After Width: | Height: | Size: 587 B |
BIN
tests/ragger/snapshots/nanosp/blind-signed_approval/00001.png
Normal file
|
After Width: | Height: | Size: 381 B |
BIN
tests/ragger/snapshots/nanox/blind-signed_approval/00000.png
Normal file
|
After Width: | Height: | Size: 587 B |
BIN
tests/ragger/snapshots/nanox/blind-signed_approval/00001.png
Normal file
|
After Width: | Height: | Size: 381 B |
BIN
tests/ragger/snapshots/stax/blind-signed_approval/00000.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
tests/ragger/snapshots/stax/blind-signed_approval/00001.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
55
tests/ragger/test_blind_sign.py
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import json
|
||||||
|
from ragger.backend import BackendInterface
|
||||||
|
from ragger.firmware import Firmware
|
||||||
|
from ragger.navigator import Navigator, NavInsID
|
||||||
|
from ragger.error import ExceptionRAPDU
|
||||||
|
from ledger_app_clients.ethereum.client import EthAppClient
|
||||||
|
from web3 import Web3
|
||||||
|
from constants import ROOT_SNAPSHOT_PATH, ABIS_FOLDER
|
||||||
|
|
||||||
|
|
||||||
|
# Token approval, would require loading the "internal plugin" &
|
||||||
|
# providing the token metadata from the CAL
|
||||||
|
def test_blind_sign(firmware: Firmware,
|
||||||
|
backend: BackendInterface,
|
||||||
|
navigator: Navigator):
|
||||||
|
app_client = EthAppClient(backend)
|
||||||
|
|
||||||
|
with open("%s/erc20.json" % (ABIS_FOLDER)) as file:
|
||||||
|
contract = Web3().eth.contract(
|
||||||
|
abi=json.load(file),
|
||||||
|
address=None
|
||||||
|
)
|
||||||
|
data = contract.encodeABI("approve", [
|
||||||
|
# Uniswap Protocol: Permit2
|
||||||
|
bytes.fromhex("000000000022d473030f116ddee9f6b43ac78ba3"),
|
||||||
|
Web3.to_wei("2", "ether")
|
||||||
|
])
|
||||||
|
tx_params = {
|
||||||
|
"nonce": 235,
|
||||||
|
"maxFeePerGas": Web3.to_wei(100, "gwei"),
|
||||||
|
"maxPriorityFeePerGas": Web3.to_wei(10, "gwei"),
|
||||||
|
"gas": 44001,
|
||||||
|
# Maker: Dai Stablecoin
|
||||||
|
"to": bytes.fromhex("6b175474e89094c44da98b954eedeac495271d0f"),
|
||||||
|
"data": data,
|
||||||
|
"chainId": 1
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
with app_client.sign("m/44'/60'/0'/0/0", tx_params):
|
||||||
|
pass
|
||||||
|
except ExceptionRAPDU:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
|
|
||||||
|
moves = list()
|
||||||
|
if firmware.device.startswith("nano"):
|
||||||
|
if firmware.device == "nanos":
|
||||||
|
moves += [NavInsID.RIGHT_CLICK]
|
||||||
|
moves += [NavInsID.BOTH_CLICK]
|
||||||
|
else:
|
||||||
|
moves += [NavInsID.USE_CASE_CHOICE_CONFIRM]
|
||||||
|
navigator.navigate_and_compare(ROOT_SNAPSHOT_PATH,
|
||||||
|
"blind-signed_approval",
|
||||||
|
moves)
|
||||||
@@ -11,12 +11,9 @@ import ledger_app_clients.ethereum.response_parser as ResponseParser
|
|||||||
from ledger_app_clients.ethereum.utils import get_selector_from_data, recover_transaction
|
from ledger_app_clients.ethereum.utils import get_selector_from_data, recover_transaction
|
||||||
from web3 import Web3
|
from web3 import Web3
|
||||||
import json
|
import json
|
||||||
import os
|
from constants import ROOT_SNAPSHOT_PATH, ABIS_FOLDER
|
||||||
from constants import ROOT_SNAPSHOT_PATH
|
|
||||||
|
|
||||||
|
|
||||||
ABIS_FOLDER = "%s/abis" % (os.path.dirname(__file__))
|
|
||||||
|
|
||||||
BIP32_PATH = "m/44'/60'/0'/0/0"
|
BIP32_PATH = "m/44'/60'/0'/0/0"
|
||||||
NONCE = 21
|
NONCE = 21
|
||||||
GAS_PRICE = 13
|
GAS_PRICE = 13
|
||||||
|
|||||||