Skip to content

Commit

Permalink
shore: Update test name
Browse files Browse the repository at this point in the history
  • Loading branch information
neithanmo committed Apr 28, 2024
1 parent c6ae575 commit 9ce99b8
Showing 1 changed file with 88 additions and 103 deletions.
191 changes: 88 additions & 103 deletions tests_zemu/tests/addr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,110 +23,95 @@ const defaultOptions = (model: any) => {
return commonOpts(model, true)
}

const EXPECTED_PUBLIC_KEY = '02c6f477ff8e7136de982f898f6bfe93136bbe8dada6c17d0cd369acce90036ac4';
const EXPECTED_PUBLIC_KEY = '02c6f477ff8e7136de982f898f6bfe93136bbe8dada6c17d0cd369acce90036ac4'

jest.setTimeout(200000)

describe.each(models)('Standard [%s] - pubkey', function (m) {
test.concurrent(
'get pubkey and addr',
async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const resp = await app.getAddressAndPubKey(APP_DERIVATION, false)

console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
expect(resp.publicKey.toString('hex')).toEqual(EXPECTED_PUBLIC_KEY)
expect(resp.address).toEqual('P-avax1tlq4m9js4ckqvz9umfz7tjxna3yysm79r2jz8e')
} finally {
await sim.close()
}
},
);

test.concurrent(
'show addr',
async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const respReq = app.getAddressAndPubKey(APP_DERIVATION, true)

await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-addr`);

const resp = await respReq;
console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
} finally {
await sim.close()
}
},
);

test.concurrent(
'get addr with custom hrp & chainID addr',
async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const resp = await app.getAddressAndPubKey(APP_DERIVATION, false,
"zemu", bs58_encode(Buffer.alloc(32, 42)))

console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
expect(resp.address).toEqual('Ka3NKcnfs8d67EZYU5mbTCVY7Znnd2YQAYjbBfb4XmeWJuCGa'
+ '-zemu1tlq4m9js4ckqvz9umfz7tjxna3yysm79zy94y7')
} finally {
await sim.close()
}
},
);

test.concurrent(
'show custom hrp & chainID addr',
async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const respReq = app.getAddressAndPubKey(APP_DERIVATION, true,
"zemu", bs58_encode(Buffer.alloc(32, 42)))

await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-zemu-addr`);

const resp = await respReq;
console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
} finally {
await sim.close()
}
},
);
describe.each(models)('StandardPubKey [%s] - pubkey', function (m) {
test.concurrent('get pubkey and addr', async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const resp = await app.getAddressAndPubKey(APP_DERIVATION, false)

console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
expect(resp.publicKey.toString('hex')).toEqual(EXPECTED_PUBLIC_KEY)
expect(resp.address).toEqual('P-avax1tlq4m9js4ckqvz9umfz7tjxna3yysm79r2jz8e')
} finally {
await sim.close()
}
})

test.concurrent('show addr', async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const respReq = app.getAddressAndPubKey(APP_DERIVATION, true)

await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-addr`)

const resp = await respReq
console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
} finally {
await sim.close()
}
})

test.concurrent('get addr with custom hrp & chainID addr', async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const resp = await app.getAddressAndPubKey(APP_DERIVATION, false, 'zemu', bs58_encode(Buffer.alloc(32, 42)))

console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
expect(resp.address).toEqual('Ka3NKcnfs8d67EZYU5mbTCVY7Znnd2YQAYjbBfb4XmeWJuCGa' + '-zemu1tlq4m9js4ckqvz9umfz7tjxna3yysm79zy94y7')
} finally {
await sim.close()
}
})

test.concurrent('show custom hrp & chainID addr', async function () {
const sim = new Zemu(m.path)
try {
await sim.start(defaultOptions(m))
const app = new AvalancheApp(sim.getTransport())
const respReq = app.getAddressAndPubKey(APP_DERIVATION, true, 'zemu', bs58_encode(Buffer.alloc(32, 42)))

await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-zemu-addr`)

const resp = await respReq
console.log(resp, m.name)

expect(resp.returnCode).toEqual(0x9000)
expect(resp.errorMessage).toEqual('No errors')
expect(resp).toHaveProperty('publicKey')
expect(resp).toHaveProperty('hash')
expect(resp).toHaveProperty('address')
} finally {
await sim.close()
}
})
})

0 comments on commit 9ce99b8

Please sign in to comment.