diff --git a/tests/speculos/conftest.py b/tests/speculos/conftest.py index cc0175f..b10f7a6 100644 --- a/tests/speculos/conftest.py +++ b/tests/speculos/conftest.py @@ -1,5 +1,4 @@ from pathlib import Path - import pytest from speculos.client import SpeculosClient diff --git a/tests/speculos/ethereum_client/ethereum_cmd_builder.py b/tests/speculos/ethereum_client/ethereum_cmd_builder.py index 594e054..e0e8f0a 100644 --- a/tests/speculos/ethereum_client/ethereum_cmd_builder.py +++ b/tests/speculos/ethereum_client/ethereum_cmd_builder.py @@ -3,7 +3,6 @@ import logging import struct from typing import List, Tuple, Union, Iterator, cast - from ethereum_client.transaction import PersonalTransaction, Transaction from ethereum_client.plugin import Plugin from ethereum_client.utils import bip32_path_from_string diff --git a/tests/speculos/ethereum_client/plugin.py b/tests/speculos/ethereum_client/plugin.py index 2c4f4e2..d6bdc58 100644 --- a/tests/speculos/ethereum_client/plugin.py +++ b/tests/speculos/ethereum_client/plugin.py @@ -1,7 +1,6 @@ from typing import Union -from ethereum_client.utils import (read, read_uint, read_varint, - write_varint, UINT64_MAX) +from ethereum_client.utils import write_varint class Plugin: """Plugin class diff --git a/tests/speculos/ethereum_client/transaction.py b/tests/speculos/ethereum_client/transaction.py index f20102f..08ff529 100644 --- a/tests/speculos/ethereum_client/transaction.py +++ b/tests/speculos/ethereum_client/transaction.py @@ -1,8 +1,6 @@ -from io import BytesIO from typing import Union -from ethereum_client.utils import (read, read_uint, read_varint, - write_varint, UINT64_MAX) +from ethereum_client.utils import write_varint, UINT64_MAX class TransactionError(Exception): diff --git a/tests/speculos/ethereum_client/utils.py b/tests/speculos/ethereum_client/utils.py index e318b7f..78e690c 100644 --- a/tests/speculos/ethereum_client/utils.py +++ b/tests/speculos/ethereum_client/utils.py @@ -1,11 +1,9 @@ from io import BytesIO from typing import List, Optional, Literal, Tuple +import PIL.Image as Image import speculos.client -import PIL.Image as Image -import io - UINT64_MAX: int = 18446744073709551615 UINT32_MAX: int = 4294967295 UINT16_MAX: int = 65535 @@ -26,13 +24,13 @@ def apdu_as_string(apdu: str) -> bytes: def save_screenshot(cmd, path: str): screenshot = cmd.client.get_screenshot() - img = Image.open(io.BytesIO(screenshot)) + img = Image.open(BytesIO(screenshot)) img.save(path) def compare_screenshot(cmd, path: str): screenshot = cmd.client.get_screenshot() - assert speculos.client.screenshot_equal(path, io.BytesIO(screenshot)) + assert speculos.client.screenshot_equal(path, BytesIO(screenshot)) def parse_sign_response(response : bytes) -> Tuple[bytes, bytes, bytes]: diff --git a/tests/speculos/test_eip1559.py b/tests/speculos/test_eip1559.py index 3898c8f..dd3d8d9 100644 --- a/tests/speculos/test_eip1559.py +++ b/tests/speculos/test_eip1559.py @@ -1,7 +1,6 @@ from time import sleep -from ethereum_client.utils import UINT64_MAX, apdu_as_string, compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response -from ethereum_client.plugin import Plugin -import ethereum_client + +from ethereum_client.utils import apdu_as_string, compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response def test_sign_eip_1559(cmd): result: list = [] diff --git a/tests/speculos/test_eip191.py b/tests/speculos/test_eip191.py index 579ba7e..822d14d 100644 --- a/tests/speculos/test_eip191.py +++ b/tests/speculos/test_eip191.py @@ -1,7 +1,7 @@ from time import sleep -import ethereum_client -from ethereum_client.utils import UINT64_MAX, apdu_as_string, compare_screenshot, compare_screenshot, parse_sign_response, save_screenshot, PATH_IMG +import ethereum_client +from ethereum_client.utils import apdu_as_string, compare_screenshot, compare_screenshot, parse_sign_response, save_screenshot, PATH_IMG from ethereum_client.transaction import PersonalTransaction def test_personal_sign_metamask(cmd): diff --git a/tests/speculos/test_erc1155.py b/tests/speculos/test_erc1155.py index 5e13def..44463a5 100644 --- a/tests/speculos/test_erc1155.py +++ b/tests/speculos/test_erc1155.py @@ -1,7 +1,8 @@ from time import sleep -from ethereum_client.utils import UINT64_MAX, apdu_as_string, compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response -from ethereum_client.plugin import Plugin + import ethereum_client +from ethereum_client.utils import apdu_as_string, compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response +from ethereum_client.plugin import Plugin SIGN_FIRST = apdu_as_string("e004000096058000002c8000003c800000000000000000000000f901090b8520b673dd0082bcb394495f947276749ce646f68ac8c248420045cb7b5e80b8e4f242432a0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596cabf06640f8ca8fc5e0ed471b10befcdf65a33e4300000000") SIGN_MORE = apdu_as_string("e00480008b00006a0000000064000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000018080") diff --git a/tests/speculos/test_erc721.py b/tests/speculos/test_erc721.py index 9dd9add..f2ac564 100644 --- a/tests/speculos/test_erc721.py +++ b/tests/speculos/test_erc721.py @@ -1,7 +1,8 @@ from time import sleep -from ethereum_client.utils import UINT64_MAX, apdu_as_string, compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response -from ethereum_client.plugin import Plugin + import ethereum_client +from ethereum_client.utils import apdu_as_string, compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response +from ethereum_client.plugin import Plugin SIGN_FIRST = apdu_as_string("e004000096058000002c8000003c800000000000000000000000f88a0a852c3ce1ec008301f5679460f80121c31a0d46b5279700f9df786054aa5ee580b86442842e0e0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596c000000000000000000000000000000000000000000000000") SIGN_MORE = apdu_as_string("e00480000b0000000000112999018080") diff --git a/tests/speculos/test_pubkey_cmd.py b/tests/speculos/test_pubkey_cmd.py index d059ceb..8e6bfca 100644 --- a/tests/speculos/test_pubkey_cmd.py +++ b/tests/speculos/test_pubkey_cmd.py @@ -1,12 +1,7 @@ - -from cgitb import reset -from pickle import TRUE -from typing import Tuple - from time import sleep import ethereum_client -from ethereum_client.utils import UINT64_MAX, compare_screenshot, save_screenshot, PATH_IMG +from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG def test_get_public_key(cmd): diff --git a/tests/speculos/test_sign_cmd.py b/tests/speculos/test_sign_cmd.py index 0590c2b..2076459 100644 --- a/tests/speculos/test_sign_cmd.py +++ b/tests/speculos/test_sign_cmd.py @@ -1,8 +1,7 @@ from time import sleep + import ethereum_client - - -from ethereum_client.utils import UINT64_MAX, compare_screenshot, compare_screenshot, save_screenshot, PATH_IMG +from ethereum_client.utils import compare_screenshot, compare_screenshot, save_screenshot, PATH_IMG from ethereum_client.transaction import Transaction diff --git a/tests/speculos/test_version_cmd.py b/tests/speculos/test_version_cmd.py deleted file mode 100644 index 1ad0133..0000000 --- a/tests/speculos/test_version_cmd.py +++ /dev/null @@ -1,10 +0,0 @@ -#from warnings import catch_warnings -# -#import boilerplate_client -# -# -#def test_version(cmd): -# try: -# cmd.get_version() -# except boilerplate_client.exception.errors.InsNotSupportedError as error: -# assert error.args[0] == '0x6d00' \ No newline at end of file