Skip to content

Commit 7fd2b4a

Browse files
committed
test for other apps
1 parent 69c52ec commit 7fd2b4a

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

packages/sdk/wallets/wallet-ledger/src/ledger-wallet.test.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'
1111
import Web3 from 'web3'
1212
import { meetsVersionRequirements } from './ledger-utils'
13-
import { AddressValidation, LedgerWallet } from './ledger-wallet'
13+
import { AddressValidation, CELO_BASE_DERIVATION_PATH, LedgerWallet } from './ledger-wallet'
1414
import {
1515
ACCOUNT_ADDRESS1,
1616
ACCOUNT_ADDRESS2,
@@ -226,6 +226,46 @@ describe('LedgerWallet class', () => {
226226
`)
227227
expect(wallet.ledger!.getAddress).toHaveBeenCalledTimes(6)
228228
})
229+
describe('with other ledger apps', () => {
230+
describe('with the ethereum-recovery app', () => {
231+
beforeEach(() => {
232+
wallet = new LedgerWallet({}, [0], CELO_BASE_DERIVATION_PATH, [1, 2])
233+
mockLedger(wallet, mockForceValidation, { name: 'ethereum-recovery' })
234+
})
235+
it('shows warning on initialization but still initalizes', async () => {
236+
const logMock = jest.spyOn(console, 'error')
237+
await wallet.init()
238+
expect(logMock.mock.calls).toMatchInlineSnapshot(`
239+
[
240+
[
241+
"
242+
---
243+
Beware, you opened the ethereum-recovery app instead of the Celo app. We cannot ensure the safety of using this SDK with ethereum-recovery. USE AT YOUR OWN RISK.
244+
---
245+
",
246+
],
247+
]
248+
`)
249+
})
250+
})
251+
describe('with the ethereum app', () => {
252+
beforeEach(() => {
253+
wallet = new LedgerWallet({}, [0, 1, 2, 3], ETHEREUM_DERIVATION_PATH, [6, 7, 8])
254+
mockLedger(wallet, mockForceValidation, { name: 'ethereum' })
255+
})
256+
it('shows warning on initialization but still initalizes', async () => {
257+
const warnMock = jest.spyOn(console, 'warn')
258+
await wallet.init()
259+
expect(warnMock.mock.calls).toMatchInlineSnapshot(`
260+
[
261+
[
262+
"Beware, you opened the Ethereum app instead of the Celo app. Some features may not work correctly, including token transfers.",
263+
],
264+
]
265+
`)
266+
})
267+
})
268+
})
229269
})
230270

231271
describe('after initializing', () => {

0 commit comments

Comments
 (0)