Move test eip2930 to test_sign
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
from web3 import Web3
|
||||
|
||||
from client.client import EthAppClient
|
||||
import client.response_parser as ResponseParser
|
||||
from client.utils import recover_transaction
|
||||
|
||||
from ragger.backend import BackendInterface
|
||||
from ragger.firmware import Firmware
|
||||
from ragger.navigator import Navigator, NavInsID
|
||||
|
||||
from constants import ROOT_SNAPSHOT_PATH
|
||||
|
||||
|
||||
BIP32_PATH = "m/44'/60'/0'/0/0"
|
||||
NONCE = 21
|
||||
GAS_PRICE = 5
|
||||
GAS_LIMIT = 21000
|
||||
ADDR = bytes.fromhex("b2bb2b958afa2e96dab3f3ce7162b87daea39017")
|
||||
AMOUNT = 0.01
|
||||
CHAIN_ID = 3
|
||||
|
||||
|
||||
def test_sign_eip_2930(firmware: Firmware,
|
||||
backend: BackendInterface,
|
||||
navigator: Navigator,
|
||||
test_name: str):
|
||||
|
||||
tx_params = {
|
||||
"nonce": NONCE,
|
||||
"gasPrice": Web3.to_wei(GAS_PRICE, "gwei"),
|
||||
"gas": GAS_LIMIT,
|
||||
"to": ADDR,
|
||||
"value": Web3.to_wei(AMOUNT, "ether"),
|
||||
"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
|
||||
@@ -17,11 +17,13 @@ CHAIN_ID = 1
|
||||
ADDR = bytes.fromhex("0011223344556677889900112233445566778899")
|
||||
ADDR2 = bytes.fromhex("5a321744667052affa8386ed49e00ef223cbffc3")
|
||||
ADDR3 = bytes.fromhex("dac17f958d2ee523a2206206994597c13d831ec7")
|
||||
ADDR4 = bytes.fromhex("b2bb2b958afa2e96dab3f3ce7162b87daea39017")
|
||||
BIP32_PATH = "m/44'/60'/0'/0/0"
|
||||
BIP32_PATH2 = "m/44'/60'/1'/0/0"
|
||||
NONCE = 21
|
||||
NONCE2 = 68
|
||||
GAS_PRICE = 13
|
||||
GAS_PRICE2 = 5
|
||||
GAS_LIMIT = 21000
|
||||
AMOUNT = 1.22
|
||||
|
||||
@@ -144,7 +146,7 @@ def test_legacy_send_bsc(firmware: Firmware,
|
||||
test_name: str):
|
||||
tx_params: dict = {
|
||||
"nonce": 1,
|
||||
"gasPrice": Web3.to_wei(5, 'gwei'),
|
||||
"gasPrice": Web3.to_wei(GAS_PRICE2, 'gwei'),
|
||||
"gas": GAS_LIMIT,
|
||||
"to": ADDR2,
|
||||
"value": 31415926913374232,
|
||||
@@ -416,3 +418,27 @@ def test_sign_blind_error_disabled(backend: BackendInterface):
|
||||
}
|
||||
|
||||
common_fail(backend, tx_params, StatusWord.INVALID_DATA, BIP32_PATH2)
|
||||
|
||||
|
||||
def test_sign_eip_2930(firmware: Firmware,
|
||||
backend: BackendInterface,
|
||||
navigator: Navigator,
|
||||
test_name: str):
|
||||
|
||||
tx_params = {
|
||||
"nonce": NONCE,
|
||||
"gasPrice": Web3.to_wei(GAS_PRICE2, "gwei"),
|
||||
"gas": GAS_LIMIT,
|
||||
"to": ADDR4,
|
||||
"value": Web3.to_wei(0.01, "ether"),
|
||||
"chainId": 3,
|
||||
"accessList": [
|
||||
{
|
||||
"address": "0x0000000000000000000000000000000000000001",
|
||||
"storageKeys": [
|
||||
"0x0100000000000000000000000000000000000000000000000000000000000000"
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
common(firmware, backend, navigator, tx_params, test_name)
|
||||
|
||||
Reference in New Issue
Block a user