From 1ed560f1f50bcf17c19ae22c764acd78d771001c Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Fri, 29 Mar 2024 10:38:31 +0100 Subject: [PATCH] Port 'test_erc20information' from 'speculos' to 'ragger' --- tests/ragger/test_erc20information.py | 26 +++++++++++++++++++++ tests/speculos/test_erc20information.py | 31 ------------------------- 2 files changed, 26 insertions(+), 31 deletions(-) create mode 100644 tests/ragger/test_erc20information.py delete mode 100644 tests/speculos/test_erc20information.py diff --git a/tests/ragger/test_erc20information.py b/tests/ragger/test_erc20information.py new file mode 100644 index 0000000..e8ac552 --- /dev/null +++ b/tests/ragger/test_erc20information.py @@ -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 diff --git a/tests/speculos/test_erc20information.py b/tests/speculos/test_erc20information.py deleted file mode 100644 index de01c63..0000000 --- a/tests/speculos/test_erc20information.py +++ /dev/null @@ -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'