Skip to content

Commit fdca15d

Browse files
committed
tests: Fix saga tests
1 parent 1f29607 commit fdca15d

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/app/lib/ledger.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('Ledger Library', () => {
113113
it('Should fail without USB transport', () => {
114114
const signer = new LedgerSigner({
115115
type: WalletType.Ledger,
116-
path: [44, 474, 0, 0, 0],
116+
path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0),
117117
publicKey: '00',
118118
} as Wallet)
119119

@@ -141,7 +141,7 @@ describe('Ledger Library', () => {
141141

142142
const signer = new LedgerSigner({
143143
type: WalletType.Ledger,
144-
path: [44, 474, 0, 0, 0],
144+
path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0),
145145
publicKey: '00',
146146
} as Wallet)
147147

@@ -157,7 +157,7 @@ describe('Ledger Library', () => {
157157

158158
const signer = new LedgerSigner({
159159
type: WalletType.Ledger,
160-
path: [44, 474, 0, 0, 0],
160+
path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0),
161161
publicKey: '00',
162162
} as Wallet)
163163

src/app/pages/OpenWalletPage/Features/FromLedger/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function FromLedgerModal(props: FromLedgerModalProps) {
107107
const error = ledger.error
108108
const selectedAccounts = useSelector(selectSelectedLedgerAccounts)
109109
const dispatch = useDispatch()
110-
const [initDerivationPathType, derivationPathSetValue] = useState(DerivationPathTypeLegacy)
110+
const [derivationPathType, setDerivationPathType] = useState(DerivationPathTypeLegacy)
111111

112112
const derivationPathTypes = [
113113
{
@@ -125,12 +125,12 @@ export function FromLedgerModal(props: FromLedgerModalProps) {
125125
}
126126

127127
const onChangeDerivationPathType = (arg: any) => {
128-
derivationPathSetValue(arg.value)
128+
setDerivationPathType(arg.value)
129129
dispatch(ledgerActions.enumerateAccounts(arg.value))
130130
}
131131

132132
useEffect(() => {
133-
dispatch(ledgerActions.enumerateAccounts(initDerivationPathType))
133+
dispatch(ledgerActions.enumerateAccounts(DerivationPathTypeLegacy!))
134134
return () => {
135135
dispatch(ledgerActions.clear())
136136
}
@@ -159,7 +159,7 @@ export function FromLedgerModal(props: FromLedgerModalProps) {
159159
labelKey="label"
160160
onChange={onChangeDerivationPathType}
161161
options={derivationPathTypes}
162-
value={initDerivationPathType}
162+
value={derivationPathType}
163163
valueKey={{ key: 'value', reduce: true }}
164164
disabled={cancelDisabled}
165165
/>

src/app/state/ledger/saga.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { addressToPublicKey } from 'app/lib/helpers'
99
import { LedgerStep } from './types'
1010
import { WalletErrors } from 'types/errors'
1111
import { OasisTransaction } from 'app/lib/transaction'
12+
import { selectDerivationPathType } from './selectors'
1213

1314
describe('Ledger Sagas', () => {
1415
describe('enumerateAccounts', () => {
@@ -24,6 +25,7 @@ describe('Ledger Sagas', () => {
2425
[matchers.call.fn(TransportWebUSB.create), { close: () => {} }],
2526
[matchers.call.fn(Ledger.enumerateAccounts), [validAccount]],
2627
[matchers.call.fn(getBalance), {}],
28+
[matchers.select.selector(selectDerivationPathType), DerivationPathTypeAdr8],
2729
])
2830
.dispatch(ledgerActions.enumerateAccounts(DerivationPathTypeAdr8))
2931
.put(ledgerActions.setStep(LedgerStep.Done))
@@ -43,6 +45,7 @@ describe('Ledger Sagas', () => {
4345
[matchers.call.fn(TransportWebUSB.create), { close: () => {} }],
4446
[matchers.call.fn(Ledger.enumerateAccounts), [validAccount]],
4547
[matchers.call.fn(getBalance), {}],
48+
[matchers.select.selector(selectDerivationPathType), DerivationPathTypeAdr8],
4649
])
4750
.dispatch(ledgerActions.enumerateAccounts(DerivationPathTypeLegacy))
4851
.put(ledgerActions.setStep(LedgerStep.Done))
@@ -89,6 +92,7 @@ describe('Ledger Sagas', () => {
8992
[matchers.call.fn(TransportWebUSB.isSupported), true],
9093
[matchers.call.fn(TransportWebUSB.create), { close: () => {} }],
9194
[matchers.call.fn(Ledger.enumerateAccounts), Promise.reject(new Error('Dummy error'))],
95+
[matchers.select.selector(selectDerivationPathType), DerivationPathTypeAdr8],
9296
])
9397
.dispatch(ledgerActions.enumerateAccounts(DerivationPathTypeAdr8))
9498
.put.like({ action: { payload: { code: WalletErrors.UnknownError, message: 'Dummy error' } } })

src/app/state/wallet/saga.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { transactionActions } from '../transaction'
1010
import { getBalance, rootWalletSaga, walletSaga, selectWallet } from './saga'
1111
import { selectActiveWallet } from './selectors'
1212
import { Wallet, WalletState } from './types'
13+
import { DerivationPathTypeAdr8, Ledger } from '../../lib/ledger'
1314

1415
describe('Wallet Sagas', () => {
1516
const validMnemonic =
@@ -61,7 +62,7 @@ describe('Wallet Sagas', () => {
6162
{
6263
address: addressHex,
6364
balance: { available: '0', debonding: '0', escrow: '0', total: '0' },
64-
path: [44, 474, 0, 0, 0],
65+
path: Ledger.mustGetPath(DerivationPathTypeAdr8, 0),
6566
publicKey: '00',
6667
selected: true,
6768
},

0 commit comments

Comments
 (0)