Updated ERC-721 & ERC-1155 tests
|
Before Width: | Height: | Size: 541 B |
|
Before Width: | Height: | Size: 444 B |
|
Before Width: | Height: | Size: 748 B |
|
Before Width: | Height: | Size: 764 B |
|
Before Width: | Height: | Size: 540 B |
|
Before Width: | Height: | Size: 630 B |
|
Before Width: | Height: | Size: 835 B |
|
Before Width: | Height: | Size: 838 B |
|
Before Width: | Height: | Size: 679 B |
|
Before Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 798 B |
|
Before Width: | Height: | Size: 501 B |
|
Before Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 541 B |
|
Before Width: | Height: | Size: 408 B |
|
Before Width: | Height: | Size: 693 B |
|
Before Width: | Height: | Size: 739 B |
|
Before Width: | Height: | Size: 481 B |
|
Before Width: | Height: | Size: 639 B |
|
Before Width: | Height: | Size: 835 B |
|
Before Width: | Height: | Size: 838 B |
|
Before Width: | Height: | Size: 679 B |
|
Before Width: | Height: | Size: 532 B |
|
Before Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 541 B |
|
Before Width: | Height: | Size: 408 B |
|
Before Width: | Height: | Size: 688 B |
|
Before Width: | Height: | Size: 698 B |
|
Before Width: | Height: | Size: 526 B |
|
Before Width: | Height: | Size: 679 B |
|
Before Width: | Height: | Size: 840 B |
|
Before Width: | Height: | Size: 888 B |
|
Before Width: | Height: | Size: 629 B |
|
Before Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 796 B |
|
Before Width: | Height: | Size: 492 B |
|
Before Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 541 B |
|
Before Width: | Height: | Size: 408 B |
|
Before Width: | Height: | Size: 688 B |
|
Before Width: | Height: | Size: 698 B |
|
Before Width: | Height: | Size: 526 B |
|
Before Width: | Height: | Size: 679 B |
|
Before Width: | Height: | Size: 840 B |
|
Before Width: | Height: | Size: 888 B |
|
Before Width: | Height: | Size: 629 B |
|
Before Width: | Height: | Size: 404 B |
|
Before Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 796 B |
|
Before Width: | Height: | Size: 492 B |
|
Before Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 531 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00000.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00001.png
Normal file
|
After Width: | Height: | Size: 380 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00002.png
Normal file
|
After Width: | Height: | Size: 697 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00003.png
Normal file
|
After Width: | Height: | Size: 549 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00004.png
Normal file
|
After Width: | Height: | Size: 828 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00005.png
Normal file
|
After Width: | Height: | Size: 471 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00006.png
Normal file
|
After Width: | Height: | Size: 422 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00007.png
Normal file
|
After Width: | Height: | Size: 472 B |
BIN
tests/snapshots/nanox_erc1155_batch_transfer/00008.png
Normal file
|
After Width: | Height: | Size: 365 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00000.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00001.png
Normal file
|
After Width: | Height: | Size: 338 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00002.png
Normal file
|
After Width: | Height: | Size: 697 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00003.png
Normal file
|
After Width: | Height: | Size: 457 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00004.png
Normal file
|
After Width: | Height: | Size: 828 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00005.png
Normal file
|
After Width: | Height: | Size: 783 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00006.png
Normal file
|
After Width: | Height: | Size: 527 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00007.png
Normal file
|
After Width: | Height: | Size: 294 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00008.png
Normal file
|
After Width: | Height: | Size: 427 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00009.png
Normal file
|
After Width: | Height: | Size: 472 B |
BIN
tests/snapshots/nanox_erc1155_transfer/00010.png
Normal file
|
After Width: | Height: | Size: 365 B |
BIN
tests/snapshots/nanox_erc721_transfer/00000.png
Normal file
|
After Width: | Height: | Size: 414 B |
BIN
tests/snapshots/nanox_erc721_transfer/00001.png
Normal file
|
After Width: | Height: | Size: 338 B |
BIN
tests/snapshots/nanox_erc721_transfer/00002.png
Normal file
|
After Width: | Height: | Size: 697 B |
BIN
tests/snapshots/nanox_erc721_transfer/00003.png
Normal file
|
After Width: | Height: | Size: 402 B |
BIN
tests/snapshots/nanox_erc721_transfer/00004.png
Normal file
|
After Width: | Height: | Size: 770 B |
BIN
tests/snapshots/nanox_erc721_transfer/00005.png
Normal file
|
After Width: | Height: | Size: 363 B |
BIN
tests/snapshots/nanox_erc721_transfer/00006.png
Normal file
|
After Width: | Height: | Size: 421 B |
BIN
tests/snapshots/nanox_erc721_transfer/00007.png
Normal file
|
After Width: | Height: | Size: 472 B |
BIN
tests/snapshots/nanox_erc721_transfer/00008.png
Normal file
|
After Width: | Height: | Size: 365 B |
@@ -1,27 +1,58 @@
|
||||
import "core-js/stable";
|
||||
import "regenerator-runtime/runtime";
|
||||
import { waitForAppScreen, zemu, txFromEtherscan } from './test.fixture';
|
||||
import { TransportStatusError } from "@ledgerhq/errors";
|
||||
import Zemu from '@zondax/zemu';
|
||||
import { waitForAppScreen, zemu, nano_models, apdu_as_string, send_apdu } from './test.fixture';
|
||||
|
||||
// -------------------
|
||||
// TODO: Actually write the tests
|
||||
const model = nano_models[1];
|
||||
|
||||
test.skip('[Nano S] Transfer 1155', zemu("nanos", async (sim, eth) => {
|
||||
test('[Nano ' + model.letter + '] Transfer ERC-1155', zemu(model, async (sim, eth) => {
|
||||
|
||||
const rawTx = ""
|
||||
const serializedTx = txFromEtherscan(rawTx);
|
||||
const set_plugin = apdu_as_string('e01600007401010745524331313535495f947276749ce646f68ac8c248420045cb7b5ef242432a00000000000000010001473045022100ec4377d17e8d98d424bf16b29c691bc1a010825fb5b8a35de0268a9dc22eab2402206701b016fe6718bf519d18cc12e9838e9ef898cc4c143017839023c3260b2d74');
|
||||
const provide_nft_info = apdu_as_string('e01400007b0101124f70656e53656120436f6c6c656374696f6e495f947276749ce646f68ac8c248420045cb7b5e0000000000000001000147304502210083e357a828f13d574b1296214a3749c194ab1df1f8a243655c053b1c72f91e0c02201ed93cfac7e87759445c4da2e4bfd6e1cf0405ea37c7293bc965948f51bef5cc');
|
||||
const sign_first = apdu_as_string('e004000096058000002c8000003c800000000000000000000000f901090b8520b673dd0082bcb394495f947276749ce646f68ac8c248420045cb7b5e80b8e4f242432a0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596cabf06640f8ca8fc5e0ed471b10befcdf65a33e4300000000');
|
||||
const sign_more = apdu_as_string('e00480008b00006a0000000064000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000018080');
|
||||
|
||||
// with ETH need to test
|
||||
// const serializedTx = txFromEtherscan("0x02f901350182022f8459682f0085246ad7eb3182de2994424db67b40b15ed85475c3f29dedf601b6ee75b283424242b8c4f242432a000000000000000000000000dcdb88f3754b2841093d9348a2d02df8cf06314c000000000000000000000000df9fb2eff1f2871caeeb94bf262ffba84efddddc0000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c001a0c4283f86dc852e43e9fd1077b448c63fec76bdeb44dfac977730725e41fa3676a0543b2d2f99f65fb20cd548964eee94b1c1865919f4574c7089d8b95678b667c2");
|
||||
const current_screen = sim.getMainMenuSnapshot();
|
||||
await send_apdu(eth.transport, set_plugin);
|
||||
await send_apdu(eth.transport, provide_nft_info);
|
||||
await send_apdu(eth.transport, sign_first);
|
||||
send_apdu(eth.transport, sign_more);
|
||||
|
||||
const tx = eth.signTransaction(
|
||||
"44'/60'/1'/0/0",
|
||||
serializedTx,
|
||||
);
|
||||
|
||||
await waitForAppScreen(sim);
|
||||
await sim.navigateAndCompareSnapshots('.', 'nanos_erc721_transfer_ethereum', [12, 0]);
|
||||
|
||||
await expect(tx).resolves.toEqual({
|
||||
});
|
||||
await waitForAppScreen(sim, current_screen);
|
||||
// Go to the reject screen
|
||||
await sim.navigateAndCompareSnapshots('.', model.name + '_erc1155_transfer', [10]);
|
||||
// Accepting the transaction somehow takes too long for Zemu and takes the same screenshot
|
||||
// twice, so accept it manually
|
||||
await sim.clickLeft();
|
||||
await sim.clickBoth();
|
||||
// Sleep so it has time to send the response APDU
|
||||
await Zemu.sleep(500);
|
||||
}));
|
||||
|
||||
test('[Nano ' + model.letter + '] Batch transfer ERC-1155', zemu(model, async (sim, eth) => {
|
||||
|
||||
const set_plugin = apdu_as_string('e01600007401010745524331313535495f947276749ce646f68ac8c248420045cb7b5e2eb2c2d60000000000000001000147304502210087b35cefc53fd94e25404933eb0d5ff08f20ba655d181de3b24ff0099dc3317f02204a216aa9e0b84bef6e20fcb036bd49647bf0cab66732b99b49ec277ffb682aa1');
|
||||
const provide_nft_info = apdu_as_string('e0140000820101194f70656e536561205368617265642053746f726566726f6e74495f947276749ce646f68ac8c248420045cb7b5e00000000000000010001473045022100c74cd613a27a9f4887210f5a3a0e12745e1ba0ab3a0d284cb6485d89c3cce4e602205a13e62a91164985cf58a838f8f531c0b91b980d206a5ba8df28270023ef93a3');
|
||||
const sign_first = apdu_as_string('e004000096058000002c8000003c800000000000000000000000f9020b0e850d8cfd86008301617d94495f947276749ce646f68ac8c248420045cb7b5e80b901e42eb2c2d60000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596c00000000000000000000000000000000000000000000');
|
||||
const sign_more_1 = apdu_as_string('e004800096000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000003abf06640f8ca8fc5e0ed471b10befcdf65a33e430000000000006a0000000064def9d99ff495856496c028c0');
|
||||
const sign_more_2 = apdu_as_string('e00480009689732473fcd0bbbe000000000000a30000000001abf06640f8ca8fc5e0ed471b10befcdf65a33e430000000000006a00000000640000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000010000');
|
||||
const sign_more_3 = apdu_as_string('e00480006100000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000018080');
|
||||
|
||||
const current_screen = sim.getMainMenuSnapshot();
|
||||
await send_apdu(eth.transport, set_plugin);
|
||||
await send_apdu(eth.transport, provide_nft_info);
|
||||
await send_apdu(eth.transport, sign_first);
|
||||
await send_apdu(eth.transport, sign_more_1);
|
||||
await send_apdu(eth.transport, sign_more_2);
|
||||
send_apdu(eth.transport, sign_more_3);
|
||||
|
||||
await waitForAppScreen(sim, current_screen);
|
||||
// Go to the reject screen
|
||||
await sim.navigateAndCompareSnapshots('.', model.name + '_erc1155_batch_transfer', [8]);
|
||||
// Accepting the transaction somehow takes too long for Zemu and takes the same screenshot
|
||||
// twice, so accept it manually
|
||||
await sim.clickLeft();
|
||||
await sim.clickBoth();
|
||||
// Sleep so it has time to send the response APDU
|
||||
await Zemu.sleep(500);
|
||||
}));
|
||||
|
||||
@@ -1,130 +1,30 @@
|
||||
import "core-js/stable";
|
||||
import "regenerator-runtime/runtime";
|
||||
import { waitForAppScreen, zemu, txFromEtherscan } from './test.fixture';
|
||||
import Zemu from '@zondax/zemu';
|
||||
import { waitForAppScreen, zemu, nano_models, apdu_as_string, send_apdu } from './test.fixture';
|
||||
|
||||
test.skip('[Nano S] Transfer erc721', zemu("nanos", async (sim, eth) => {
|
||||
const model = nano_models[1];
|
||||
|
||||
// https://etherscan.io/tx/0x73cec4fc07de3a24ba42e8756e13b7ddfa9bd449126c37640881195e8ea9e679
|
||||
// Modified to put a bigger token id
|
||||
const rawTx = "0x02f8d101058459682f0085233da9943e8301865b94bd3531da5cf5857e7cfaa92426877b022e612cf880b86423b872dd0000000000000000000000004cc568b73c0dcf8e90db26d7fd3a6cfadca108a3000000000000000000000000d4c9b20950c3eca38fc1f33f54bdf9694e488799ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc080a094c8632fe7277aa8c54cea9d81a15911cfa4970a2bf7356d14d04cc5afbcdab7a013a77b8c79e5d9b2b35edb3c44db3bb41b92f5c463ff126bf19d213b2b9ba8b5"
|
||||
const serializedTx = txFromEtherscan(rawTx);
|
||||
test('[Nano ' + model.letter + '] Transfer ERC-721', zemu(model, async (sim, eth) => {
|
||||
|
||||
const tx = eth.signTransaction(
|
||||
"44'/60'/1'/0/0",
|
||||
serializedTx,
|
||||
);
|
||||
const set_plugin = apdu_as_string('e01600007301010645524337323160f80121c31a0d46b5279700f9df786054aa5ee542842e0e0000000000000001000147304502202e2282d7d3ea714da283010f517af469e1d59654aaee0fc438f017aa557eaea50221008b369679381065bbe01135723a4f9adb229295017d37c4d30138b90a51cf6ab6');
|
||||
const provide_nft_info = apdu_as_string('e01400007001010752617269626c6560f80121c31a0d46b5279700f9df786054aa5ee500000000000000010001473045022025696986ef5f0ee2f72d9c6e41d7e2bf2e4f06373ab26d73ebe326c7fd4c7a6602210084f6b064d8750ae68ed5dd012296f37030390ec06ff534c5da6f0f4a4460af33');
|
||||
const sign_first = apdu_as_string('e004000096058000002c8000003c800000000000000000000000f88a0a852c3ce1ec008301f5679460f80121c31a0d46b5279700f9df786054aa5ee580b86442842e0e0000000000000000000000006cbcd73cd8e8a42844662f0a0e76d7f79afd933d000000000000000000000000c2907efcce4011c491bbeda8a0fa63ba7aab596c000000000000000000000000000000000000000000000000');
|
||||
const sign_more = apdu_as_string('e00480000b0000000000112999018080');
|
||||
|
||||
await waitForAppScreen(sim);
|
||||
await sim.navigateAndCompareSnapshots('.', 'nanos_erc721_transfer', [12, 0]);
|
||||
const current_screen = sim.getMainMenuSnapshot();
|
||||
await send_apdu(eth.transport, set_plugin);
|
||||
await send_apdu(eth.transport, provide_nft_info);
|
||||
await send_apdu(eth.transport, sign_first);
|
||||
send_apdu(eth.transport, sign_more);
|
||||
|
||||
await expect(tx).resolves.toEqual({
|
||||
"r": "59f6a9769cff66eed8be8716c44d39808d1e43f3aa0bb97538e124dba4bc4565",
|
||||
"s": "662990a841c663a165ba9a83e5cc95c03a999b851e0bd6d296aa70a0f7c96c1a",
|
||||
"v": "01",
|
||||
});
|
||||
}));
|
||||
|
||||
test.skip('[Nano S] Transfer erc721 with attached ETH', zemu("nanos", async (sim, eth) => {
|
||||
|
||||
const rawTx = "0x02f8d601058459682f0085233da9943e8301865b94bd3531da5cf5857e7cfaa92426877b022e612cf8854242424242b86423b872dd0000000000000000000000004cc568b73c0dcf8e90db26d7fd3a6cfadca108a3000000000000000000000000d4c9b20950c3eca38fc1f33f54bdf9694e4887990000000000000000000000000000000000000000000000000000000000000f21c080a094c8632fe7277aa8c54cea9d81a15911cfa4970a2bf7356d14d04cc5afbcdab7a013a77b8c79e5d9b2b35edb3c44db3bb41b92f5c463ff126bf19d213b2b9ba8b5"
|
||||
const serializedTx = txFromEtherscan(rawTx);
|
||||
|
||||
|
||||
const tx = eth.signTransaction(
|
||||
"44'/60'/1'/0/0",
|
||||
serializedTx,
|
||||
);
|
||||
|
||||
await waitForAppScreen(sim);
|
||||
await sim.navigateAndCompareSnapshots('.', 'nanos_erc721_transfer_with_eth', [13, 0]);
|
||||
|
||||
await expect(tx).resolves.toEqual({
|
||||
"r": "9c42e10b49f3ee315ab2d5f7ad96f1068c75578734b66504716cc279ead27d47",
|
||||
"s": "45dde78470ad75ffdb27a799b87e4934e2e10e98dbc6f88bc4a9bc19c4de86bc",
|
||||
"v": "00",
|
||||
});
|
||||
}));
|
||||
|
||||
test.skip('[Nano S] set approval for all erc721', zemu("nanos", async (sim, eth) => {
|
||||
|
||||
// https://etherscan.io/tx/0x86b936db53c19fddf26b8d145f165e1c7fdff3c0f8b14b7758a38f0400cfd93f
|
||||
const rawTx = "0x02f8b0010c8459682f00852cfbb00ee682b54294d4e4078ca3495de5b1d4db434bebc5a98619778280b844a22cb4650000000000000000000000002efcb1e8d4472d35356b9747bea8a051eac2e3f50000000000000000000000000000000000000000000000000000000000000001c001a0c5b8c024c15ca1452ce8a13eacfcdc25f1c6f581bb3ce570e82f08f1b792b3aca03be4dba0302ae190618a72eb1202ce3af3e17afd7d8a94345a48cae5cad15541";
|
||||
const serializedTx = txFromEtherscan(rawTx);
|
||||
|
||||
|
||||
const tx = eth.signTransaction(
|
||||
"44'/60'/1'/0/0",
|
||||
serializedTx,
|
||||
);
|
||||
|
||||
await waitForAppScreen(sim);
|
||||
await sim.navigateAndCompareSnapshots('.', 'nanos_erc721_approval_for_all', [12, 0]);
|
||||
|
||||
await expect(tx).resolves.toEqual({
|
||||
"r": "8b6a70a1fe76d8e9b1250531a17eb1e367936732d4dfb9befc81a5031b271dc8",
|
||||
"s": "7658d7151bba0d8504cea2013bead64cb8407dc6be1fca829bb9594b56f679af",
|
||||
"v": "00",
|
||||
});
|
||||
}));
|
||||
|
||||
// NOT DONE
|
||||
test.skip('[Nano S] approval erc721', zemu("nanos", async (sim, eth) => {
|
||||
|
||||
// INCORRECT, need to find / create an approval tx
|
||||
const rawTx = "";
|
||||
const serializedTx = txFromEtherscan(rawTx);
|
||||
|
||||
|
||||
const tx = eth.signTransaction(
|
||||
"44'/60'/1'/0/0",
|
||||
serializedTx,
|
||||
);
|
||||
|
||||
await waitForAppScreen(sim);
|
||||
await sim.navigateAndCompareSnapshots('.', 'nanos_erc721_approval', [12, 0]);
|
||||
|
||||
await expect(tx).resolves.toEqual({
|
||||
});
|
||||
}));
|
||||
|
||||
test.skip('[Nano S] safe transfer erc721', zemu("nanos", async (sim, eth) => {
|
||||
|
||||
// https://etherscan.io/tx/0x1ee6ce9be1c9fe6f030ff124ba8c88a410223c022816547e4b3fedd3a4d2dc1e
|
||||
const rawTx = "0xf8cc82028585077359400083061a8094d4e4078ca3495de5b1d4db434bebc5a98619778280b86442842e0e000000000000000000000000c352b534e8b987e036a93539fd6897f53488e56a0000000000000000000000000a9287d9339c175cd3ea0ad4228f734a9f75ee6200000000000000000000000000000000000000000000000000000000000000621ca08250f4b2c8f28c5e4ef621dba4682990d1faf930c8cb6d032c6e7278e8951d92a03c1e1f6d63ed339041f69f24c6c0968ba26f244f779cb4fa7a468f3ba3d3e06e";
|
||||
const serializedTx = txFromEtherscan(rawTx);
|
||||
|
||||
|
||||
const tx = eth.signTransaction(
|
||||
"44'/60'/1'/0/0",
|
||||
serializedTx,
|
||||
);
|
||||
|
||||
await waitForAppScreen(sim);
|
||||
await sim.navigateAndCompareSnapshots('.', 'nanos_erc721_safe_transfer', [10, 0]);
|
||||
|
||||
await expect(tx).resolves.toEqual({
|
||||
"r": "b936684d5d0e99e09701021fb73ae9403f2ec79414d822d42c5bd1c0a2118f1a",
|
||||
"s": "23e517c6cac998f392d179be2fe7c3225f0e0a165b1af85548da5d6acaa73c4f",
|
||||
"v": "25",
|
||||
});
|
||||
}));
|
||||
|
||||
// NOT DONE
|
||||
test.skip('[Nano S] safe transfer with data erc721', zemu("nanos", async (sim, eth) => {
|
||||
|
||||
// need to find or create a safe transfer with data on etherscan?
|
||||
const rawTx = "";
|
||||
const serializedTx = txFromEtherscan(rawTx);
|
||||
|
||||
|
||||
const tx = eth.signTransaction(
|
||||
"44'/60'/1'/0/0",
|
||||
serializedTx,
|
||||
);
|
||||
|
||||
await waitForAppScreen(sim);
|
||||
await sim.navigateAndCompareSnapshots('.', 'nanos_erc721_safe_transfer_with_data', [12, 0]);
|
||||
|
||||
await expect(tx).resolves.toEqual({
|
||||
});
|
||||
await waitForAppScreen(sim, current_screen);
|
||||
// Go to the reject screen
|
||||
await sim.navigateAndCompareSnapshots('.', model.name + '_erc721_transfer', [8]);
|
||||
// Accepting the transaction somehow takes too long for Zemu and takes the same screenshot
|
||||
// twice, so accept it manually
|
||||
await sim.clickLeft();
|
||||
await sim.clickBoth();
|
||||
// Sleep so it has time to send the response APDU
|
||||
await Zemu.sleep(500);
|
||||
}));
|
||||
|
||||
@@ -4,8 +4,10 @@ import {RLP} from "ethers/lib/utils";
|
||||
|
||||
const transactionUploadDelay = 60000;
|
||||
|
||||
async function waitForAppScreen(sim) {
|
||||
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot(), transactionUploadDelay);
|
||||
async function waitForAppScreen(sim, current_screen = null) {
|
||||
if (current_screen === null) current_screen = sim.getMainMenuSnapshot();
|
||||
|
||||
await sim.waitUntilScreenIsNot(current_screen, transactionUploadDelay);
|
||||
}
|
||||
|
||||
const sim_options_nano = {
|
||||
@@ -30,8 +32,33 @@ const nano_models: DeviceModel[] = [
|
||||
|
||||
const TIMEOUT = 1000000;
|
||||
|
||||
// useful to take an apdu as a hex string and convert its JS representation
|
||||
function apdu_as_string(str) {
|
||||
let buffer = [];
|
||||
|
||||
for (let i = 0; i < str.length; i += 2) {
|
||||
const str_extract = str.substring(i, i + 2);
|
||||
buffer[i / 2] = parseInt(str_extract, 16);
|
||||
}
|
||||
return {
|
||||
cla: buffer[0],
|
||||
ins: buffer[1],
|
||||
p1: buffer[2],
|
||||
p2: buffer[3],
|
||||
data: Buffer.from(buffer.slice(5))
|
||||
};
|
||||
}
|
||||
|
||||
async function send_apdu(ts, apdu) {
|
||||
await ts.send(apdu.cla,
|
||||
apdu.ins,
|
||||
apdu.p1,
|
||||
apdu.p2,
|
||||
apdu.data);
|
||||
}
|
||||
|
||||
// Generates a serializedTransaction from a rawHexTransaction copy pasted from etherscan.
|
||||
function txFromEtherscan(rawTx) {
|
||||
function txFromEtherscan(rawTx) {
|
||||
// Remove 0x prefix
|
||||
rawTx = rawTx.slice(2);
|
||||
|
||||
@@ -89,4 +116,6 @@ module.exports = {
|
||||
nano_models,
|
||||
TIMEOUT,
|
||||
txFromEtherscan,
|
||||
apdu_as_string,
|
||||
send_apdu
|
||||
}
|
||||
|
||||