From dd0747cdee1917f2546c7a3a2ce639fa10c17814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matev=C5=BE=20Jekovec?= Date: Tue, 29 Mar 2022 16:18:21 +0200 Subject: [PATCH] tests: Fix saga tests --- src/app/lib/ledger.test.ts | 6 +++--- src/app/state/ledger/saga.test.ts | 4 ++++ src/app/state/wallet/saga.test.ts | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/lib/ledger.test.ts b/src/app/lib/ledger.test.ts index 93775a00ea..e42fadd329 100644 --- a/src/app/lib/ledger.test.ts +++ b/src/app/lib/ledger.test.ts @@ -113,7 +113,7 @@ describe('Ledger Library', () => { it('Should fail without USB transport', () => { const signer = new LedgerSigner({ type: WalletType.Ledger, - path: [44, 474, 0, 0, 0], + path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0), publicKey: '00', } as Wallet) @@ -141,7 +141,7 @@ describe('Ledger Library', () => { const signer = new LedgerSigner({ type: WalletType.Ledger, - path: [44, 474, 0, 0, 0], + path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0), publicKey: '00', } as Wallet) @@ -157,7 +157,7 @@ describe('Ledger Library', () => { const signer = new LedgerSigner({ type: WalletType.Ledger, - path: [44, 474, 0, 0, 0], + path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0), publicKey: '00', } as Wallet) diff --git a/src/app/state/ledger/saga.test.ts b/src/app/state/ledger/saga.test.ts index cba5ec21bd..514da6696a 100644 --- a/src/app/state/ledger/saga.test.ts +++ b/src/app/state/ledger/saga.test.ts @@ -9,6 +9,7 @@ import { addressToPublicKey } from 'app/lib/helpers' import { LedgerStep } from './types' import { WalletErrors } from 'types/errors' import { OasisTransaction } from 'app/lib/transaction' +import { selectDerivationPathType } from './selectors' describe('Ledger Sagas', () => { describe('enumerateAccounts', () => { @@ -24,6 +25,7 @@ describe('Ledger Sagas', () => { [matchers.call.fn(TransportWebUSB.create), { close: () => {} }], [matchers.call.fn(Ledger.enumerateAccounts), [validAccount]], [matchers.call.fn(getBalance), {}], + [matchers.select.selector(selectDerivationPathType), DerivationPathTypeAdr8], ]) .dispatch(ledgerActions.enumerateAccounts(DerivationPathTypeAdr8)) .put(ledgerActions.setStep(LedgerStep.Done)) @@ -43,6 +45,7 @@ describe('Ledger Sagas', () => { [matchers.call.fn(TransportWebUSB.create), { close: () => {} }], [matchers.call.fn(Ledger.enumerateAccounts), [validAccount]], [matchers.call.fn(getBalance), {}], + [matchers.select.selector(selectDerivationPathType), DerivationPathTypeAdr8], ]) .dispatch(ledgerActions.enumerateAccounts(DerivationPathTypeLegacy)) .put(ledgerActions.setStep(LedgerStep.Done)) @@ -89,6 +92,7 @@ describe('Ledger Sagas', () => { [matchers.call.fn(TransportWebUSB.isSupported), true], [matchers.call.fn(TransportWebUSB.create), { close: () => {} }], [matchers.call.fn(Ledger.enumerateAccounts), Promise.reject(new Error('Dummy error'))], + [matchers.select.selector(selectDerivationPathType), DerivationPathTypeAdr8], ]) .dispatch(ledgerActions.enumerateAccounts(DerivationPathTypeAdr8)) .put.like({ action: { payload: { code: WalletErrors.UnknownError, message: 'Dummy error' } } }) diff --git a/src/app/state/wallet/saga.test.ts b/src/app/state/wallet/saga.test.ts index c86f5af3fb..024f5a385d 100644 --- a/src/app/state/wallet/saga.test.ts +++ b/src/app/state/wallet/saga.test.ts @@ -10,6 +10,7 @@ import { transactionActions } from '../transaction' import { getBalance, rootWalletSaga, walletSaga, selectWallet } from './saga' import { selectActiveWallet } from './selectors' import { Wallet, WalletState } from './types' +import { DerivationPathTypeAdr8, Ledger } from '../../lib/ledger' describe('Wallet Sagas', () => { const validMnemonic = @@ -61,7 +62,7 @@ describe('Wallet Sagas', () => { { address: addressHex, balance: { available: '0', debonding: '0', escrow: '0', total: '0' }, - path: [44, 474, 0, 0, 0], + path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0), publicKey: '00', selected: true, },