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:
@@ -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",
|
||||
});
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user