diff --git a/app/Makefile.version b/app/Makefile.version index 54f82061..8268a85e 100644 --- a/app/Makefile.version +++ b/app/Makefile.version @@ -3,4 +3,4 @@ APPVERSION_M=2 # This is the `spec_version` field of `Runtime` APPVERSION_N=34 # This is the patch version of this release -APPVERSION_P=1 +APPVERSION_P=2 diff --git a/tests/testcases/manual.json b/tests/testcases/manual.json index 2446ee81..1cea43e5 100644 --- a/tests/testcases/manual.json +++ b/tests/testcases/manual.json @@ -1840,5 +1840,43 @@ "7 | Gas : 200000" ], "expert": true + }, + { + "name": "minimal_extra_field", + "tx": { + "account_number": "V1", + "chain_id": "V2", + "fee": { + "amount": [ + { + "amount": "b" + }, + { + "c": "d" + }, + { + "x": "y" + } + ], + "gas": "V3" + }, + "foo": "bar", + "memo": "V4", + "msgs": [], + "sequence": "V5", + "unknown_param": "123456" + }, + "foo": "bar", + "parsingErr": "No error", + "validationErr": "Unexpected field", + "expected": [ + "0 | Chain ID : V2", + "1 | Account : V1", + "2 | Sequence : V5", + "3 | Memo : V4", + "4 | fee/amount : Unexpected field", + "5 | Gas : V3" + ], + "expert": true } ] diff --git a/tests_zemu/package.json b/tests_zemu/package.json index 882e74b5..29671cd8 100644 --- a/tests_zemu/package.json +++ b/tests_zemu/package.json @@ -18,7 +18,7 @@ "testSR25519": "jest --detectOpenHandles --runInBand tests/sr25519.test.ts" }, "dependencies": { - "@zondax/zemu": "^0.27.0-rc2", + "@zondax/zemu": "^0.27.4", "ledger-cosmos-js": "^2.1.8" }, "devDependencies": { diff --git a/tests_zemu/snapshots/s-mainmenu/00004.png b/tests_zemu/snapshots/s-mainmenu/00004.png index 641950a4..0fac4278 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00004.png and b/tests_zemu/snapshots/s-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00010.png b/tests_zemu/snapshots/s-mainmenu/00010.png index 641950a4..0fac4278 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00010.png and b/tests_zemu/snapshots/s-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00000.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00000.png new file mode 100644 index 00000000..49639ec9 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00000.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00001.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00001.png new file mode 100644 index 00000000..368d6198 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00001.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00002.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00002.png new file mode 100644 index 00000000..56fe9ab2 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00002.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00003.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00003.png new file mode 100644 index 00000000..9dae9154 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00003.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00004.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00004.png new file mode 100644 index 00000000..08fc31e0 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00004.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00005.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00005.png new file mode 100644 index 00000000..7ee7a7ba Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00005.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00006.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00006.png new file mode 100644 index 00000000..006c26ab Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00006.png differ diff --git a/tests_zemu/snapshots/s-sign_basic_extra_fields/00007.png b/tests_zemu/snapshots/s-sign_basic_extra_fields/00007.png new file mode 100644 index 00000000..131855e2 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_basic_extra_fields/00007.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00004.png b/tests_zemu/snapshots/sp-mainmenu/00004.png index 16bb08a0..c0ce7660 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00004.png and b/tests_zemu/snapshots/sp-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00010.png b/tests_zemu/snapshots/sp-mainmenu/00010.png index 16bb08a0..c0ce7660 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00010.png and b/tests_zemu/snapshots/sp-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/sp-sign_basic_extra_fields/00000.png b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00000.png differ diff --git a/tests_zemu/snapshots/sp-sign_basic_extra_fields/00001.png b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00001.png new file mode 100644 index 00000000..0f9cfb13 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00001.png differ diff --git a/tests_zemu/snapshots/sp-sign_basic_extra_fields/00002.png b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00002.png new file mode 100644 index 00000000..b47dabb4 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00002.png differ diff --git a/tests_zemu/snapshots/sp-sign_basic_extra_fields/00003.png b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00003.png new file mode 100644 index 00000000..4e0f2906 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00003.png differ diff --git a/tests_zemu/snapshots/sp-sign_basic_extra_fields/00004.png b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00004.png new file mode 100644 index 00000000..a51f4624 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00004.png differ diff --git a/tests_zemu/snapshots/sp-sign_basic_extra_fields/00005.png b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00005.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00005.png differ diff --git a/tests_zemu/snapshots/sp-sign_basic_extra_fields/00006.png b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00006.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_basic_extra_fields/00006.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00004.png b/tests_zemu/snapshots/x-mainmenu/00004.png index 16bb08a0..c0ce7660 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00004.png and b/tests_zemu/snapshots/x-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00010.png b/tests_zemu/snapshots/x-mainmenu/00010.png index 16bb08a0..c0ce7660 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00010.png and b/tests_zemu/snapshots/x-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00000.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00000.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00001.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00001.png new file mode 100644 index 00000000..0f9cfb13 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00001.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png new file mode 100644 index 00000000..b47dabb4 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png new file mode 100644 index 00000000..4e0f2906 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00004.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00004.png new file mode 100644 index 00000000..a51f4624 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00004.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00005.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00005.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00005.png differ diff --git a/tests_zemu/snapshots/x-sign_basic_extra_fields/00006.png b/tests_zemu/snapshots/x-sign_basic_extra_fields/00006.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_basic_extra_fields/00006.png differ diff --git a/tests_zemu/tests/common.ts b/tests_zemu/tests/common.ts index bdcf10ea..cd283595 100644 --- a/tests_zemu/tests/common.ts +++ b/tests_zemu/tests/common.ts @@ -163,3 +163,38 @@ export const example_tx_str_basic2 = { ], sequence: '6', } + +export const example_tx_str_basic_extra_fields = { + account_number: '108', + chain_id: 'cosmoshub-4', + extra_field: 'empty', + fee: { + amount: [ + { + amount: '600', + denom: 'uatom', + }, + ], + gas: '200000', + }, + foo: 'bar', + memo: '', + msgs: [ + { + type: 'cosmos-sdk/MsgWithdrawDelegationReward', + value: { + delegator_address: 'cosmos1w34k53py5v5xyluazqpq65agyajavep2rflq6h', + validator_address: 'cosmosvaloper1kn3wugetjuy4zetlq6wadchfhvu3x740ae6z6x', + }, + }, + { + type: 'cosmos-sdk/MsgWithdrawDelegationReward', + value: { + delegator_address: 'cosmos1w34k53py5v5xyluazqpq65agyajavep2rflq6h', + validator_address: 'cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0', + }, + }, + ], + sequence: '106', + unknown_field: 123456 +} diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index e96eaabe..e9436a85 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -107,8 +107,7 @@ describe('Standard', function () { const respRequest = app.showAddressAndPubKey(path, 'cosmos') // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) - - await sim.compareSnapshotsAndAccept('.', `${m.prefix.toLowerCase()}-show_address`, 2) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-show_address`) const resp = await respRequest console.log(resp) @@ -161,9 +160,7 @@ describe('Standard', function () { // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) - - // Now navigate the address / path - await sim.compareSnapshotsAndAccept('.', `${m.prefix.toLowerCase()}-show_address_huge`, 3) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-show_address_huge`) const resp = await respRequest console.log(resp) @@ -201,9 +198,7 @@ describe('Standard', function () { // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) - - // Now navigate the address / path - await sim.compareSnapshotsAndAccept('.', `${m.prefix.toLowerCase()}-sign_basic`, m.prefix == 'S' ? 6 : 5) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_basic`) const resp = await signatureRequest console.log(resp) @@ -248,15 +243,58 @@ describe('Standard', function () { // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_basic2`) + + const resp = await signatureRequest + console.log(resp) - // Now navigate the address / path - await sim.compareSnapshotsAndAccept('.', `${m.prefix.toLowerCase()}-sign_basic2`, m.prefix == 'S' ? 7 : 6) + expect(resp.return_code).toEqual(0x9000) + expect(resp.error_message).toEqual('No errors') + + // Now verify the signature + const hash = crypto.createHash('sha256') + const msgHash = Uint8Array.from(hash.update(tx).digest()) + + const signatureDER = resp.signature + const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER)) + + const pk = Uint8Array.from(respPk.compressed_pk) + + const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk) + expect(signatureOk).toEqual(true) + } finally { + await sim.close() + } + }) + + test.each(DEVICE_MODELS)('sign basic with extra fields', async function (m) { + const sim = new Zemu(m.path) + try { + await sim.start({ ...DEFAULT_OPTIONS, model: m.name }) + const app = new CosmosApp(sim.getTransport()) + + const path = [44, 118, 0, 0, 0] + const tx = JSON.stringify(example_tx_str_basic) + + // get address / publickey + const respPk = await app.getAddressAndPubKey(path, 'cosmos') + expect(respPk.return_code).toEqual(0x9000) + expect(respPk.error_message).toEqual('No errors') + console.log(respPk) + + // do not wait here.. + const signatureRequest = app.sign(path, tx) + + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_basic_extra_fields`) const resp = await signatureRequest console.log(resp) expect(resp.return_code).toEqual(0x9000) expect(resp.error_message).toEqual('No errors') + expect(resp).toHaveProperty('signature') // Now verify the signature const hash = crypto.createHash('sha256')