@@ -6,7 +6,10 @@ import {
66 RESOLVE_ACCOUNT_KEYRING_AND_WALLET ,
77 ResolveAccountSource ,
88} from './accountResolver' ;
9- import { AccountService } from '../services/account' ;
9+ import {
10+ AccountService ,
11+ DerivedAccountAddressMismatchException ,
12+ } from '../services/account' ;
1013import { generateStellarKeyringAccount } from '../services/account/__mocks__/account.fixtures' ;
1114import { AccountNotActivatedException } from '../services/network' ;
1215import {
@@ -20,7 +23,10 @@ import {
2023 mockOnChainAccountService ,
2124} from '../services/on-chain-account/__mocks__/onChainAccount.fixtures' ;
2225import { WalletService } from '../services/wallet' ;
23- import { getTestWallet } from '../services/wallet/__mocks__/wallet.fixtures' ;
26+ import {
27+ generateStellarAddress ,
28+ getTestWallet ,
29+ } from '../services/wallet/__mocks__/wallet.fixtures' ;
2430
2531jest . mock ( '../utils/logger' ) ;
2632
@@ -189,6 +195,34 @@ describe('AccountResolver', () => {
189195 ) . rejects . toThrow ( AccountNotActivatedException ) ;
190196 } ) ;
191197
198+ it ( 'throws DerivedAccountAddressMismatchException when state snapshot address differs from keyring' , async ( ) => {
199+ const { accountResolver, resolveOnChainAccountByKeyringAccountIdSpy } =
200+ setup ( ) ;
201+
202+ const otherAddress = generateStellarAddress ( ) ;
203+ const mockRawAccount = createMockAccountWithBalances (
204+ otherAddress ,
205+ '1' ,
206+ DEFAULT_MOCK_ACCOUNT_WITH_BALANCES ,
207+ ) ;
208+ const mismatchedOnChainAccount = new OnChainAccount (
209+ mockRawAccount ,
210+ scope ,
211+ horizonSource ( mockRawAccount , scope ) ,
212+ ) ;
213+ resolveOnChainAccountByKeyringAccountIdSpy . mockResolvedValue (
214+ mismatchedOnChainAccount ,
215+ ) ;
216+
217+ await expect (
218+ accountResolver . resolveAccount ( {
219+ accountId : keyringAccountId ,
220+ scope,
221+ options : RESOLVE_ACCOUNT_FULL_FROM_KEYRING_STATE ,
222+ } ) ,
223+ ) . rejects . toThrow ( DerivedAccountAddressMismatchException ) ;
224+ } ) ;
225+
192226 it ( 'omits wallet when wallet load is disabled' , async ( ) => {
193227 const { accountResolver, account, onChainAccount, resolveWalletSpy } =
194228 setup ( ) ;
0 commit comments