Port 'test_erc20information' from 'speculos' to 'ragger'
This commit is contained in:
26
tests/ragger/test_erc20information.py
Normal file
26
tests/ragger/test_erc20information.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import pytest
|
||||
from ledger_app_clients.ethereum.client import EthAppClient, StatusWord
|
||||
|
||||
from ragger.error import ExceptionRAPDU
|
||||
from ragger.backend import BackendInterface
|
||||
|
||||
|
||||
def test_provide_erc20_token(backend: BackendInterface):
|
||||
|
||||
app_client = EthAppClient(backend)
|
||||
|
||||
addr = bytes.fromhex("e41d2489571d322189246dafa5ebde1f4699f498")
|
||||
response = app_client.provide_token_metadata("ZRX", addr, 18, 1)
|
||||
assert response.status == StatusWord.OK
|
||||
|
||||
|
||||
def test_provide_erc20_token_error(backend: BackendInterface):
|
||||
|
||||
app_client = EthAppClient(backend)
|
||||
|
||||
addr = bytes.fromhex("e41d2489571d322189246dafa5ebde1f4699f498")
|
||||
sign = bytes.fromhex("deadbeef")
|
||||
with pytest.raises(ExceptionRAPDU) as e:
|
||||
app_client.provide_token_metadata("ZRX", addr, 18, 1, sign)
|
||||
|
||||
assert e.value.status == StatusWord.INVALID_DATA
|
||||
@@ -1,31 +0,0 @@
|
||||
import pytest
|
||||
from ethereum_client.plugin import ERC20Information
|
||||
import ethereum_client
|
||||
|
||||
def test_provide_erc20_token(cmd):
|
||||
erc20_info = ERC20Information(
|
||||
erc20_ticker="5a5258",
|
||||
addr="0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
nb_decimals=18,
|
||||
chainID=1,
|
||||
sign="304402200ae8634c22762a8ba41d2acb1e068dcce947337c6dd984f13b820d396176952302203306a49d8a6c35b11a61088e1570b3928ca3a0db6bd36f577b5ef87628561ff7"
|
||||
)
|
||||
|
||||
# Test if return 9000
|
||||
try:
|
||||
cmd.provide_erc20_token_information(info=erc20_info)
|
||||
except:
|
||||
raise
|
||||
|
||||
def test_provide_erc20_token_error(cmd):
|
||||
erc20_info = ERC20Information(
|
||||
erc20_ticker="5a5258",
|
||||
addr="0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
nb_decimals=18,
|
||||
chainID=1,
|
||||
sign="deadbeef"
|
||||
)
|
||||
|
||||
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
|
||||
cmd.provide_erc20_token_information(info=erc20_info)
|
||||
assert error.args[0] == '0x6a80'
|
||||
Reference in New Issue
Block a user