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

Commit

Permalink
add proxy transfer keep alive zemu test
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed May 12, 2022
1 parent 3cff72a commit c1acc78
Show file tree
Hide file tree
Showing 33 changed files with 44 additions and 1 deletion.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests_zemu/tests/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ export const models: DeviceModel[] = [
{ name: 'nanox', prefix: 'X', path: APP_PATH_X },
{ name: 'nanosp', prefix: 'SP', path: APP_PATH_SP },
]

export const txProxy_proxy_transferKeepAlive =
'1e0030e9b187efd17adfd88a3beba6917378a27dffdaebd6ccb5d4bd36933ccd572c010004030030e9b187efd17adfd88a3beba6917378a27dffdaebd6ccb5d4bd36933ccd572c07f0a03ff4e56503001b00b07a81791a1dc3aa75e62300000b000000b0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe463dccc3c2a833249b90b4c1911b55be117763f3b40377e7b1802b3d7263ea8f'

41 changes: 40 additions & 1 deletion tests_zemu/tests/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Zemu, { DEFAULT_START_OPTIONS } from '@zondax/zemu'
import { newKusamaApp } from '@zondax/ledger-substrate'
import { APP_SEED, models } from './common'
import { APP_SEED, models, txProxy_proxy_transferKeepAlive } from './common'
import { txBalances_transfer, txSession_setKeys, txStaking_nominate } from './zemu_blobs'

// @ts-ignore
Expand Down Expand Up @@ -314,4 +314,43 @@ describe('Standard', function () {
await sim.close()
}
})

test.each(models)('Proxy proxy transferKeepAlive', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...defaultOptions, model: m.name })
const app = newKusamaApp(sim.getTransport())
const pathAccount = 0x80000000
const pathChange = 0x80000000
const pathIndex = 0x80000000

const txBlob = Buffer.from(txProxy_proxy_transferKeepAlive, '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)
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-proxy_transfer_keepAlive`)

const 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)
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 c1acc78

Please sign in to comment.