Skip to content

Commit

Permalink
Test for clear signing a hash tx
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPxt committed Jan 14, 2025
1 parent 8f1af21 commit fb49c1a
Show file tree
Hide file tree
Showing 13 changed files with 43 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.
44 changes: 43 additions & 1 deletion tests_zemu/tests/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
******************************************************************************* */

import Zemu, {ButtonKind, isTouchDevice, TouchNavigation} from '@zondax/zemu'
import Zemu, {ButtonKind, isTouchDevice, TouchNavigation, zondaxMainmenuNavigation} from '@zondax/zemu'
import { KadenaApp, TransferTxType, TransferCrossChainTxParams } from '@zondax/ledger-kadena'
import { PATH, defaultOptions, models } from './common'
import { blake2bFinal, blake2bInit, blake2bUpdate } from 'blakejs'
Expand Down Expand Up @@ -100,6 +100,48 @@ describe.each(HASH_TEST_CASES)('Hash transactions', function (data) {
})
})

describe.each(HASH_TEST_CASES)('Hash transactions BLS off', function (data) {
test.concurrent.each(models)('clear sign hash', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...defaultOptions, model: m.name })
const app = new KadenaApp(sim.getTransport())

const responseAddr = await app.getAddressAndPubKey(data.path)
const pubKey = responseAddr.pubkey

const req = app.signHash(data.path, data.hash).catch(error => {
// Store the error to verify later, we are expecting signHash to fail
return error;
});

// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())

// Confirm "Go to settings" and toggle Blind Signing
const nav = new TouchNavigation(m.name, [
ButtonKind.ConfirmYesButton,
ButtonKind.ToggleSettingButton2,
ButtonKind.SettingsNavRightButton,
ButtonKind.SettingsNavRightButton,
ButtonKind.SettingsQuitButton,
]);
await sim.navigateAndCompareSnapshots('.', `${m.prefix.toLowerCase()}-clear_sign_${data.name}`, nav.schedule)

const result = await req;

// Verify the error, anything other than 0x6984 is not expected
expect(result).toMatchObject({
returnCode: 0x6984,
message: expect.stringContaining("Data is invalid")
});

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

describe.each(TRANSACTIONS_TEST_CASES)('Tx transfer', function (data) {
test.concurrent.each(models)('sign transfer tx', async function (m) {
const sim = new Zemu(m.path)
Expand Down

0 comments on commit fb49c1a

Please sign in to comment.