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