Skip to content

Commit

Permalink
improve zemu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Jul 19, 2024
1 parent a8564c4 commit a9a9865
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
21 changes: 5 additions & 16 deletions tests_zemu/tests/migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Zemu, { ButtonKind, ClickNavigation, TouchNavigation } from '@zondax/zemu
import { ASTAR_PATH, defaultOptions, DOT_SS58_PREFIX, migrationModels, PATH } from './common'
import { PolkadotGenericApp } from '@zondax/ledger-substrate'
import { IButton, SwipeDirection } from '@zondax/zemu/dist/types'
import { isTouchDevice } from '@zondax/zemu/dist/zondax'

const polkadot_pk = 'e1b4d72d27b3e91b9b6116555b4ea17138ddc12ca7cdbab30e2e0509bd848419'
const astar_pk = 'cf557b2d2bebf3e14f932fec31d2b3ea776b63eede6658e282c9ab3f27d1287b'
Expand All @@ -29,21 +30,9 @@ describe('Migration', function () {
test.concurrent.each(migrationModels)('main menu + get version', async function (m) {
const sim = new Zemu(m.path)
try {
let migrationStartText = ''
switch (m.name) {
case 'nanos':
migrationStartText = 'Migration'
break;

case 'nanosp':
case 'nanox':
migrationStartText = 'Please'
break;

case 'stax':
case 'flex':
migrationStartText = 'Review'
break;
let migrationStartText = 'review'
if (m.name === 'nanos') {
migrationStartText = 'Migration'
}

await sim.start({
Expand All @@ -53,7 +42,7 @@ describe('Migration', function () {
})

let nav = undefined;
if (m.name === 'stax' || m.name === "flex") {
if (isTouchDevice(m.name)) {
const okButton: IButton = {
x: 200,
y: 550,
Expand Down
5 changes: 3 additions & 2 deletions tests_zemu/tests/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import Zemu, { ButtonKind, zondaxMainmenuNavigation } from '@zondax/zemu'
import { defaultOptions, DOT_SS58_PREFIX, PATH, models } from './common'
import { PolkadotGenericApp } from '@zondax/ledger-substrate'
import { isTouchDevice } from '@zondax/zemu/dist/zondax'

const expected_address = '166wVhuQsKFeb7bd1faydHgVvX1bZU2rUuY7FJmWApNz2fQY'
const expected_pk = 'e1b4d72d27b3e91b9b6116555b4ea17138ddc12ca7cdbab30e2e0509bd848419'
Expand Down Expand Up @@ -85,7 +86,7 @@ describe('Standard', function () {
await sim.start({
...defaultOptions,
model: m.name,
approveKeyword: (m.name === 'stax' || m.name === 'flex') ? 'Public key' : '',
approveKeyword: isTouchDevice(m.name) ? 'Public key' : '',
approveAction: ButtonKind.ApproveTapButton,
})
const app = new PolkadotGenericApp(sim.getTransport(), 'dot', '')
Expand All @@ -112,7 +113,7 @@ describe('Standard', function () {
await sim.start({
...defaultOptions,
model: m.name,
rejectKeyword: (m.name === 'stax' || m.name === 'flex') ? 'Public key' : '',
rejectKeyword: isTouchDevice(m.name) ? 'Public key' : '',
})
const app = new PolkadotGenericApp(sim.getTransport(), 'dot')

Expand Down

0 comments on commit a9a9865

Please sign in to comment.