diff --git a/tests_zemu/tests/amino.test.ts b/tests_zemu/tests/amino.test.ts index 9bc28d0f..97f0cf99 100644 --- a/tests_zemu/tests/amino.test.ts +++ b/tests_zemu/tests/amino.test.ts @@ -16,7 +16,7 @@ import Zemu, { ClickNavigation, TouchNavigation } from '@zondax/zemu' // @ts-ignore -import { CosmosApp } from '@zondax/ledger-cosmos-js' +import CosmosApp from '@zondax/ledger-cosmos-js' import { defaultOptions, DEVICE_MODELS, @@ -38,7 +38,7 @@ import { ButtonKind, IButton } from '@zondax/zemu/dist/types' jest.setTimeout(120000) describe('Amino', function () { - // eslint-disable-next-line jest/expect-expect + //eslint-disable-next-line jest/expect-expect test.concurrent.each(DEVICE_MODELS)('can start and stop container', async function (m) { const sim = new Zemu(m.path) try { @@ -54,14 +54,13 @@ describe('Amino', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 118, 0, 0, 0] - const tx = Buffer.from(JSON.stringify(example_tx_str_basic), "utf-8") + const path = "m/44'/118'/0'/0/0" + const tx = Buffer.from(JSON.stringify(example_tx_str_basic), 'utf-8') const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') + console.log(respPk) // do not wait here.. @@ -74,8 +73,6 @@ describe('Amino', function () { 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 @@ -100,14 +97,12 @@ describe('Amino', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(JSON.stringify(example_tx_str_basic2)) const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -120,9 +115,6 @@ describe('Amino', function () { const resp = await signatureRequest console.log(resp) - 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()) @@ -145,14 +137,12 @@ describe('Amino', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(JSON.stringify(example_tx_str_basic)) const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -164,9 +154,6 @@ describe('Amino', function () { 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 @@ -191,14 +178,12 @@ describe('Amino', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(JSON.stringify(ibc_denoms)) const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -210,9 +195,6 @@ describe('Amino', function () { 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 @@ -237,14 +219,12 @@ describe('Amino', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(JSON.stringify(setWithdrawAddress)) const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -256,9 +236,6 @@ describe('Amino', function () { 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 @@ -283,14 +260,12 @@ describe('Amino', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(JSON.stringify(cliGovDeposit)) const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -303,8 +278,6 @@ describe('Amino', function () { 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 @@ -330,16 +303,14 @@ describe('Amino', function () { const app = new CosmosApp(sim.getTransport()) // Activate expert mode - await sim.toggleExpertMode(); + await sim.toggleExpertMode() - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(JSON.stringify(example_tx_str_msgMultiSend)) const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -352,8 +323,6 @@ describe('Amino', function () { 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 @@ -379,16 +348,14 @@ describe('Amino', function () { const app = new CosmosApp(sim.getTransport()) // Change to expert mode so we can skip fields - await sim.toggleExpertMode(); + await sim.toggleExpertMode() - const path = [44, 60, 0, 0, 0] + const path = "m/44'/60'/0'/0/0" const tx = Buffer.from(JSON.stringify(setWithdrawAddress)) const hrp = 'inj' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -401,8 +368,6 @@ describe('Amino', function () { 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 @@ -428,48 +393,44 @@ describe('Amino', function () { const app = new CosmosApp(sim.getTransport()) // Enable expert to allow sign with eth path - await sim.toggleExpertMode(); + await sim.toggleExpertMode() - const path = [44, 60, 0, 0, 0] - const tx = Buffer.from(JSON.stringify(example_tx_str_basic), "utf-8") + const path = "m/44'/60'/0'/0/0" + const tx = Buffer.from(JSON.stringify(example_tx_str_basic), 'utf-8') const hrp = 'inj' // check with invalid HRP - const errorRespPk = await app.getAddressAndPubKey(path, 'forbiddenHRP') - expect(errorRespPk.return_code).toEqual(0x6986) - expect(errorRespPk.error_message).toEqual('Transaction rejected') + try { + const errorRespPk = await app.getAddressAndPubKey(path, 'forbiddenHRP') - // do not wait here.. - const signatureRequest = app.sign(path, tx, hrp) - - // Wait until we are not in the main menu - await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) - await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_basic_eth`) + // do not wait here.. + const signatureRequest = app.sign(path, tx, hrp) - const resp = await signatureRequest - console.log(resp) + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_basic_eth`) - expect(resp.return_code).toEqual(0x9000) - expect(resp.error_message).toEqual('No errors') - expect(resp).toHaveProperty('signature') + const resp = await signatureRequest + console.log(resp) - // get address / publickey - const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') - console.log(respPk) + // get address / publickey + const respPk = await app.getAddressAndPubKey(path, hrp) + console.log(respPk) - // Now verify the signature - const sha3 = require('js-sha3') - const msgHash = Buffer.from(sha3.keccak256(tx), 'hex') + // Now verify the signature + const sha3 = require('js-sha3') + const msgHash = Buffer.from(sha3.keccak256(tx), 'hex') - const signatureDER = resp.signature - const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER)) + const signatureDER = resp.signature + const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER)) - const pk = Uint8Array.from(respPk.compressed_pk) + const pk = Uint8Array.from(respPk.compressed_pk) - const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk) - expect(signatureOk).toEqual(true) + const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk) + expect(signatureOk).toEqual(true) + } catch (e: any) { + expect(e.message).toEqual('Transaction rejected') + } } finally { await sim.close() } @@ -481,40 +442,37 @@ describe('Amino', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 60, 0, 0, 0] - const tx = Buffer.from(JSON.stringify(example_tx_str_basic), "utf-8") - - // get address / publickey - const respPk = await app.getAddressAndPubKey(path, 'inj') - 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()) - let nav = undefined; - if (m.name === 'stax') { - const okButton: IButton = { - x: 200, - y: 540, - delay: 0.25, - }; - nav = new TouchNavigation([ - ButtonKind.ConfirmYesButton, - ]); - nav.schedule[0].button = okButton; - } else { - nav = new ClickNavigation([1, 0]); + const path = "m/44'/60'/0'/0/0" + const tx = Buffer.from(JSON.stringify(example_tx_str_basic), 'utf-8') + + try { + // get address / publickey + const respPk = await app.getAddressAndPubKey(path, 'inj') + + // do not wait here.. + const signatureRequest = app.sign(path, tx, 'inj') + + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + let nav = undefined + if (m.name === 'stax') { + const okButton: IButton = { + x: 200, + y: 540, + delay: 0.25, + } + nav = new TouchNavigation([ButtonKind.ConfirmYesButton]) + nav.schedule[0].button = okButton + } else { + nav = new ClickNavigation([1, 0]) + } + await sim.navigate('.', `${m.prefix.toLowerCase()}-sign_basic_eth_warning`, nav.schedule) + + const resp = await signatureRequest + console.log(resp) + } catch (e: any) { + expect(e.message).toEqual('Data is invalid') } - await sim.navigate('.', `${m.prefix.toLowerCase()}-sign_basic_eth_warning`, nav.schedule); - - const resp = await signatureRequest - console.log(resp) - - expect(resp.return_code).toEqual(0x6984) } finally { await sim.close() } diff --git a/tests_zemu/tests/common.ts b/tests_zemu/tests/common.ts index 722cae2a..991cb0b4 100644 --- a/tests_zemu/tests/common.ts +++ b/tests_zemu/tests/common.ts @@ -36,8 +36,8 @@ export const defaultOptions = { export const DEVICE_MODELS: IDeviceModel[] = [ { name: 'nanos', prefix: 'S', path: APP_PATH_S }, { name: 'nanox', prefix: 'X', path: APP_PATH_X }, - { name: 'nanosp', prefix: 'SP', path: APP_PATH_SP }, - { name: 'stax', prefix: 'ST', path: APP_PATH_ST }, + //{ name: 'nanosp', prefix: 'SP', path: APP_PATH_SP }, + //{ name: 'stax', prefix: 'ST', path: APP_PATH_ST }, ] export const tx_sign_textual = 'a10192a20168436861696e20696402686d792d636861696ea2016e4163636f756e74206e756d626572026131a2016853657175656e6365026132a301674164647265737302782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e767161386579687304f5a3016a5075626c6963206b657902781f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657904f5a3026d5075624b6579206f626a656374030104f5a401634b657902785230324542204444374620453446442045423736204443384120323035452046363544203739304320443330452038413337203541354320323532382045423341203932334120463146422034443739203444030204f5a102781e54686973207472616e73616374696f6e206861732031204d657373616765a3016d4d6573736167652028312f312902781c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e640301a2026e4d736753656e64206f626a6563740302a3016c46726f6d206164647265737302782d636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730303a3016a546f206164647265737302782d636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b6835740303a30166416d6f756e74026731302041544f4d0303a1026e456e64206f66204d657373616765a201644d656d6f0278193e20e29a9befb88f5c7532363942e29a9befb88f2020202020a2016446656573026a302e3030322041544f4da30169476173206c696d697402673130302730303004f5a3017148617368206f66207261772062797465730278403963303433323930313039633237306232666661396633633066613535613039306330313235656265663838316637646135333937386462663933663733383504f5' diff --git a/tests_zemu/tests/standard.test.ts b/tests_zemu/tests/standard.test.ts index 9ec51ca4..856af6e7 100644 --- a/tests_zemu/tests/standard.test.ts +++ b/tests_zemu/tests/standard.test.ts @@ -15,7 +15,7 @@ ******************************************************************************* */ import Zemu, { zondaxMainmenuNavigation, ButtonKind, ClickNavigation, TouchNavigation } from '@zondax/zemu' -import { CosmosApp } from '@zondax/ledger-cosmos-js' +import CosmosApp from '@zondax/ledger-cosmos-js' import { defaultOptions, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2, ibc_denoms } from './common' // @ts-ignore @@ -56,12 +56,11 @@ describe('Standard', function () { console.log(resp) - expect(resp.return_code).toEqual(0x9000) - expect(resp.error_message).toEqual('No errors') - expect(resp).toHaveProperty('test_mode') + expect(resp).toHaveProperty('testMode') expect(resp).toHaveProperty('major') expect(resp).toHaveProperty('minor') expect(resp).toHaveProperty('patch') + expect(resp.testMode).toEqual(false) } finally { await sim.close() } @@ -74,20 +73,17 @@ describe('Standard', function () { const app = new CosmosApp(sim.getTransport()) // Derivation path. First 3 items are automatically hardened! - const path = [44, 118, 5, 0, 3] + const path = "m/44'/118'/5'/0/3" const resp = await app.getAddressAndPubKey(path, 'cosmos') console.log(resp) - expect(resp.return_code).toEqual(0x9000) - expect(resp.error_message).toEqual('No errors') - expect(resp).toHaveProperty('bech32_address') expect(resp).toHaveProperty('compressed_pk') expect(resp.bech32_address).toEqual('cosmos1wkd9tfm5pqvhhaxq77wv9tvjcsazuaykwsld65') expect(resp.compressed_pk.length).toEqual(33) - expect(resp.compressed_pk.toString("hex")).toEqual('035c986b9ae5fbfb8e1e9c12c817f5ef8fdb821cdecaa407f1420ec4f8f1d766bf') + expect(resp.compressed_pk.toString('hex')).toEqual('035c986b9ae5fbfb8e1e9c12c817f5ef8fdb821cdecaa407f1420ec4f8f1d766bf') } finally { await sim.close() } @@ -105,7 +101,7 @@ describe('Standard', function () { const app = new CosmosApp(sim.getTransport()) // Derivation path. First 3 items are automatically hardened! - const path = [44, 118, 5, 0, 3] + const path = "m/44'/118'/5'/0/3" const respRequest = app.showAddressAndPubKey(path, 'cosmos') // Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) @@ -114,21 +110,18 @@ describe('Standard', function () { const resp = await respRequest console.log(resp) - expect(resp.return_code).toEqual(0x9000) - expect(resp.error_message).toEqual('No errors') - expect(resp).toHaveProperty('bech32_address') expect(resp).toHaveProperty('compressed_pk') expect(resp.bech32_address).toEqual('cosmos1wkd9tfm5pqvhhaxq77wv9tvjcsazuaykwsld65') expect(resp.compressed_pk.length).toEqual(33) - expect(resp.compressed_pk.toString("hex")).toEqual('035c986b9ae5fbfb8e1e9c12c817f5ef8fdb821cdecaa407f1420ec4f8f1d766bf') + expect(resp.compressed_pk.toString('hex')).toEqual('035c986b9ae5fbfb8e1e9c12c817f5ef8fdb821cdecaa407f1420ec4f8f1d766bf') } finally { await sim.close() } - }) + }) - test.concurrent.each(DEVICE_MODELS)('show Eth address', async function (m) { + test.concurrent.each(DEVICE_MODELS)('show Eth address', async function (m) { const sim = new Zemu(m.path) try { await sim.start({ @@ -140,13 +133,15 @@ describe('Standard', function () { const app = new CosmosApp(sim.getTransport()) // Derivation path. First 3 items are automatically hardened! - const path = [44, 60, 0, 0, 1] + const path = "m/44'/60'/0'/0/1" const hrp = 'inj' - // check with invalid HRP - const errorRespPk = await app.getAddressAndPubKey(path, 'cosmos') - expect(errorRespPk.return_code).toEqual(0x6986) - expect(errorRespPk.error_message).toEqual('Transaction rejected') + try { + // check with invalid HRP + const errorRespPk = await app.getAddressAndPubKey(path, 'cosmos') + } catch (e: any) { + expect(e.message).toEqual('Transaction rejected') + } const respRequest = app.showAddressAndPubKey(path, hrp) // Wait until we are not in the main menu @@ -156,23 +151,20 @@ describe('Standard', function () { const resp = await respRequest console.log(resp) - expect(resp.return_code).toEqual(0x9000) - expect(resp.error_message).toEqual('No errors') - expect(resp).toHaveProperty('bech32_address') expect(resp).toHaveProperty('compressed_pk') expect(resp.compressed_pk.length).toEqual(33) // Verify address - const secp256k1 = require("secp256k1"); - const keccak = require("keccak256"); - const { bech32 } = require("bech32"); + const secp256k1 = require('secp256k1') + const keccak = require('keccak256') + const { bech32 } = require('bech32') // Take the compressed pubkey and verify that the expected address can be computed - const uncompressPubKeyUint8Array = secp256k1.publicKeyConvert(resp.compressed_pk, false).subarray(1); - const ethereumAddressBuffer = Buffer.from(keccak(Buffer.from(uncompressPubKeyUint8Array))).subarray(-20); - const eth_address = bech32.encode(hrp, bech32.toWords(ethereumAddressBuffer)); // "cosmos15n2h0lzvfgc8x4fm6fdya89n78x6ee2fm7fxr3" + const uncompressPubKeyUint8Array = secp256k1.publicKeyConvert(resp.compressed_pk, false).subarray(1) + const ethereumAddressBuffer = Buffer.from(keccak(Buffer.from(uncompressPubKeyUint8Array))).subarray(-20) + const eth_address = bech32.encode(hrp, bech32.toWords(ethereumAddressBuffer)) // "cosmos15n2h0lzvfgc8x4fm6fdya89n78x6ee2fm7fxr3" expect(resp.bech32_address).toEqual(eth_address) expect(resp.bech32_address).toEqual('inj15n2h0lzvfgc8x4fm6fdya89n78x6ee2f3h7z3f') @@ -193,12 +185,14 @@ describe('Standard', function () { const app = new CosmosApp(sim.getTransport()) // Derivation path. First 3 items are automatically hardened! - const path = [44, 118, 2147483647, 0, 4294967295] - const resp = await app.showAddressAndPubKey(path, 'cosmos') - console.log(resp) - - expect(resp.return_code).toEqual(0x6985) - expect(resp.error_message).toEqual('Conditions not satisfied') + const path = "m/44'/2147483647'/0'/0/4294967295" + + try { + // check with invalid HRP + const resp = await app.getAddressAndPubKey(path, 'cosmos') + } catch (e: any) { + expect(e.message).toEqual('Data is invalid') + } } finally { await sim.close() } @@ -219,19 +213,17 @@ describe('Standard', function () { await sim.toggleExpertMode(); // Derivation path. First 3 items are automatically hardened! - const path = [44, 118, 2147483647, 0, 4294967295] + const path = "m/44'/118'/2147483647'/0/4294967295" + const respRequest = app.showAddressAndPubKey(path, 'cosmos') - // Wait until we are not in the main menu + //Wait until we are not in the main menu await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-show_address_huge`) const resp = await respRequest console.log(resp) - expect(resp.return_code).toEqual(0x9000) - expect(resp.error_message).toEqual('No errors') - expect(resp).toHaveProperty('bech32_address') expect(resp).toHaveProperty('compressed_pk') diff --git a/tests_zemu/tests/textual.test.ts b/tests_zemu/tests/textual.test.ts index 495d2a17..4968e0c6 100644 --- a/tests_zemu/tests/textual.test.ts +++ b/tests_zemu/tests/textual.test.ts @@ -16,7 +16,7 @@ import Zemu, { ClickNavigation, TouchNavigation } from '@zondax/zemu' // @ts-ignore -import { CosmosApp } from '@zondax/ledger-cosmos-js' +import CosmosApp from '@zondax/ledger-cosmos-js' import { defaultOptions, DEVICE_MODELS, tx_sign_textual, TEXTUAL_TX } from './common' // @ts-ignore import secp256k1 from 'secp256k1/elliptic' @@ -43,14 +43,12 @@ describe('Textual', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(tx_sign_textual, 'hex') const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -62,9 +60,6 @@ describe('Textual', function () { 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 @@ -92,14 +87,12 @@ describe('Textual', function () { // Change to expert mode so we can skip fields await sim.toggleExpertMode() - const path = [44, 118, 0, 0, 0] + const path = "m/44'/118'/0'/0/0" const tx = Buffer.from(tx_sign_textual, 'hex') const hrp = 'cosmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -111,9 +104,6 @@ describe('Textual', function () { 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 @@ -139,16 +129,14 @@ describe('Textual', function () { const app = new CosmosApp(sim.getTransport()) // Enable expert to allow sign with eth path - await sim.toggleExpertMode(); + await sim.toggleExpertMode() - const path = [44, 60, 0, 0, 0] + const path = "m/44'/60'/0'/0/0" const tx = Buffer.from(tx_sign_textual, 'hex') const hrp = 'inj' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -160,9 +148,6 @@ describe('Textual', function () { 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 @@ -187,41 +172,38 @@ describe('Textual', function () { await sim.start({ ...defaultOptions, model: m.name }) const app = new CosmosApp(sim.getTransport()) - const path = [44, 60, 0, 0, 0] + const path = "m/44'/60'/0'/0/0" const tx = Buffer.from(tx_sign_textual, 'hex') const hrp = 'inj' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - 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, hrp, TEXTUAL_TX) - - // Wait until we are not in the main menu - await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) - let nav = undefined; - if (m.name === 'stax') { - const okButton: IButton = { - x: 200, - y: 540, - delay: 0.25, - }; - nav = new TouchNavigation([ - ButtonKind.ConfirmYesButton, - ]); - nav.schedule[0].button = okButton; - } else { - nav = new ClickNavigation([1, 0]); + try { + const signatureRequest = app.sign(path, tx, hrp, TEXTUAL_TX) + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + let nav = undefined + if (m.name === 'stax') { + const okButton: IButton = { + x: 200, + y: 540, + delay: 0.25, + } + nav = new TouchNavigation([ButtonKind.ConfirmYesButton]) + nav.schedule[0].button = okButton + } else { + nav = new ClickNavigation([1, 0]) + } + await sim.navigate('.', `${m.prefix.toLowerCase()}-textual-sign_basic_eth_warning`, nav.schedule) + + const resp = await signatureRequest + console.log(resp) + } catch (e: any) { + expect(e.message).toEqual('Data is invalid') } - await sim.navigate('.', `${m.prefix.toLowerCase()}-textual-sign_basic_eth_warning`, nav.schedule); - - const resp = await signatureRequest - console.log(resp) - - expect(resp.return_code).toEqual(0x6984) } finally { await sim.close() } @@ -236,14 +218,12 @@ describe('Textual', function () { // Enable expert to allow sign with eth path await sim.toggleExpertMode() - const path = [44, 60, 0, 0, 0] + const path = "m/44'/60'/0'/0/0" const tx = Buffer.from(tx_sign_textual, 'hex') const hrp = 'evmos' // get address / publickey const respPk = await app.getAddressAndPubKey(path, hrp) - expect(respPk.return_code).toEqual(0x9000) - expect(respPk.error_message).toEqual('No errors') console.log(respPk) // do not wait here.. @@ -262,8 +242,6 @@ describe('Textual', function () { 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