Skip to content

Commit

Permalink
zemu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Jun 19, 2024
1 parent c8e8fcf commit 73f2e4b
Show file tree
Hide file tree
Showing 48 changed files with 67 additions and 69 deletions.
Binary file added tests_zemu/snapshots/sp-blind_sign/00000.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/sp-blind_sign/00001.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/sp-blind_sign/00002.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/sp-blind_sign/00003.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/sp-blind_sign/00004.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/sp-blind_sign/00005.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/sp-blind_sign/00006.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/sp-blind_sign/00007.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/sp-blind_sign/00008.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/sp-blind_sign2/00000.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/sp-blind_sign2/00001.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/sp-blind_sign2/00002.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/sp-blind_sign2/00003.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/sp-blind_sign2/00004.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/sp-blind_sign2/00005.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/sp-blind_sign2/00006.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/sp-blind_sign2/00007.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/sp-blind_sign2/00008.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/st-blind_sign/00000.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/st-blind_sign/00001.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/st-blind_sign/00002.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/st-blind_sign/00003.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/st-blind_sign/00004.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/st-blind_sign2/00000.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/st-blind_sign2/00001.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/st-blind_sign2/00002.png
Binary file added tests_zemu/snapshots/st-blind_sign2/00003.png
Binary file added tests_zemu/snapshots/st-blind_sign2/00004.png
Binary file added tests_zemu/snapshots/x-blind_sign/00000.png
Binary file added tests_zemu/snapshots/x-blind_sign/00001.png
Binary file added tests_zemu/snapshots/x-blind_sign/00002.png
Binary file added tests_zemu/snapshots/x-blind_sign/00003.png
Binary file added tests_zemu/snapshots/x-blind_sign/00004.png
Binary file added tests_zemu/snapshots/x-blind_sign/00005.png
Binary file added tests_zemu/snapshots/x-blind_sign/00006.png
Binary file added tests_zemu/snapshots/x-blind_sign/00007.png
Binary file added tests_zemu/snapshots/x-blind_sign/00008.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00000.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00001.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00002.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00003.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00004.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00005.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00006.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00007.png
Binary file added tests_zemu/snapshots/x-blind_sign2/00008.png
9 changes: 6 additions & 3 deletions tests_zemu/tests/common.ts

Large diffs are not rendered by default.

127 changes: 61 additions & 66 deletions tests_zemu/tests/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
******************************************************************************* */

import Zemu, { ButtonKind, zondaxMainmenuNavigation } from '@zondax/zemu'
import { PATH, defaultOptions, expectedKeys, models, txBlobExample } from './common'
import { PATH, defaultOptions, expectedKeys, models, spend_1_output_1, spend_1_output_4_mint_1_burn_1, txBlobExample } from './common'
import IronfishApp, { IronfishKeys, ResponseAddress, ResponseProofGenKey, ResponseViewKey } from '@zondax/ledger-ironfish'

jest.setTimeout(60000)
jest.setTimeout(20000)

describe('Standard', function () {
test.concurrent.each(models)('can start and stop container', async function (m) {
Expand Down Expand Up @@ -167,68 +167,63 @@ describe('Standard', function () {
}
})

// #{TODO} --> Add Zemu tests for different transactions. Include expert mode if needed
// test.concurrent.each(models)('sign tx0 normal', async function (m) {
// const sim = new Zemu(m.path)
// try {
// await sim.start({ ...defaultOptions, model: m.name })
// const app = new TemplateApp(sim.getTransport())

// const txBlob = Buffer.from(txBlobExample)
// const responseAddr = await app.getAddressAndPubKey(accountId)
// const pubKey = responseAddr.publicKey

// // do not wait here.. we need to navigate
// const signatureRequest = app.sign(accountId, txBlob)

// // Wait until we are not in the main menu
// await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
// await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_freeze`,50000)

// const signatureResponse = await signatureRequest
// console.log(signatureResponse)

// expect(signatureResponse.return_code).toEqual(0x9000)
// expect(signatureResponse.error_message).toEqual('No errors')

// // Now verify the signature
// const prehash = Buffer.concat([Buffer.from('TX'), txBlob]);
// const valid = ed25519.verify(signatureResponse.signature, prehash, pubKey)
// expect(valid).toEqual(true)
// } finally {
// await sim.close()
// }
// })

// test.concurrent.each(models)('sign tx1 normal', async function (m) {
// const sim = new Zemu(m.path)
// try {
// await sim.start({ ...defaultOptions, model: m.name })
// const app = new TemplateApp(sim.getTransport())

// const txBlob = Buffer.from(txBlobExample)
// const responseAddr = await app.getAddressAndPubKey(accountId)
// const pubKey = responseAddr.publicKey

// // do not wait here.. we need to navigate
// const signatureRequest = app.sign(accountId, txBlob)

// // Wait until we are not in the main menu
// await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
// await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-sign_asset_freeze`,50000)

// const signatureResponse = await signatureRequest
// console.log(signatureResponse)

// expect(signatureResponse.return_code).toEqual(0x9000)
// expect(signatureResponse.error_message).toEqual('No errors')

// // Now verify the signature
// const prehash = Buffer.concat([Buffer.from('TX'), txBlob]);
// const valid = ed25519.verify(signatureResponse.signature, prehash, pubKey)
// expect(valid).toEqual(true)
// } finally {
// await sim.close()
// }
// })
test.concurrent.each(models)('blind-signing', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...defaultOptions, model: m.name })
const app = new IronfishApp(sim.getTransport())

const txBlob = Buffer.from(spend_1_output_1, 'hex')
const responsePublicAddress = await app.retrieveKeys(PATH, IronfishKeys.PublicAddress, false);
console.log(responsePublicAddress)

// do not wait here.. we need to navigate
const signatureRequest = app.sign(PATH, txBlob,)

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-blind_sign`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)

console.log(signatureResponse.signatures?.length)

expect(signatureResponse.returnCode).toEqual(0x9000)
expect(signatureResponse.errorMessage).toEqual('No errors')

} finally {
await sim.close()
}
})

test.only.each(models)('blind-signing2', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...defaultOptions, model: m.name })
const app = new IronfishApp(sim.getTransport())

const txBlob = Buffer.from(spend_1_output_4_mint_1_burn_1, 'hex')
const responsePublicAddress = await app.retrieveKeys(PATH, IronfishKeys.PublicAddress, false);
console.log(responsePublicAddress)

// do not wait here.. we need to navigate
const signatureRequest = app.sign(PATH, txBlob,)

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-blind_sign2`)

const signatureResponse = await signatureRequest
console.log(signatureResponse)

console.log(signatureResponse.signatures?.length)

expect(signatureResponse.returnCode).toEqual(0x9000)
expect(signatureResponse.errorMessage).toEqual('No errors')

} finally {
await sim.close()
}
})
})

0 comments on commit 73f2e4b

Please sign in to comment.