@@ -11,10 +11,10 @@ import {
11
11
WalletRepositoryDependencies ,
12
12
WalletType
13
13
} from '../../src' ;
14
+ import { BehaviorSubject , firstValueFrom , of } from 'rxjs' ;
14
15
import { Cardano , Serialization } from '@cardano-sdk/core' ;
15
16
import { Hash28ByteBase16 } from '@cardano-sdk/crypto' ;
16
17
import { KeyPurpose , KeyRole } from '@cardano-sdk/key-management' ;
17
- import { firstValueFrom , of } from 'rxjs' ;
18
18
import { logger } from '@cardano-sdk/util-dev' ;
19
19
import pick from 'lodash/pick' ;
20
20
@@ -210,6 +210,9 @@ describe('WalletRepository', () => {
210
210
} ) ;
211
211
212
212
it ( 'allows creating 1852 and 1854 purpose account with the same index' , async ( ) => {
213
+ const storeSubject = new BehaviorSubject ( [ storedLedgerWallet ] ) ;
214
+ store . observeAll . mockReturnValue ( storeSubject . asObservable ( ) ) ;
215
+
213
216
const standardAccountProps = createAccount (
214
217
0 ,
215
218
storedLedgerWallet . accounts [ storedLedgerWallet . accounts . length - 1 ] . accountIndex + 1 ,
@@ -220,14 +223,14 @@ describe('WalletRepository', () => {
220
223
walletId : storedLedgerWallet . walletId
221
224
} ;
222
225
223
- const multiSigAccountProps2 = createAccount (
226
+ const multiSigAccountProps = createAccount (
224
227
0 ,
225
228
storedLedgerWallet . accounts [ storedLedgerWallet . accounts . length - 1 ] . accountIndex + 1 ,
226
229
KeyPurpose . MULTI_SIG
227
230
) ;
228
231
229
232
const multiSigProps = {
230
- ...multiSigAccountProps2 ,
233
+ ...multiSigAccountProps ,
231
234
walletId : storedLedgerWallet . walletId
232
235
} ;
233
236
@@ -239,11 +242,18 @@ describe('WalletRepository', () => {
239
242
}
240
243
] ) ;
241
244
245
+ storeSubject . next ( [
246
+ {
247
+ ...storedLedgerWallet ,
248
+ accounts : [ ...storedLedgerWallet . accounts , standardAccountProps ]
249
+ }
250
+ ] ) ;
251
+
242
252
await expect ( repository . addAccount ( multiSigProps ) ) . resolves . toEqual ( multiSigProps ) ;
243
253
expect ( store . setAll ) . toBeCalledWith ( [
244
254
{
245
255
...storedLedgerWallet ,
246
- accounts : [ ...storedLedgerWallet . accounts , multiSigAccountProps2 ]
256
+ accounts : [ ...storedLedgerWallet . accounts , standardAccountProps , multiSigAccountProps ]
247
257
}
248
258
] ) ;
249
259
} ) ;
@@ -333,7 +343,8 @@ describe('WalletRepository', () => {
333
343
} ) ;
334
344
335
345
it ( 'does not update 1852 account metadata when updating 1854 account' , async ( ) => {
336
- const newAccount = createAccount ( 0 , 1 , KeyPurpose . MULTI_SIG ) ;
346
+ const storedAccount = storedLedgerWallet . accounts [ 0 ] ;
347
+ const newAccount = createAccount ( 0 , storedAccount . accountIndex , KeyPurpose . MULTI_SIG ) ;
337
348
const accounts = [ storedLedgerWallet . accounts [ 0 ] , newAccount ] ;
338
349
store . observeAll . mockReturnValueOnce ( of ( [ { ...storedLedgerWallet , accounts } ] ) ) ;
339
350
0 commit comments