feat: test batch erc1155

This commit is contained in:
Coline
2022-06-29 16:45:24 +02:00
parent 23739af93c
commit 78e66aea44
9 changed files with 88 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

View File

@@ -117,4 +117,91 @@ def test_transfer_erc1155_without_set_plugin(cmd):
pass
except ethereum_client.exception.errors.DenyError as error:
assert error.args[0] == '0x6985'
assert error.args[0] == '0x6985'
# ===========================
# Batch
# ===========================
SIGN_FIRST_BATCH = apdu_as_string("e004000096058000002c8000003c800000000000000000000000f9020b0e850d8cfd86008301617d94495f947276749ce646f68ac8c248420045cb7b5e80b901e42eb2c2d60000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596c00000000000000000000000000000000000000000000")
SIGN_MORE_1_BATCH = apdu_as_string("e004800096000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000003abf06640f8ca8fc5e0ed471b10befcdf65a33e430000000000006a0000000064def9d99ff495856496c028c0")
SIGN_MORE_2_BATCH = apdu_as_string("e00480009689732473fcd0bbbe000000000000a30000000001abf06640f8ca8fc5e0ed471b10befcdf65a33e430000000000006a00000000640000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000010000")
SIGN_MORE_3_BATCH = apdu_as_string("e00480006100000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000018080")
PLUGIN_BATCH = Plugin(
type=1,
version=1,
name="ERC1155",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
selector=0x2eb2c2d6,
chainID=1,
keyID=0,
algorithm=1,
sign=b"\x30\x45\x02\x21\x00\x87\xb3\x5c\xef\xc5\x3f\xd9\x4e\x25\x40\x49\x33\xeb\x0d\x5f\xf0\x8f\x20\xba\x65\x5d\x18\x1d\xe3\xb2\x4f\xf0\x09\x9d\xc3\x31\x7f\x02\x20\x4a\x21\x6a\xa9\xe0\xb8\x4b\xef\x6e\x20\xfc\xb0\x36\xbd\x49\x64\x7b\xf0\xca\xb6\x67\x32\xb9\x9b\x49\xec\x27\x7f\xfb\x68\x2a\xa1",
)
PROVIDE_NFT_INFORMATION_BATCH = Plugin(
type=1,
version=1,
name="OpenSea Shared Storefront",
addr="0x495f947276749ce646f68ac8c248420045cb7b5e",
chainID=1,
keyID=0,
algorithm=1,
sign=b"\x30\x45\x02\x21\x00\xc7\x4c\xd6\x13\xa2\x7a\x9f\x48\x87\x21\x0f\x5a\x3a\x0e\x12\x74\x5e\x1b\xa0\xab\x3a\x0d\x28\x4c\xb6\x48\x5d\x89\xc3\xcc\xe4\xe6\x02\x20\x5a\x13\xe6\x2a\x91\x16\x49\x85\xcf\x58\xa8\x38\xf8\xf5\x31\xc0\xb9\x1b\x98\x0d\x20\x6a\x5b\xa8\xdf\x28\x27\x00\x23\xef\x93\xa3",
)
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')
pass
response: bytes = result[0]
v, r, s = parse_sign_response(response)
assert v == 0x25 # 37
assert r.hex() == "ee17b599747775a5056c6f654b476bdec0f3fea2c03a4754a31f736e61015082"
assert s.hex() == "3d76f264da438a5bda69389e59c08216e98ddb6649323bd5055980ae31f79c1c"