Add a UI warning when contract data are not enabled in the settings (#193)

* Add a UI warning when contract data are not enabled in the settings

* Update wording "contract data" -> "blind signing" to raise awareness

* Bump version 1.9.5

* remove hardcoded path in helper build script

* Add blind signature test

* Add snapshot-tmp to gitignore

* Remove unused snapshots

* Increase tests timings

* Remove unused snapshots

* Fix and rename compound blind deposit test

* Update Approve and Transfer tests

* Update tests

* Cosmetic changes + disable debug flag

* Update CHANGELOG.md
This commit is contained in:
Jean P
2021-09-28 12:32:06 +02:00
committed by GitHub
parent 9951cc0e46
commit fa355a5d97
196 changed files with 475 additions and 1554 deletions

View File

@@ -1,175 +1,37 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import Eth from "@ledgerhq/hw-app-eth";
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20";
import Zemu from "@zondax/zemu";
import { TransportStatusError } from "@ledgerhq/errors";
import { expect } from "../jest";
import { waitForAppScreen, zemu } from './test.fixture';
const {NANOS_ELF_PATH, NANOX_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT, getTmpPath} = require("generic.js");
test('[Nano S] Approve DAI tokens', zemu("nanos", async (sim, eth) => {
const ORIGINAL_SNAPSHOT_PATH_PREFIX = "snapshots/approve/";
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'F869468506A8B15E0082EBEB946B175474E89094C44DA98B954EEDEAC495271D0F80B844095EA7B30000000000000000000000007D2768DE32B0B80B7A3454C06BDAC94A69DDC7A9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF018080',
);
const ORIGINAL_SNAPSHOT_PATH_NANOS = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanos/";
const ORIGINAL_SNAPSHOT_PATH_NANOX = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanox/";
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_approve_dai_tokens', [7, 0]);
test("Approve DAI tokens nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
await expect(tx).resolves.toEqual({
"r": "92243511396b65a4faa735a5472ea99b3ce0f7f2338eab426206730bc0ddc57f",
"s": "161bc0f861064d840de4f4304cfd19a571017e62df7d8f70cf605c0f025593b6",
"v": "25",
});
}));
let tmpPath = getTmpPath(expect.getState().currentTestName);
test('[Nano X] Approve DAI tokens', zemu("nanox", async (sim, eth) => {
try {
await sim.start(sim_options_nanos);
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'F869468506A8B15E0082EBEB946B175474E89094C44DA98B954EEDEAC495271D0F80B844095EA7B30000000000000000000000007D2768DE32B0B80B7A3454C06BDAC94A69DDC7A9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF018080',
);
let transport = await sim.getTransport();
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_approve_dai_tokens', [5, 0]);
// Token provisioning
let buffer = Buffer.from("034441496B175474E89094C44DA98B954EEDEAC495271D0F00000012000000013045022100B3AA979633284EB0F55459099333AB92CF06FDD58DC90E9C070000C8E968864C02207B10EC7D6609F51DDA53D083A6E165A0ABF3A77E13250E6F260772809B49AFF5", "hex");
let tx = transport.send(0xe0, 0x0a, 0x00, 0x00, buffer);
// Send transaction
buffer = Buffer.from("058000002C8000003C800000010000000000000000F869468506A8B15E0082EBEB946B175474E89094C44DA98B954EEDEAC495271D0F80B844095EA7B30000000000000000000000007D2768DE32B0B80B7A3454C06BDAC94A69DDC7A9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF018080", "hex");
tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
// Type
filename = "type.png";
await sim.clickRight(tmpPath + filename);
const type = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_type = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(type).toMatchSnapshot(expected_type);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([37, 146, 36, 53, 17, 57, 107, 101, 164, 250, 167, 53, 165, 71, 46, 169, 155, 60, 224, 247, 242, 51, 142, 171, 66, 98, 6, 115, 11, 192, 221, 197, 127, 22, 27, 192, 248, 97, 6, 77, 132, 13, 228, 244, 48, 76, 253, 25, 165, 113, 1, 126, 98, 223, 125, 143, 112, 207, 96, 92, 15, 2, 85, 147, 182, 144, 0])
);
} finally {
await sim.close();
}
});
test("Approve DAI token nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
// Token provisioning
let buffer = Buffer.from("034441496B175474E89094C44DA98B954EEDEAC495271D0F00000012000000013045022100B3AA979633284EB0F55459099333AB92CF06FDD58DC90E9C070000C8E968864C02207B10EC7D6609F51DDA53D083A6E165A0ABF3A77E13250E6F260772809B49AFF5", "hex");
let tx = transport.send(0xe0, 0x0a, 0x00, 0x00, buffer);
// Send transaction
buffer = Buffer.from("058000002C8000003C800000010000000000000000F869468506A8B15E0082EBEB946B175474E89094C44DA98B954EEDEAC495271D0F80B844095EA7B30000000000000000000000007D2768DE32B0B80B7A3454C06BDAC94A69DDC7A9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF018080", "hex");
tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Type
filename = "type.png";
await sim.clickRight(tmpPath + filename);
const type = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_type = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(type).toMatchSnapshot(expected_type);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([37, 146, 36, 53, 17, 57, 107, 101, 164, 250, 167, 53, 165, 71, 46, 169, 155, 60, 224, 247, 242, 51, 142, 171, 66, 98, 6, 115, 11, 192, 221, 197, 127, 22, 27, 192, 248, 97, 6, 77, 132, 13, 228, 244, 48, 76, 253, 25, 165, 113, 1, 126, 98, 223, 125, 143, 112, 207, 96, 92, 15, 2, 85, 147, 182, 144, 0])
);
} finally {
await sim.close();
}
});
await expect(tx).resolves.toEqual({
"r": "92243511396b65a4faa735a5472ea99b3ce0f7f2338eab426206730bc0ddc57f",
"s": "161bc0f861064d840de4f4304cfd19a571017e62df7d8f70cf605c0f025593b6",
"v": "25",
});
}));

View File

@@ -0,0 +1,37 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import { waitForAppScreen, zemu } from './test.fixture';
test('[Nano S] Deposit ETH on compound, blind sign', zemu("nanos", async (sim, eth) => {
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'f8924685028fa6ae008306599594cc9a0b7c43dc2a5f023bb9b738e45b0ef6b06e0488016345785d8a0000b864474cf53d0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a900000000000000000000000070bc641723fad48be2df6cf63dc6270ee2f897430000000000000000000000000000000000000000000000000000000000000000018080',
);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_deposit_eth_compound_blind', [7, 0]);
await expect(tx).resolves.toEqual({
"r": "b5ae3a011eb50e7d1fe9f5e6f6d91ca9f4dfca5f73805fc4866d49e72ead2f5c",
"s": "3c6e55db5925586bb58e434b58b2c04756f662131597f98c1aa2418b16992b81",
"v": "26",
});
}));
test('[Nano X] Deposit ETH on compound, blind sign', zemu("nanox", async (sim, eth) => {
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'f8924685028fa6ae008306599594cc9a0b7c43dc2a5f023bb9b738e45b0ef6b06e0488016345785d8a0000b864474cf53d0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a900000000000000000000000070bc641723fad48be2df6cf63dc6270ee2f897430000000000000000000000000000000000000000000000000000000000000000018080',
);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_deposit_eth_compound_blind', [5, 0]);
await expect(tx).resolves.toEqual({
"r": "b5ae3a011eb50e7d1fe9f5e6f6d91ca9f4dfca5f73805fc4866d49e72ead2f5c",
"s": "3c6e55db5925586bb58e434b58b2c04756f662131597f98c1aa2418b16992b81",
"v": "26",
});
}));

View File

@@ -1,370 +1,71 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import Eth from "@ledgerhq/hw-app-eth";
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20";
import Zemu from "@zondax/zemu";
import { TransportStatusError } from "@ledgerhq/errors";
import { expect } from "../jest";
import { waitForAppScreen, zemu } from './test.fixture';
const {NANOS_ELF_PATH, NANOX_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT, getTmpPath} = require("generic.js");
test('[Nano S] Transfer on network 112233445566 on Ethereum', zemu("nanos", async (sim, eth) => {
const ORIGINAL_SNAPSHOT_PATH_PREFIX = "snapshots/chainid/";
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf6181880851a21a278be8080',
);
const ORIGINAL_SNAPSHOT_PATH_NANOS = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanos/";
const ORIGINAL_SNAPSHOT_PATH_NANOX = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanox/";
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_transfer_112233445566_network', [9, 0]);
test("Transfer on network 112233445566 on Ethereum nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
await expect(tx).resolves.toEqual({
"r": "509981d8dfb66757e25ff47c009b9b5bc5db0f169473e4735f5212b144f1c069",
"s": "5db989d81025de3c846e41a9ce01a3f9fd0982e2d827f1b88ffc95d73a48d04c",
"v": "344344f19f",
});
}));
try {
await sim.start(sim_options_nanos);
test('[Nano S] Transfer on palm network on Ethereum', zemu("nanos", async (sim, eth) => {
let transport = await sim.getTransport();
let eth = new Eth(transport);
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf61818808502a15c308d8080',
);
// Send transaction
let tx = eth.signTransaction(
"44'/60'/0'/0/0",
"f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf6181880851a21a278be8080"
)
let filename;
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_transfer_palm_network', [9, 0]);
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
await expect(tx).resolves.toEqual({
"r": "946700c4972b3da24ddaa95e590ad25a8f905da62e2bd053285a4cc17f93f490",
"s": "3698e84564e58477a49f7a9cea572ef5d672a5538db08f3ee42df5eb75a1b907",
"v": "0542b8613d",
});
}));
// Amount 1/3
filename = "amount_1.png";
await sim.clickRight(tmpPath + filename);
const amount_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_1).toMatchSnapshot(expected_amount_1);
test('[Nano X] Transfer on network 112233445566 on Ethereum', zemu("nanox", async (sim, eth) => {
// Amount 2/3
filename = "amount_2.png";
await sim.clickRight(tmpPath + filename);
const amount_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_2).toMatchSnapshot(expected_amount_2);
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf6181880851a21a278be8080',
);
// Amount 3/3
filename = "amount_3.png";
await sim.clickRight(tmpPath + filename);
const amount_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_3).toMatchSnapshot(expected_amount_3);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_transfer_112233445566_network', [5, 0]);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
await expect(tx).resolves.toEqual({
"r": "509981d8dfb66757e25ff47c009b9b5bc5db0f169473e4735f5212b144f1c069",
"s": "5db989d81025de3c846e41a9ce01a3f9fd0982e2d827f1b88ffc95d73a48d04c",
"v": "344344f19f",
});
}));
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
test('[Nano X] Transfer on palm network on Ethereum', zemu("nanox", async (sim, eth) => {
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf61818808502a15c308d8080',
);
// Network
filename = "network.png";
await sim.clickRight(tmpPath + filename);
const network = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_network = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(network).toMatchSnapshot(expected_network);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_transfer_palm_network', [5, 0]);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
{
"r": "31fca443b3cad62f3ce18e287f3cf4892ac2669379cc21b5cf198561f0511d1e",
"s": "3cf21485cd8b86e1acddbcc641e16a3efad18aaeb5ae96a650f1a8b291078494",
"v": "344344f1a0",
}
);
} finally {
await sim.close();
}
});
test("Transfer on palm network on Ethereum nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanos);
let transport = await sim.getTransport();
let eth = new Eth(transport);
// Send transaction
let tx = eth.signTransaction(
"44'/60'/0'/0/0",
"f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf61818808502a15c308d8080"
);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount 1/3
filename = "amount_1_palm.png";
await sim.clickRight(tmpPath + filename);
const amount_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_1).toMatchSnapshot(expected_amount_1);
// Amount 2/3
filename = "amount_2.png";
await sim.clickRight(tmpPath + filename);
const amount_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_2).toMatchSnapshot(expected_amount_2);
// Amount 3/3
filename = "amount_3.png";
await sim.clickRight(tmpPath + filename);
const amount_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_3).toMatchSnapshot(expected_amount_3);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
// Network
filename = "palm.png";
await sim.clickRight(tmpPath + filename);
const network = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_network = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(network).toMatchSnapshot(expected_network);
// Max Fees
filename = "fees_palm.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
{
"r": "f9b5d903c47c34027156e869bda5aa002233d6cca583ad53d125612fc0795f3b",
"s": "00da038129414e5ae6f7c1529c6067e82484e3694c84c16d575e77162f631c27",
"v": "0542b8613d",
}
);
} finally {
await sim.close();
}
});
test("Transfer on network 112233445566 on Ethereum nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
let eth = new Eth(transport);
// Send transaction
let tx = eth.signTransaction(
"44'/60'/0'/0/0",
"f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf6181880851a21a278be8080"
)
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Network
filename = "network.png";
await sim.clickRight(tmpPath + filename);
const network = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_network = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(network).toMatchSnapshot(expected_network);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
{
"r": "31fca443b3cad62f3ce18e287f3cf4892ac2669379cc21b5cf198561f0511d1e",
"s": "3cf21485cd8b86e1acddbcc641e16a3efad18aaeb5ae96a650f1a8b291078494",
"v": "344344f1a0",
}
);
} finally {
await sim.close();
}
});
test("Transfer on palm network on Ethereum nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
let eth = new Eth(transport);
// Send transaction
let tx = eth.signTransaction(
"44'/60'/0'/0/0",
"f044850306dc4200825208945a321744667052affa8386ed49e00ef223cbffc3876f9c9e7bf61818808502a15c308d8080"
);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount
filename = "amount_palm.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Network
filename = "palm.png";
await sim.clickRight(tmpPath + filename);
const network = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_network = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(network).toMatchSnapshot(expected_network);
// Max Fees
filename = "fees_palm.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
{
"r": "f9b5d903c47c34027156e869bda5aa002233d6cca583ad53d125612fc0795f3b",
"s": "00da038129414e5ae6f7c1529c6067e82484e3694c84c16d575e77162f631c27",
"v": "0542b8613d",
}
);
} finally {
await sim.close();
}
});
await expect(tx).resolves.toEqual({
"r": "946700c4972b3da24ddaa95e590ad25a8f905da62e2bd053285a4cc17f93f490",
"s": "3698e84564e58477a49f7a9cea572ef5d672a5538db08f3ee42df5eb75a1b907",
"v": "0542b8613d",
});
}));

View File

@@ -0,0 +1,38 @@
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import { expect } from "../jest";
import { TransportStatusError } from "@ledgerhq/errors";
import { waitForAppScreen, zemu } from './test.fixture';
import Zemu from '@zondax/zemu';
test('[Nano S] Try to blind sign with setting disabled', zemu("nanos", async (sim, eth) => {
// disable blind signing
await sim.navigateAndCompareSnapshots('.', 'nanos_disable_blind_signing', [2, 0, 0, 3, 0]);
// we can't use eth.signTransaction because it detects that contract data is disabled and fails early
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002c8000003c800000010000000000000000f849208506fc23ac008303dc3194f650c3d88d12db855b8bf7d11be6c55a4e07dcc980a4a1712d6800000000000000000000000000000000000000000000000000000000000acbc7018080", "hex");
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
await expect(tx).rejects.toEqual(new TransportStatusError(0x6a80));
await Zemu.sleep(1000);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_try_to_blind_sign_with_setting_disabled', [1, 0]);
}));
test('[Nano X] Try to blind sign with setting disabled', zemu("nanox", async (sim, eth) => {
// disable blind signing
await sim.navigateAndCompareSnapshots('.', 'nanox_disable_blind_signing', [2, 0, 0, 3, 0]);
// we can't use eth.signTransaction because it detects that contract data is disabled and fails early
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002c8000003c800000010000000000000000f849208506fc23ac008303dc3194f650c3d88d12db855b8bf7d11be6c55a4e07dcc980a4a1712d6800000000000000000000000000000000000000000000000000000000000acbc7018080", "hex");
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
await expect(tx).rejects.toEqual(new TransportStatusError(0x6a80));
await Zemu.sleep(1000);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_try_to_blind_sign_with_setting_disabled', [0]);
}));

View File

@@ -1,171 +0,0 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import Eth from "@ledgerhq/hw-app-eth";
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20";
import Zemu from "@zondax/zemu";
import { TransportStatusError } from "@ledgerhq/errors";
import { expect } from "../jest";
const {NANOS_ELF_PATH, NANOX_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT, getTmpPath} = require("generic.js");
// Adapt this prefix.
const ORIGINAL_SNAPSHOT_PATH_PREFIX = "snapshots/deposit/";
const ORIGINAL_SNAPSHOT_PATH_NANOS = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanos/";
const ORIGINAL_SNAPSHOT_PATH_NANOX = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanox/";
test("Deposit ETH nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanos);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002c8000003c800000010000000000000000f8924685028fa6ae008306599594cc9a0b7c43dc2a5f023bb9b738e45b0ef6b06e0488016345785d8a0000b864474cf53d0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a900000000000000000000000070bc641723fad48be2df6cf63dc6270ee2f8974300000000000000000000000000000000", "hex");
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
buffer = Buffer.from("00000000000000000000000000000000018080", "hex");
tx = transport.send(0xe0, 0x04, 0x80, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
// Data present
filename = "data_present.png";
await sim.clickRight(tmpPath + filename);
const data_present = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_data_present = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(data_present).toMatchSnapshot(expected_data_present);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([38, 181, 174, 58, 1, 30, 181, 14, 125, 31, 233, 245, 230, 246, 217, 28, 169, 244, 223, 202, 95, 115, 128, 95, 196, 134, 109, 73, 231, 46, 173, 47, 92, 60, 110, 85, 219, 89, 37, 88, 107, 181, 142, 67, 75, 88, 178, 192, 71, 86, 246, 98, 19, 21, 151, 249, 140, 26, 162, 65, 139, 22, 153, 43, 129, 144, 0])
);
} finally {
await sim.close();
}
});
test("Deposit ETH nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002c8000003c800000010000000000000000f8924685028fa6ae008306599594cc9a0b7c43dc2a5f023bb9b738e45b0ef6b06e0488016345785d8a0000b864474cf53d0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a900000000000000000000000070bc641723fad48be2df6cf63dc6270ee2f8974300000000000000000000000000000000", "hex");
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
buffer = Buffer.from("00000000000000000000000000000000018080", "hex");
tx = transport.send(0xe0, 0x04, 0x80, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Data present
filename = "data_present.png";
await sim.clickRight(tmpPath + filename);
const data_present = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_data_present = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(data_present).toMatchSnapshot(expected_data_present);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([38, 181, 174, 58, 1, 30, 181, 14, 125, 31, 233, 245, 230, 246, 217, 28, 169, 244, 223, 202, 95, 115, 128, 95, 196, 134, 109, 73, 231, 46, 173, 47, 92, 60, 110, 85, 219, 89, 37, 88, 107, 181, 142, 67, 75, 88, 178, 192, 71, 86, 246, 98, 19, 21, 151, 249, 140, 26, 162, 65, 139, 22, 153, 43, 129, 144, 0])
);
} finally {
await sim.close();
}
});

View File

@@ -1,152 +1,39 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import Eth from "@ledgerhq/hw-app-eth";
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20";
import Zemu from "@zondax/zemu";
import { TransportStatusError } from "@ledgerhq/errors";
import { expect } from "../jest";
import { waitForAppScreen, zemu } from './test.fixture';
const {NANOS_ELF_PATH, NANOX_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT, getTmpPath} = require("generic.js");
test('[Nano S] Transfer eip1559', zemu("nanos", async (sim, eth) => {
const ORIGINAL_SNAPSHOT_PATH_PREFIX = "snapshots/eip1559/";
const tx = eth.signTransaction(
"44'/60'/0'/0/0",
'02f87001018502540be4008502540be40086246139ca800094cccccccccccccccccccccccccccccccccccccccc8000c001a0e07fb8a64ea3786c9a6649e54429e2786af3ea31c6d06165346678cf8ce44f9ba00e4a0526db1e905b7164a858fd5ebd2f1759e22e6955499448bd276a6aa62830',
);
const ORIGINAL_SNAPSHOT_PATH_NANOS = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanos/";
const ORIGINAL_SNAPSHOT_PATH_NANOX = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanox/";
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_transfer_eip1559', [6, 0]);
test("Transfer nanos eip1559", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
await expect(tx).resolves.toEqual({
"r": "3d6dfabc6c52374bfa34cb2c433856a0bcd9484870dd1b50249f7164a5fce052",
"s": "0548a774dd0b63930d83cb2e1a836fe3ef24444e8b758b00585d9a076c0e98a8",
"v": "01"
});
try {
await sim.start(sim_options_nanos);
}));
let transport = await sim.getTransport();
test('[Nano X] Transfer eip1559', zemu("nanox", async (sim, eth) => {
// From this test: https://github.com/ethereum/tests/blob/5d534e37b80e9310e8c7751f805ca481a451123e/GeneralStateTests/stEIP1559/outOfFunds.json#L35
let buffer = Buffer.from("058000002c8000003c80000000000000000000000002f87001018502540be4008502540be40086246139ca800094cccccccccccccccccccccccccccccccccccccccc8000c001a0e07fb8a64ea3786c9a6649e54429e2786af3ea31c6d06165346678cf8ce44f9ba00e4a0526db1e905b7164a858fd5ebd2f1759e22e6955499448bd276a6aa62830", "hex");
const tx = eth.signTransaction(
"44'/60'/0'/0/0",
'02f87001018502540be4008502540be40086246139ca800094cccccccccccccccccccccccccccccccccccccccc8000c001a0e07fb8a64ea3786c9a6649e54429e2786af3ea31c6d06165346678cf8ce44f9ba00e4a0526db1e905b7164a858fd5ebd2f1759e22e6955499448bd276a6aa62830',
);
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_transfer_eip1559', [4, 0]);
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
await expect(tx).resolves.toEqual({
"r": "3d6dfabc6c52374bfa34cb2c433856a0bcd9484870dd1b50249f7164a5fce052",
"s": "0548a774dd0b63930d83cb2e1a836fe3ef24444e8b758b00585d9a076c0e98a8",
"v": "01"
});
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([1, 61, 109, 250, 188, 108, 82, 55, 75, 250, 52, 203, 44, 67, 56, 86, 160, 188, 217, 72, 72, 112, 221, 27, 80, 36, 159, 113, 100, 165, 252, 224, 82, 5, 72, 167, 116, 221, 11, 99, 147, 13, 131, 203, 46, 26, 131, 111, 227, 239, 36, 68, 78, 139, 117, 139, 0, 88, 93, 154, 7, 108, 14, 152, 168, 144, 0]));
} finally {
await sim.close();
}
});
test("Transfer nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
// From this test: https://github.com/ethereum/tests/blob/5d534e37b80e9310e8c7751f805ca481a451123e/GeneralStateTests/stEIP1559/outOfFunds.json#L35
let buffer = Buffer.from("058000002c8000003c80000000000000000000000002f87001018502540be4008502540be40086246139ca800094cccccccccccccccccccccccccccccccccccccccc8000c001a0e07fb8a64ea3786c9a6649e54429e2786af3ea31c6d06165346678cf8ce44f9ba00e4a0526db1e905b7164a858fd5ebd2f1759e22e6955499448bd276a6aa62830", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([1, 61, 109, 250, 188, 108, 82, 55, 75, 250, 52, 203, 44, 67, 56, 86, 160, 188, 217, 72, 72, 112, 221, 27, 80, 36, 159, 113, 100, 165, 252, 224, 82, 5, 72, 167, 116, 221, 11, 99, 147, 13, 131, 203, 46, 26, 131, 111, 227, 239, 36, 68, 78, 139, 117, 139, 0, 88, 93, 154, 7, 108, 14, 152, 168, 144, 0]));
} finally {
await sim.close();
}
});
}));

View File

@@ -1,53 +0,0 @@
import fs from "fs";
const sim_options_nanos = {
model: "nanos",
logging: true,
start_delay: 2000,
X11: true,
custom: "",
};
const sim_options_nanox = {
model: "nanox",
logging: true,
start_delay: 2000,
X11: true,
custom: "",
};
const Resolve = require("path").resolve;
const NANOS_ELF_PATH = Resolve("elfs/ethereum_nanos.elf");
const NANOX_ELF_PATH = Resolve("elfs/ethereum_nanox.elf");
const NANOS_ETH_LIB = { "Ethereum": NANOS_ELF_PATH };
const NANOX_ETH_LIB = { "Ethereum": NANOX_ELF_PATH };
const NANOS_CLONE_ELF_PATH = Resolve("elfs/ethereum_classic_nanos.elf");
const NANOX_CLONE_ELF_PATH = Resolve("elfs/ethereum_classic_nanox.elf");
const TIMEOUT = 1000000;
const getTmpPath = (testName) => {
let date = new Date();
let tmpPath = `snapshots/tmp/${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}@${testName}/`;
fs.mkdir(tmpPath, { recursive:true }, (err) => {
if(err) {
console.log("couldn't create tmp folder at path: " + tmpPath)
}
});
return tmpPath;
}
module.exports = {
NANOS_ELF_PATH,
NANOX_ELF_PATH,
NANOS_ETH_LIB,
NANOX_ETH_LIB,
NANOS_CLONE_ELF_PATH,
NANOX_CLONE_ELF_PATH,
sim_options_nanos,
sim_options_nanox,
TIMEOUT,
getTmpPath,
}

View File

@@ -1,332 +1,71 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import Eth from "@ledgerhq/hw-app-eth";
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20";
import Zemu from "@zondax/zemu";
import { TransportStatusError } from "@ledgerhq/errors";
import { expect } from "../jest";
import { waitForAppScreen, zemu } from './test.fixture';
const {NANOS_ELF_PATH, NANOX_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT, getTmpPath} = require("generic.js");
test('[Nano S] Transfer Ether on Ethereum app', zemu("nanos", async (sim, eth) => {
const ORIGINAL_SNAPSHOT_PATH_PREFIX = "snapshots/send/";
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880018080',
);
const ORIGINAL_SNAPSHOT_PATH_NANOS = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanos/";
const ORIGINAL_SNAPSHOT_PATH_NANOX = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanox/";
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_transfer_ethereum', [8, 0]);
test("Transfer Ether on Ethereum app nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
await expect(tx).resolves.toEqual({
"r": "6f389d15320f0501383526ed03de917c14212716f09a262dbc98431086a5db49",
"s": "0dc994b7b97230bb35fdf6fec2f4d8ff4cfb8bfeb2a652c364c738ff033c05dd",
"v": "26",
});
}));
try {
await sim.start(sim_options_nanos);
test('[Nano S] Transfer Ether on network 5234 on Ethereum app', zemu("nanos", async (sim, eth) => {
let transport = await sim.getTransport();
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'ED44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080',
);
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880018080", "hex");
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_transfer_ethereum_5234_network', [9, 0]);
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await expect(tx).resolves.toEqual({
"r": "07a7982dfd16360c96a03467877d0cf9c36f799deff4dace250cdb18e28a3b90",
"s": "773318a93da2e32c1cf308ddd6add1e8c0d285973e541520a05fb4dc720e4fb1",
"v": "2908",
});
}));
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
test('[Nano X] Transfer Ether on Ethereum app', zemu("nanox", async (sim, eth) => {
// Amount 1/3
filename = "amount_1.png";
await sim.clickRight(tmpPath + filename);
const amount_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_1).toMatchSnapshot(expected_amount_1);
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880018080',
);
// Amount 2/3
filename = "amount_2.png";
await sim.clickRight(tmpPath + filename);
const amount_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_2).toMatchSnapshot(expected_amount_2);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_transfer_ethereum', [4, 0]);
// Amount 3/3
filename = "amount_3.png";
await sim.clickRight(tmpPath + filename);
const amount_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_3).toMatchSnapshot(expected_amount_3);
await expect(tx).resolves.toEqual({
"r": "6f389d15320f0501383526ed03de917c14212716f09a262dbc98431086a5db49",
"s": "0dc994b7b97230bb35fdf6fec2f4d8ff4cfb8bfeb2a652c364c738ff033c05dd",
"v": "26",
});
}));
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
test('[Nano X] Transfer Ether on network 5234 on Ethereum app', zemu("nanox", async (sim, eth) => {
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'ED44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080',
);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_transfer_ethereum_5234_network', [5, 0]);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([ 38, 111, 56, 157, 21, 50, 15, 5, 1, 56, 53, 38, 237, 3, 222, 145, 124, 20, 33, 39, 22, 240, 154, 38, 45, 188, 152, 67, 16, 134, 165, 219, 73, 13, 201, 148, 183, 185, 114, 48, 187, 53, 253, 246, 254, 194, 244, 216, 255, 76, 251, 139, 254, 178, 166, 82, 195, 100, 199, 56, 255, 3, 60, 5, 221, 144, 0])
);
} finally {
await sim.close();
}
});
test("Transfer on network 5234 on Ethereum nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanos);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount 1/3
filename = "amount_1.png";
await sim.clickRight(tmpPath + filename);
const amount_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_1).toMatchSnapshot(expected_amount_1);
// Amount 2/3
filename = "amount_2.png";
await sim.clickRight(tmpPath + filename);
const amount_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_2).toMatchSnapshot(expected_amount_2);
// Amount 3/3
filename = "amount_3.png";
await sim.clickRight(tmpPath + filename);
const amount_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_3).toMatchSnapshot(expected_amount_3);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
// Network
filename = "network.png";
await sim.clickRight(tmpPath + filename);
const network = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_network = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(network).toMatchSnapshot(expected_network);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from("08f3449bbc245669e26dd076986e11aa3117e2405ffe2ddc7a7e220f81326fbd91150515605c78119367be311345e9ff40c4e4ddb9ec0fd81f37035c3828f4c8b29000", 'hex')
);
} finally {
await sim.close();
}
});
test("Transfer Ether on Ethereum nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880018080", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([ 38, 111, 56, 157, 21, 50, 15, 5, 1, 56, 53, 38, 237, 3, 222, 145, 124, 20, 33, 39, 22, 240, 154, 38, 45, 188, 152, 67, 16, 134, 165, 219, 73, 13, 201, 148, 183, 185, 114, 48, 187, 53, 253, 246, 254, 194, 244, 216, 255, 76, 251, 139, 254, 178, 166, 82, 195, 100, 199, 56, 255, 3, 60, 5, 221, 144, 0])
);
} finally {
await sim.close();
}
});
test("Transfer on network 5234 on Ethereum nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Network
filename = "network.png";
await sim.clickRight(tmpPath + filename);
const network = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_network = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(network).toMatchSnapshot(expected_network);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from("08f3449bbc245669e26dd076986e11aa3117e2405ffe2ddc7a7e220f81326fbd91150515605c78119367be311345e9ff40c4e4ddb9ec0fd81f37035c3828f4c8b29000", 'hex')
);
} finally {
await sim.close();
}
});
await expect(tx).resolves.toEqual({
"r": "07a7982dfd16360c96a03467877d0cf9c36f799deff4dace250cdb18e28a3b90",
"s": "773318a93da2e32c1cf308ddd6add1e8c0d285973e541520a05fb4dc720e4fb1",
"v": "2908",
});
}));

View File

@@ -1,182 +1,37 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import Eth from "@ledgerhq/hw-app-eth";
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20";
import Zemu from "@zondax/zemu";
import { TransportStatusError } from "@ledgerhq/errors";
import { expect } from "../jest";
import { waitForAppScreen, zemu } from './test.fixture';
const {NANOS_ELF_PATH, NANOX_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT, getTmpPath} = require("generic.js");
test('[Nano S] Transfer bsc', zemu("nanos", async (sim, eth) => {
const ORIGINAL_SNAPSHOT_PATH_PREFIX = "snapshots/send_bsc/";
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'EB0185012A05F200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880388080',
);
const ORIGINAL_SNAPSHOT_PATH_NANOS = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanos/";
const ORIGINAL_SNAPSHOT_PATH_NANOX = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanox/";
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_transfer_bsc', [9, 0]);
await expect(tx).resolves.toEqual({
"r": "f667cc34e9815df4f052fb3463cdbe355fff5c1acf4e919b3539806521a059ad",
"s": "6b35492b7108d9d9e1cc7aede536ed6b3173197b56dd873cbc3b43e041d6f407",
"v": "93",
});
}));
test("Transfer bsc nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
test('[Nano X] Transfer bsc', zemu("nanox", async (sim, eth) => {
try {
await sim.start(sim_options_nanos);
const tx = eth.signTransaction(
"44'/60'/1'/0/0",
'EB0185012A05F200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880388080',
);
let transport = await sim.getTransport();
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_transfer_bsc', [5, 0]);
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB0185012A05F200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880388080", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount 1/3
filename = "amount_1.png";
await sim.clickRight(tmpPath + filename);
const amount_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_1).toMatchSnapshot(expected_amount_1);
// Amount 2/3
filename = "amount_2.png";
await sim.clickRight(tmpPath + filename);
const amount_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_2).toMatchSnapshot(expected_amount_2);
// Amount 3/3
filename = "amount_3.png";
await sim.clickRight(tmpPath + filename);
const amount_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_3).toMatchSnapshot(expected_amount_3);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
// Network name
filename = "network.png";
await sim.clickRight(tmpPath + filename);
const chainid = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_chainid = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(chainid).toMatchSnapshot(expected_chainid);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([147, 246, 103, 204, 52, 233, 129, 93, 244, 240, 82, 251, 52, 99, 205, 190, 53, 95, 255, 92, 26, 207, 78, 145, 155, 53, 57, 128, 101, 33, 160, 89, 173, 107, 53, 73, 43, 113, 8, 217, 217, 225, 204, 122, 237, 229, 54, 237, 107, 49, 115, 25, 123, 86, 221, 135, 60, 188, 59, 67, 224, 65, 214, 244, 7, 144, 0]),
);
} finally {
await sim.close();
}
});
test("Transfer bsc nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_ELF_PATH);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB0185012A05F200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF6181880388080", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Network name
filename = "network.png";
await sim.clickRight(tmpPath + filename);
const chainid = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_chainid = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(chainid).toMatchSnapshot(expected_chainid);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from([147, 246, 103, 204, 52, 233, 129, 93, 244, 240, 82, 251, 52, 99, 205, 190, 53, 95, 255, 92, 26, 207, 78, 145, 155, 53, 57, 128, 101, 33, 160, 89, 173, 107, 53, 73, 43, 113, 8, 217, 217, 225, 204, 122, 237, 229, 54, 237, 107, 49, 115, 25, 123, 86, 221, 135, 60, 188, 59, 67, 224, 65, 214, 244, 7, 144, 0]),
);
} finally {
await sim.close();
}
});
await expect(tx).resolves.toEqual({
"r": "f667cc34e9815df4f052fb3463cdbe355fff5c1acf4e919b3539806521a059ad",
"s": "6b35492b7108d9d9e1cc7aede536ed6b3173197b56dd873cbc3b43e041d6f407",
"v": "93",
});
}));

View File

@@ -1,109 +1,13 @@
import "core-js/stable";
import "regenerator-runtime/runtime";
import Eth from "@ledgerhq/hw-app-eth";
import { byContractAddress } from "@ledgerhq/hw-app-eth/erc20";
import Zemu from "@zondax/zemu";
import { TransportStatusError } from "@ledgerhq/errors";
import { EthAppPleaseEnableContractData } from "@ledgerhq/errors";
import { expect } from "../jest";
const {NANOS_ETH_LIB, NANOX_ETH_LIB, NANOS_CLONE_ELF_PATH, NANOX_CLONE_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT, getTmpPath} = require("generic.js");
import { waitForAppScreen, NANOS_ETH_LIB, NANOX_ETH_LIB, NANOS_CLONE_ELF_PATH, NANOX_CLONE_ELF_PATH, sim_options_nanos, sim_options_nanox, TIMEOUT} from './test.fixture';
const ORIGINAL_SNAPSHOT_PATH_PREFIX = "snapshots/send_etc/";
const ORIGINAL_SNAPSHOT_PATH_NANOS = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanos/";
const ORIGINAL_SNAPSHOT_PATH_NANOX = ORIGINAL_SNAPSHOT_PATH_PREFIX + "nanox/";
test("Transfer on Ethereum clone app nanos", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_CLONE_ELF_PATH, NANOS_ETH_LIB);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanos);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818803D8080", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount 1/3
filename = "amount_1.png";
await sim.clickRight(tmpPath + filename);
const amount_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_1).toMatchSnapshot(expected_amount_1);
// Amount 2/3
filename = "amount_2.png";
await sim.clickRight(tmpPath + filename);
const amount_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_2).toMatchSnapshot(expected_amount_2);
// Amount 3/3
filename = "amount_3.png";
await sim.clickRight(tmpPath + filename);
const amount_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(amount_3).toMatchSnapshot(expected_amount_3);
// Address 1/3
filename = "address_1.png";
await sim.clickRight(tmpPath + filename);
const address_1 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_1 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_1).toMatchSnapshot(expected_address_1);
// Address 2/3
filename = "address_2.png";
await sim.clickRight(tmpPath + filename);
const address_2 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_2 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_2).toMatchSnapshot(expected_address_2);
// Address 3/3
filename = "address_3.png";
await sim.clickRight(tmpPath + filename);
const address_3 = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address_3 = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(address_3).toMatchSnapshot(expected_address_3);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOS + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from("9e52b80e10cb82f3dc8345005e3da3f9cae1fb3f2b9a5df05b7cedba786c685fed381875af27d121beaa9efd8a7450975f9d45a26ba5aa331b7a8b26bcce95e6d09000", 'hex')
);
} finally {
await sim.close();
}
});
test("Transfer on network 5234 on Ethereum clone nanos", async () => {
test("[Nano S] Transfer on Ethereum clone app", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_CLONE_ELF_PATH, NANOS_ETH_LIB);
@@ -112,81 +16,51 @@ test("Transfer on network 5234 on Ethereum clone nanos", async () => {
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080", "hex");
const eth = new Eth(transport);
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
await expect(tx).rejects.toEqual(new TransportStatusError(0x6a80));
} finally {
await sim.close();
}
});
test("Transfer on Ethereum clone nanox", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_CLONE_ELF_PATH, NANOX_ETH_LIB);
let tmpPath = getTmpPath(expect.getState().currentTestName);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818803D8080", "hex");
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
let filename;
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());
// Review tx
filename = "review.png";
await sim.snapshot(tmpPath + filename);
const review = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_review = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(review).toMatchSnapshot(expected_review);
// Amount
filename = "amount.png";
await sim.clickRight(tmpPath + filename);
const amount = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_amount = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(amount).toMatchSnapshot(expected_amount);
// Address
filename = "address.png";
await sim.clickRight(tmpPath + filename);
const address = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_address = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(address).toMatchSnapshot(expected_address);
// Max Fees
filename = "fees.png";
await sim.clickRight(tmpPath + filename);
const fees = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_fees = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(fees).toMatchSnapshot(expected_fees);
// Accept
filename = "accept.png";
await sim.clickRight(tmpPath + filename);
const accept = Zemu.LoadPng2RGB(tmpPath + filename);
const expected_accept = Zemu.LoadPng2RGB(ORIGINAL_SNAPSHOT_PATH_NANOX + filename);
expect(accept).toMatchSnapshot(expected_accept);
await sim.clickBoth();
await expect(tx).resolves.toEqual(
Buffer.from("9e52b80e10cb82f3dc8345005e3da3f9cae1fb3f2b9a5df05b7cedba786c685fed381875af27d121beaa9efd8a7450975f9d45a26ba5aa331b7a8b26bcce95e6d09000", 'hex')
const tx = eth.signTransaction(
"44'/60'/0'/0/0",
'EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818803D8080',
);
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanos_transfer_ethereum_clone', [8, 0]);
await expect(tx).resolves.toEqual({
"r": "60df850d297e355596f87dc313a742032de4b59c5579186b3d59bdf31402fec0",
"s": "23c3a2beacabc1943d487a2e1d545e4c46c718b1e70e9d1c11a98828c9338927",
"v": "9e",
});
} finally {
await sim.close();
}
});
test("[Nano S] Transfer on network 5234 on Ethereum clone", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOS_CLONE_ELF_PATH, NANOS_ETH_LIB);
test("Transfer on network 5234 on Ethereum clone nanox", async () => {
try {
await sim.start(sim_options_nanos);
let transport = await sim.getTransport();
const eth = new Eth(transport);
const tx = eth.signTransaction(
"44'/60'/0'/0/0",
'ED44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080',
);
await expect(tx).rejects.toEqual(new EthAppPleaseEnableContractData(
"Please enable Contract data on the Ethereum app Settings"
));
} finally {
await sim.close();
}
});
test("[Nano X] Transfer on Ethereum clone app", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_CLONE_ELF_PATH, NANOX_ETH_LIB);
@@ -195,12 +69,45 @@ test("Transfer on network 5234 on Ethereum clone nanox", async () => {
let transport = await sim.getTransport();
let buffer = Buffer.from("058000002C8000003C800000010000000000000000EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080", "hex");
const eth = new Eth(transport);
// Send transaction
let tx = transport.send(0xe0, 0x04, 0x00, 0x00, buffer);
const tx = eth.signTransaction(
"44'/60'/0'/0/0",
'EB44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818803D8080',
);
await expect(tx).rejects.toEqual(new TransportStatusError(0x6a80));
await waitForAppScreen(sim);
await sim.navigateAndCompareSnapshots('.', 'nanox_transfer_ethereum_clone', [4, 0]);
await expect(tx).resolves.toEqual({
"r": "60df850d297e355596f87dc313a742032de4b59c5579186b3d59bdf31402fec0",
"s": "23c3a2beacabc1943d487a2e1d545e4c46c718b1e70e9d1c11a98828c9338927",
"v": "9e",
});
} finally {
await sim.close();
}
});
test("[Nano X] Transfer on network 5234 on Ethereum clone", async () => {
jest.setTimeout(TIMEOUT);
const sim = new Zemu(NANOX_CLONE_ELF_PATH, NANOX_ETH_LIB);
try {
await sim.start(sim_options_nanox);
let transport = await sim.getTransport();
const eth = new Eth(transport);
const tx = eth.signTransaction(
"44'/60'/0'/0/0",
'ED44850306DC4200825208945A321744667052AFFA8386ED49E00EF223CBFFC3876F9C9E7BF61818808214728080',
);
await expect(tx).rejects.toEqual(new EthAppPleaseEnableContractData(
"Please enable Contract data on the Ethereum app Settings"
));
} finally {
await sim.close();
}

75
tests/src/test.fixture.js Normal file
View File

@@ -0,0 +1,75 @@
import Zemu from '@zondax/zemu';
import Eth from '@ledgerhq/hw-app-eth';
const transactionUploadDelay = 60000;
async function waitForAppScreen(sim) {
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot(), transactionUploadDelay);
}
const sim_options_nanos = {
model: 'nanos',
logging: true,
X11: true,
startDelay: 5000,
custom: '',
};
const sim_options_nanox = {
model: 'nanox',
logging: true,
X11: true,
startDelay: 5000,
custom: '',
};
const Resolve = require('path').resolve;
const NANOS_ELF_PATH = Resolve('elfs/ethereum_nanos.elf');
const NANOX_ELF_PATH = Resolve('elfs/ethereum_nanox.elf');
const NANOS_ETH_LIB = { "Ethereum": NANOS_ELF_PATH };
const NANOX_ETH_LIB = { "Ethereum": NANOX_ELF_PATH };
const NANOS_CLONE_ELF_PATH = Resolve("elfs/ethereum_classic_nanos.elf");
const NANOX_CLONE_ELF_PATH = Resolve("elfs/ethereum_classic_nanox.elf");
const TIMEOUT = 1000000;
function zemu(device, func) {
return async () => {
jest.setTimeout(TIMEOUT);
let zemu_args;
let sim_options;
if(device === "nanos") {
zemu_args = [NANOS_ELF_PATH];
sim_options = sim_options_nanos;
}
else {
zemu_args = [NANOX_ELF_PATH];
sim_options = sim_options_nanox;
}
const sim = new Zemu(...zemu_args);
try {
await sim.start(sim_options);
const transport = await sim.getTransport();
await func(sim, new Eth(transport));
} finally {
await sim.close();
}
};
}
module.exports = {
zemu,
waitForAppScreen,
NANOS_ELF_PATH,
NANOX_ELF_PATH,
NANOS_ETH_LIB,
NANOX_ETH_LIB,
NANOS_CLONE_ELF_PATH,
NANOX_CLONE_ELF_PATH,
sim_options_nanos,
sim_options_nanox,
TIMEOUT
}