Remove useless 'speculos' tests eip712, erc721, erc1155

This commit is contained in:
Charles-Edouard de la Vergne
2024-03-28 17:30:16 +01:00
parent 5d5b68f56b
commit ed6d6b222e
64 changed files with 0 additions and 502 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

View File

@@ -1,179 +0,0 @@
from time import sleep
import pytest
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response
from ethereum_client.transaction import EIP712
import ethereum_client
def test_sign_eip_712_hashed_msg(cmd):
result: list = []
bip32_path="44'/60'/0'/0'/0"
transaction = EIP712(
domain_hash="c24f499b8c957196651b13edd64aaccc3980009674b2aea0966c8a56ba81278e",
msg_hash="9d96be8a7cca396e711a3ba356bd9878df02a726d753ddb6cda3c507d888bc77"
)
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
if cmd.model == "nanos":
# Sign typed message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00000.png")
cmd.client.press_and_release('right')
# Domain hash 1/4, 2/4, 3/4, 4/4
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00001.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00002.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00003.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00004.png")
cmd.client.press_and_release('right')
# Message hash 1/4, 2/4, 3/4, 4/4
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00005.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00006.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00007.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00008.png")
cmd.client.press_and_release('right')
# Sign message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00009.png")
cmd.client.press_and_release('both')
if cmd.model == "nanox" or cmd.model == "nanosp":
# Sign typed message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00000.png")
cmd.client.press_and_release('right')
# Domain hash 1/2, 2/2
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00001.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00002.png")
cmd.client.press_and_release('right')
# Message hash 1/2, 2/2
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00003.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00004.png")
cmd.client.press_and_release('right')
# Sign message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg/00005.png")
cmd.client.press_and_release('both')
v, r, s = result
assert v == 0x1B #27
assert r.hex() == "b1cf3dd6f2902ae9b181e158cc07f6ee6e6c456360b18842ece0b947dec89f07"
assert s.hex() == "5372a9b1a495b76ccd75347b6f591867859fb73aa05a546b79c81073ddff5e8a"
def test_sign_eip_712_hashed_msg_reject(cmd):
result: list = []
bip32_path="44'/60'/0'/0'/0"
transaction = EIP712(
domain_hash="c24f499b8c957196651b13edd64aaccc3980009674b2aea0966c8a56ba81278e",
msg_hash="9d96be8a7cca396e711a3ba356bd9878df02a726d753ddb6cda3c507d888bc77"
)
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
if cmd.model == "nanos":
# Sign typed message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00000.png")
cmd.client.press_and_release('right')
# Domain hash 1/4, 2/4, 3/4, 4/4
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00001.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00002.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00003.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00004.png")
cmd.client.press_and_release('right')
# Message hash 1/4, 2/4, 3/4, 4/4
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00005.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00006.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00007.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00008.png")
cmd.client.press_and_release('right')
# Sign message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00009.png")
cmd.client.press_and_release('right')
# Cancel signature
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00010.png")
cmd.client.press_and_release('both')
if cmd.model == "nanox" or cmd.model == "nanosp":
# Sign typed message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00000.png")
cmd.client.press_and_release('right')
# Domain hash 1/2, 2/2
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00001.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00002.png")
cmd.client.press_and_release('right')
# Message hash 1/2, 2/2
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00003.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00004.png")
cmd.client.press_and_release('right')
# Sign message
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00005.png")
cmd.client.press_and_release('right')
# Cancel signature
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00006.png")
cmd.client.press_and_release('both')
assert error.args[0] == '0x6985'
def test_sign_eip_712_bad_domain(cmd):
result: list = []
bip32_path="44'/60'/0'/0'/0"
transaction = EIP712(
domain_hash="deadbeef",
msg_hash="9d96be8a7cca396e711a3ba356bd9878df02a726d753ddb6cda3c507d888bc77"
)
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass
assert error.args[0] == '0x6a80'
def test_sign_eip_712_bad_msg(cmd):
result: list = []
bip32_path="44'/60'/0'/0'/0"
transaction = EIP712(
domain_hash="c24f499b8c957196651b13edd64aaccc3980009674b2aea0966c8a56ba81278e",
msg_hash="deadbeef"
)
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass
assert error.args[0] == '0x6a80'

View File

@@ -1,208 +0,0 @@
from time import sleep
import pytest
import ethereum_client
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response
from ethereum_client.plugin import Plugin
SIGN_FIRST = bytes.fromhex("e004000096058000002c8000003c800000000000000000000000f901090b8520b673dd0082bcb394495f947276749ce646f68ac8c248420045cb7b5e80b8e4f242432a0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596cabf06640f8ca8fc5e0ed471b10befcdf65a33e4300000000")
SIGN_MORE = bytes.fromhex("e00480008b00006a0000000064000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000018080")
PLUGIN = Plugin(
type=1,
version=1,
name="ERC1155",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
selector=0xf242432a,
chainID=1,
keyID=0,
algorithm=1,
sign="3045022100ec4377d17e8d98d424bf16b29c691bc1a010825fb5b8a35de0268a9dc22eab2402206701b016fe6718bf519d18cc12e9838e9ef898cc4c143017839023c3260b2d74",
)
PROVIDE_NFT_INFORMATION = Plugin(
type=1,
version=1,
name="OpenSea Collection",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
chainID=1,
keyID=0,
algorithm=1,
sign="304502210083e357a828f13d574b1296214a3749c194ab1df1f8a243655c053b1c72f91e0c02201ed93cfac7e87759445c4da2e4bfd6e1cf0405ea37c7293bc965948f51bef5cc",
)
def test_transfer_erc1155(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
sleep(0.5)
# Review transaction
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00000.png")
cmd.client.press_and_release('right')
# NFT Transfer
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00001.png")
cmd.client.press_and_release('right')
# To
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00002.png")
cmd.client.press_and_release('right')
# Collection Name
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00003.png")
cmd.client.press_and_release('right')
# NFT Address
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00004.png")
cmd.client.press_and_release('right')
# NFT ID 1/2, 2/2
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00005.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00006.png")
cmd.client.press_and_release('right')
# Quantity
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00007.png")
cmd.client.press_and_release('right')
# Max Fees
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00008.png")
cmd.client.press_and_release('right')
# Accept and send
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00009.png")
cmd.client.press_and_release('both')
response: bytes = result[0]
v, r, s = parse_sign_response(response)
assert v == 0x25 # 37
assert r.hex() == "ab3eca1a0b5c66bfe603252037682a024a12f92d799b4d74993a8bf4221bbe7d"
assert s.hex() == "24de0c0598d1d8e5ea99b75fa26105478f45f43b510e504fc1b14f07fe7dda2a"
def test_transfer_erc1155_without_nft_provide_info(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
cmd.set_plugin(plugin=PLUGIN)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
assert error.args[0] == '0x6a80'
def test_transfer_erc1155_without_set_plugin(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
assert error.args[0] == '0x6985'
# ===========================
# Batch
# ===========================
SIGN_FIRST_BATCH = bytes.fromhex("e004000096058000002c8000003c800000000000000000000000f9020b0e850d8cfd86008301617d94495f947276749ce646f68ac8c248420045cb7b5e80b901e42eb2c2d60000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596c00000000000000000000000000000000000000000000")
SIGN_MORE_1_BATCH = bytes.fromhex("e004800096000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000003abf06640f8ca8fc5e0ed471b10befcdf65a33e430000000000006a0000000064def9d99ff495856496c028c0")
SIGN_MORE_2_BATCH = bytes.fromhex("e00480009689732473fcd0bbbe000000000000a30000000001abf06640f8ca8fc5e0ed471b10befcdf65a33e430000000000006a00000000640000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000010000")
SIGN_MORE_3_BATCH = bytes.fromhex("e00480006100000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000018080")
PLUGIN_BATCH = Plugin(
type=1,
version=1,
name="ERC1155",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
selector=0x2eb2c2d6,
chainID=1,
keyID=0,
algorithm=1,
sign="304502210087b35cefc53fd94e25404933eb0d5ff08f20ba655d181de3b24ff0099dc3317f02204a216aa9e0b84bef6e20fcb036bd49647bf0cab66732b99b49ec277ffb682aa1",
)
PROVIDE_NFT_INFORMATION_BATCH = Plugin(
type=1,
version=1,
name="OpenSea Shared Storefront",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
chainID=1,
keyID=0,
algorithm=1,
sign="3045022100c74cd613a27a9f4887210f5a3a0e12745e1ba0ab3a0d284cb6485d89c3cce4e602205a13e62a91164985cf58a838f8f531c0b91b980d206a5ba8df28270023ef93a3",
)
def test_transfer_batch_erc1155(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN_BATCH)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION_BATCH)
cmd.send_apdu(SIGN_FIRST_BATCH)
cmd.send_apdu(SIGN_MORE_1_BATCH)
cmd.send_apdu(SIGN_MORE_2_BATCH)
with cmd.send_apdu_context(SIGN_MORE_3_BATCH, result) as ex:
sleep(0.5)
# Review transaction
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00000.png")
cmd.client.press_and_release('right')
# NFT Batch Transfer
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00001.png")
cmd.client.press_and_release('right')
# To
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00002.png")
cmd.client.press_and_release('right')
# Collection Name
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00003.png")
cmd.client.press_and_release('right')
# NFT Address
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00004.png")
cmd.client.press_and_release('right')
# Total Quantity
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00005.png")
cmd.client.press_and_release('right')
# Max Fees
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00006.png")
cmd.client.press_and_release('right')
# Accept and send
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/test_transfer_batch_erc1155/00007.png")
cmd.client.press_and_release('both')
response: bytes = result[0]
v, r, s = parse_sign_response(response)
assert v == 0x25 # 37
assert r.hex() == "ee17b599747775a5056c6f654b476bdec0f3fea2c03a4754a31f736e61015082"
assert s.hex() == "3d76f264da438a5bda69389e59c08216e98ddb6649323bd5055980ae31f79c1c"

View File

@@ -1,115 +0,0 @@
from time import sleep
import pytest
import ethereum_client
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response
from ethereum_client.plugin import Plugin
SIGN_FIRST = bytes.fromhex("e004000096058000002c8000003c800000000000000000000000f88a0a852c3ce1ec008301f5679460f80121c31a0d46b5279700f9df786054aa5ee580b86442842e0e0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596c000000000000000000000000000000000000000000000000")
SIGN_MORE = bytes.fromhex("e00480000b0000000000112999018080")
PLUGIN = Plugin(
type=1,
version=1,
name="ERC721",
addr="0x60f80121c31a0d46b5279700f9df786054aa5ee5",
selector=0x42842e0e,
chainID=1,
keyID=0,
algorithm=1,
sign="304502202e2282d7d3ea714da283010f517af469e1d59654aaee0fc438f017aa557eaea50221008b369679381065bbe01135723a4f9adb229295017d37c4d30138b90a51cf6ab6",
)
PROVIDE_NFT_INFORMATION = Plugin(
type=1,
version=1,
name="Rarible",
addr="0x60f80121c31a0d46b5279700f9df786054aa5ee5",
chainID=1,
keyID=0,
algorithm=1,
sign="3045022025696986ef5f0ee2f72d9c6e41d7e2bf2e4f06373ab26d73ebe326c7fd4c7a6602210084f6b064d8750ae68ed5dd012296f37030390ec06ff534c5da6f0f4a4460af33",
)
def test_transfer_erc721(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
sleep(0.5)
# Review transaction
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00000.png")
cmd.client.press_and_release('right')
# NFT Transfer
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00001.png")
cmd.client.press_and_release('right')
# To
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00002.png")
cmd.client.press_and_release('right')
# Collection Name
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00003.png")
cmd.client.press_and_release('right')
# NFT Address
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00004.png")
cmd.client.press_and_release('right')
# NFT ID
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00005.png")
cmd.client.press_and_release('right')
# Max Fees
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00006.png")
cmd.client.press_and_release('right')
# Accept and send
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00007.png")
cmd.client.press_and_release('both')
response: bytes = result[0]
v, r, s = parse_sign_response(response)
assert v == 0x25 # 37
assert r.hex() == "68ba082523584adbfc31d36d68b51d6f209ce0838215026bf1802a8f17dcdff4"
assert s.hex() == "7c92908fa05c8bc86507a3d6a1c8b3c2722ee01c836d89a61df60c1ab0b43fff"
def test_transfer_erc721_without_nft_provide_info(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
cmd.set_plugin(plugin=PLUGIN)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
assert error.args[0] == '0x6a80'
def test_transfer_erc721_without_set_plugin(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
assert error.args[0] == '0x6985'