Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #33 from Zondax/extend_testing
Browse files Browse the repository at this point in the history
Extend test vectors + add zemu large nomination test
  • Loading branch information
jleni authored Aug 7, 2020
2 parents 446438a + ac1f7ef commit 67e6479
Show file tree
Hide file tree
Showing 44 changed files with 22,178 additions and 4,741 deletions.
26,874 changes: 22,134 additions & 4,740 deletions tests/testcases.json

Large diffs are not rendered by default.

Binary file added tests_zemu/snapshots/sign_large_nomination/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sign_large_nomination/32.png
Binary file added tests_zemu/snapshots/sign_large_nomination/33.png
Binary file added tests_zemu/snapshots/sign_large_nomination/34.png
Binary file added tests_zemu/snapshots/sign_large_nomination/35.png
Binary file added tests_zemu/snapshots/sign_large_nomination/36.png
Binary file added tests_zemu/snapshots/sign_large_nomination/37.png
Binary file added tests_zemu/snapshots/sign_large_nomination/38.png
Binary file added tests_zemu/snapshots/sign_large_nomination/39.png
Binary file added tests_zemu/snapshots/sign_large_nomination/4.png
Binary file added tests_zemu/snapshots/sign_large_nomination/40.png
Binary file added tests_zemu/snapshots/sign_large_nomination/41.png
Binary file added tests_zemu/snapshots/sign_large_nomination/5.png
Binary file added tests_zemu/snapshots/sign_large_nomination/6.png
Binary file added tests_zemu/snapshots/sign_large_nomination/7.png
Binary file added tests_zemu/snapshots/sign_large_nomination/8.png
Binary file added tests_zemu/snapshots/sign_large_nomination/9.png
45 changes: 44 additions & 1 deletion tests_zemu/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('Basic checks', function () {
// Now verify the signature
let prehash = txBlob;
if (txBlob.length > 256) {
const context = blake2bInit(64, null);
const context = blake2bInit(32, null);
blake2bUpdate(context, txBlob);
prehash = Buffer.from(blake2bFinal(context));
}
Expand All @@ -159,4 +159,47 @@ describe('Basic checks', function () {
}
});

test('sign large nomination', async function () {
const sim = new Zemu(APP_PATH);
try {
await sim.start(sim_options);
const app = newKusamaApp(sim.getTransport());
const pathAccount = 0x80000000;
const pathChange = 0x80000000;
const pathIndex = 0x80000000;

let txBlobStr = "060540c17c9e6afb931ae7beb788511a328f969f3973a3463d346b3f37b78b7148a2de6eb61a6850ef4a72361507f73c5e11b9ac83526940296f4d5b76187a20bc38b54c11bc36f9ae08d274dd4dd6f01b0d3b1bc5bf6d348d9497dbfba1d848e496af59da2c352aaf3660d4cb3f6d1503aee4ce7d2cb6aa8640883ed2c72332d0015489e530a829632e84698d1b2029fd99d3d1ef1a74d85c5516bab91155dcbb64536683d375cdc516f8a0f49d04c669cf5f3a4dcd9626e35fd54bb01c554a612abb4ad3dc3ac25ddb3ad2227428519a51476b02de5d086f2594652c01a9968c45cd8ef40f1f310d26d880b5ff4d4640430a884fa36ec8c8f1e914c1c5a8ce152c46dbfcd84f7fce802c2ec814144be18e1985981fc85002e6c8e5d587b53149db381909be0274b84e846a5900ec972a11c204fb45b5efc0be284b48de2c6d82410592015cf9cef9a74d7179954e124c7d8131c6addb11cad60e73478db74bcfe7f22c8c584ef41a0f2ed937b976411ef9c576ca3c71098538f3110e33970f7a935d503d6288cb603e03dbbc398af9f0006463c5bc9cd4db5de3d68137da7a2f813b5c98e60c109de2e8c42bb5a5706ef25d3fffd8d19a50bfd017301221f006f41c5ee1c4a1fe7d7b972335955b5aef187dff342eea4b9c1ef5d468946bdaf333d71aaa5756aac3eb8b03382f2ed9ad9000872651db6836319f955ab3331a3ebac5d5030400e307000002000000b0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafeb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe";

const txBlob = Buffer.from(txBlobStr, "hex");

const responseAddr = await app.getAddress(pathAccount, pathChange, pathIndex);
const pubKey = Buffer.from(responseAddr.pubKey, "hex");

// do not wait here.. we need to navigate
const signatureRequest = app.sign(pathAccount, pathChange, pathIndex, txBlob);
// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot());

await sim.compareSnapshotsAndAccept(".", "sign_large_nomination", 41);

let signatureResponse = await signatureRequest;
console.log(signatureResponse);

expect(signatureResponse.return_code).toEqual(0x9000);
expect(signatureResponse.error_message).toEqual("No errors");

// Now verify the signature
let prehash = txBlob;
if (txBlob.length > 256) {
const context = blake2bInit(32, null);
blake2bUpdate(context, txBlob);
prehash = Buffer.from(blake2bFinal(context));
}
const valid = ed25519.verify(signatureResponse.signature.slice(1), prehash, pubKey);
expect(valid).toEqual(true);
} finally {
await sim.close();
}
});

});

0 comments on commit 67e6479

Please sign in to comment.