feat: erc1155 tests with screen

This commit is contained in:
Coline
2022-06-28 13:16:57 +02:00
parent 3491bd5fa2
commit f9673dfca7
22 changed files with 171 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

View File

@@ -0,0 +1,160 @@
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
SIGN_FIRST = apdu_as_string("e004000096058000002c8000003c800000000000000000000000f901090b8520b673dd0082bcb394495f947276749ce646f68ac8c248420045cb7b5e80b8e4f242432a0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596cabf06640f8ca8fc5e0ed471b10befcdf65a33e4300000000")
SIGN_MORE = apdu_as_string("e00480008b00006a0000000064000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000018080")
PLUGIN = Plugin(
type=1,
version=1,
name="ERC1155",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
selector=0xf242432a,
chainID=1,
keyID=0,
algorithm=1,
sign=b"\x30\x45\x02\x21\x00\xec\x43\x77\xd1\x7e\x8d\x98\xd4\x24\xbf\x16\xb2\x9c\x69\x1b\xc1\xa0\x10\x82\x5f\xb5\xb8\xa3\x5d\xe0\x26\x8a\x9d\xc2\x2e\xab\x24\x02\x20\x67\x01\xb0\x16\xfe\x67\x18\xbf\x51\x9d\x18\xcc\x12\xe9\x83\x8e\x9e\xf8\x98\xcc\x4c\x14\x30\x17\x83\x90\x23\xc3\x26\x0b\x2d\x74",
)
PROVIDE_NFT_INFORMATION = Plugin(
type=1,
version=1,
name="OpenSea Collection",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
chainID=1,
keyID=0,
algorithm=1,
sign=b"\x30\x45\x02\x21\x00\x83\xe3\x57\xa8\x28\xf1\x3d\x57\x4b\x12\x96\x21\x4a\x37\x49\xc1\x94\xab\x1d\xf1\xf8\xa2\x43\x65\x5c\x05\x3b\x1c\x72\xf9\x1e\x0c\x02\x20\x1e\xd9\x3c\xfa\xc7\xe8\x77\x59\x44\x5c\x4d\xa2\xe4\xbf\xd6\xe1\xcf\x04\x05\xea\x37\xc7\x29\x3b\xc9\x65\x94\x8f\x51\xbe\xf5\xcc",
)
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 Transfert
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":
cmd.set_plugin(plugin=PLUGIN)
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_without_nft_provide_info/00000.png")
cmd.client.press_and_release('right')
# NFT Transfert
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/00001.png")
cmd.client.press_and_release('right')
# To
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/00002.png")
cmd.client.press_and_release('right')
# Collection Name
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/00003.png")
cmd.client.press_and_release('right')
# NFT Address
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/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_without_nft_provide_info/00005.png")
cmd.client.press_and_release('right')
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/00006.png")
cmd.client.press_and_release('right')
# Quantity
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/00007.png")
cmd.client.press_and_release('right')
# Max Fees
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/00008.png")
cmd.client.press_and_release('right')
# Accept and send
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155_without_nft_provide_info/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_set_plugin(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
try:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
assert error.args[0] == '0x6a80'

View File

@@ -7,16 +7,16 @@ SIGN_FIRST = apdu_as_string("e004000096058000002c8000003c80000000000000000000000
SIGN_MORE = apdu_as_string("e00480000b0000000000112999018080")
PLUGIN = Plugin(
type=1,
version=1,
name="ERC721",
addr="0x60f80121c31a0d46b5279700f9df786054aa5ee5",
selector=0x42842e0e,
chainID=1,
keyID=0,
algorithm=1,
sign=b"\x30\x45\x02\x20\x2e\x22\x82\xd7\xd3\xea\x71\x4d\xa2\x83\x01\x0f\x51\x7a\xf4\x69\xe1\xd5\x96\x54\xaa\xee\x0f\xc4\x38\xf0\x17\xaa\x55\x7e\xae\xa5\x02\x21\x00\x8b\x36\x96\x79\x38\x10\x65\xbb\xe0\x11\x35\x72\x3a\x4f\x9a\xdb\x22\x92\x95\x01\x7d\x37\xc4\xd3\x01\x38\xb9\x0a\x51\xcf\x6a\xb6",
)
type=1,
version=1,
name="ERC721",
addr="0x60f80121c31a0d46b5279700f9df786054aa5ee5",
selector=0x42842e0e,
chainID=1,
keyID=0,
algorithm=1,
sign=b"\x30\x45\x02\x20\x2e\x22\x82\xd7\xd3\xea\x71\x4d\xa2\x83\x01\x0f\x51\x7a\xf4\x69\xe1\xd5\x96\x54\xaa\xee\x0f\xc4\x38\xf0\x17\xaa\x55\x7e\xae\xa5\x02\x21\x00\x8b\x36\x96\x79\x38\x10\x65\xbb\xe0\x11\x35\x72\x3a\x4f\x9a\xdb\x22\x92\x95\x01\x7d\x37\xc4\xd3\x01\x38\xb9\x0a\x51\xcf\x6a\xb6",
)
PROVIDE_NFT_INFORMATION = Plugin(
type=1,
@@ -27,7 +27,7 @@ PROVIDE_NFT_INFORMATION = Plugin(
keyID=0,
algorithm=1,
sign=b"\x30\x45\x02\x20\x25\x69\x69\x86\xef\x5f\x0e\xe2\xf7\x2d\x9c\x6e\x41\xd7\xe2\xbf\x2e\x4f\x06\x37\x3a\xb2\x6d\x73\xeb\xe3\x26\xc7\xfd\x4c\x7a\x66\x02\x21\x00\x84\xf6\xb0\x64\xd8\x75\x0a\xe6\x8e\xd5\xdd\x01\x22\x96\xf3\x70\x30\x39\x0e\xc0\x6f\xf5\x34\xc5\xda\x6f\x0f\x4a\x44\x60\xaf\x33",
)
)
def test_transfer_erc721(cmd):
result: list = []