Skip to content

Commit 3d0f0e1

Browse files
fixup! feat: asset tracker now uses local cache before fetching asset metadata
1 parent c2530f2 commit 3d0f0e1

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

packages/wallet/test/PersonalWallet/load.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const createWallet = async (props: CreateWalletProps) => {
141141
);
142142
};
143143

144-
const removeStaleFetchedAt = (assetInfos: Map<Cardano.AssetId, Asset.AssetInfo>) =>
144+
const removeStaleAt = (assetInfos: Map<Cardano.AssetId, Asset.AssetInfo>) =>
145145
new Map([...assetInfos.entries()].map(([key, value]) => [key, { ...value, staleAt: undefined }]));
146146

147147
const assertWalletProperties = async (
@@ -190,7 +190,7 @@ const assertWalletProperties = async (
190190
expect(rewardAccounts[0].delegatee?.nextNextEpoch?.id).toEqual(expectedDelegateeId);
191191
expect(rewardAccounts[0].rewardBalance).toBe(mocks.rewardAccountBalance);
192192
// assets$
193-
expect(removeStaleFetchedAt(await firstValueFrom(wallet.assetInfo$))).toEqual(
193+
expect(removeStaleAt(await firstValueFrom(wallet.assetInfo$))).toEqual(
194194
new Map([
195195
[AssetId.TSLA, mocks.asset],
196196
[handleAssetId, handleAssetInfo]

packages/wallet/test/PersonalWallet/shutdown.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
/* eslint-disable max-statements */
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33
import { AddressType, Bip32Account, GroupedAddress, util } from '@cardano-sdk/key-management';
4+
import {
5+
Asset,
6+
Cardano,
7+
ChainHistoryProvider,
8+
NetworkInfoProvider,
9+
RewardsProvider,
10+
UtxoProvider,
11+
coalesceValueQuantities
12+
} from '@cardano-sdk/core';
413
import {
514
AssetId,
615
createStubStakePoolProvider,
@@ -15,14 +24,6 @@ import {
1524
WalletNetworkInfoProviderStats,
1625
createPersonalWallet
1726
} from '../../src';
18-
import {
19-
Cardano,
20-
ChainHistoryProvider,
21-
NetworkInfoProvider,
22-
RewardsProvider,
23-
UtxoProvider,
24-
coalesceValueQuantities
25-
} from '@cardano-sdk/core';
2627
import { WalletStores, createInMemoryWalletStores } from '../../src/persistence';
2728
import { firstValueFrom } from 'rxjs';
2829
import { dummyLogger as logger } from 'ts-log';
@@ -79,6 +80,9 @@ const createWallet = async (stores: WalletStores, providers: Providers, pollingC
7980
);
8081
};
8182

83+
const removeStaleAt = (assetInfos: Map<Cardano.AssetId, Asset.AssetInfo>) =>
84+
new Map([...assetInfos.entries()].map(([key, value]) => [key, { ...value, staleAt: undefined }]));
85+
8286
const assertWalletProperties = async (
8387
wallet: BaseWallet,
8488
expectedDelegateeId: Cardano.PoolId | undefined,
@@ -124,7 +128,7 @@ const assertWalletProperties = async (
124128
expect(addresses[0].address).toEqual(address);
125129
expect(addresses[0].rewardAccount).toEqual(rewardAccount);
126130
// assets$
127-
expect(await firstValueFrom(wallet.assetInfo$)).toEqual(
131+
expect(removeStaleAt(await firstValueFrom(wallet.assetInfo$))).toEqual(
128132
new Map([
129133
[AssetId.TSLA, mocks.asset],
130134
[mocks.handleAssetId, mocks.handleAssetInfo]

0 commit comments

Comments
 (0)