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,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",
});
}));