Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("Wallet Repository Copy On Write", () => {
it("should find wallets by address", () => {
const spyFindByAddress = jest.spyOn(walletRepo, "findByAddress");
const clonedWallet = walletRepoCopyOnWrite.findByAddress("notexisting");
expect(spyFindByAddress).toHaveBeenCalledWith("notexisting");
expect(spyFindByAddress).not.toBeCalled();
const originalWallet = walletRepo.findByAddress(clonedWallet.getAddress());
expect(originalWallet).not.toBe(clonedWallet);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export class WalletRepositoryCopyOnWrite extends WalletRepository {

public findByAddress(address: string): Contracts.State.Wallet {
if (address && !this.hasByAddress(address)) {
this.cloneWallet(this.blockchainWalletRepository, this.blockchainWalletRepository.findByAddress(address));
if (this.blockchainWalletRepository.hasByAddress(address)) {
this.cloneWallet(
this.blockchainWalletRepository,
this.blockchainWalletRepository.findByAddress(address),
);
} else {
super.findByAddress(address);
}
}
return this.findByIndex(Contracts.State.WalletIndexes.Addresses, address)!;
}
Expand Down