Skip to content

Commit 4bb496d

Browse files
committed
fixup! feat: make KoraLabsHandleProvider compliant with bitcoin
1 parent 94abd03 commit 4bb496d

File tree

1 file changed

+66
-86
lines changed

1 file changed

+66
-86
lines changed

packages/wallet/test/services/HandlesTracker.test.ts

Lines changed: 66 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,24 @@ const handleReferenceTokenAssetId = Cardano.AssetId.fromParts(
8282
describe('createHandlesTracker', () => {
8383
it('matches utxo$ assets to given handlePolicyIds and adds context from assetInfo$ and tip$ observables', () => {
8484
createTestScheduler().run(({ hot, expectObservable }) => {
85-
const utxo$ = hot('-ab-', { a: utxo, b: utxo2 });
85+
const utxo$ = hot( '-ab-', { a: utxo, b: utxo2 });
8686
const assetInfo$ = hot('-a-b', {
8787
a: new Map(),
8888
b: new Map([[handleAssetId, handleAssetInfo]])
8989
});
9090
const handlePolicyIds$ = hot('-a--', { a: [handlePolicyId] });
9191

92-
const handles$ = createHandlesTracker(
93-
{
94-
assetInfo$,
95-
handlePolicyIds$,
96-
handleProvider: {
97-
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
98-
healthCheck: jest.fn(),
99-
resolveHandles: async () => []
100-
},
101-
logger,
102-
utxo$
92+
const handles$ = createHandlesTracker({
93+
assetInfo$,
94+
handlePolicyIds$,
95+
handleProvider: {
96+
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
97+
healthCheck: jest.fn(),
98+
resolveHandles: async () => []
10399
},
104-
{ hydrateHandle: () => hydrateHandle }
105-
);
100+
logger,
101+
utxo$
102+
}, { hydrateHandle: () => hydrateHandle });
106103

107104
expectObservable(handles$).toBe('---ab', {
108105
a: [expectedHandleInfo],
@@ -113,7 +110,7 @@ describe('createHandlesTracker', () => {
113110

114111
it('filters out handles that have total supply >1', () => {
115112
createTestScheduler().run(({ hot, expectObservable }) => {
116-
const utxo$ = hot('-a', { a: utxo });
113+
const utxo$ = hot( '-a', { a: utxo });
117114
const assetInfo$ = hot('-a', {
118115
a: new Map([
119116
[
@@ -127,46 +124,38 @@ describe('createHandlesTracker', () => {
127124
});
128125
const handlePolicyIds$ = hot('-a-', { a: [handlePolicyId] });
129126

130-
const handles$ = createHandlesTracker(
131-
{
132-
assetInfo$,
133-
handlePolicyIds$,
134-
handleProvider: {
135-
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
136-
healthCheck: jest.fn(),
137-
resolveHandles: async () => []
138-
},
139-
logger,
140-
utxo$
127+
const handles$ = createHandlesTracker({
128+
assetInfo$,
129+
handlePolicyIds$,
130+
handleProvider: {
131+
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
132+
healthCheck: jest.fn(),
133+
resolveHandles: async () => []
141134
},
142-
{ hydrateHandle: () => hydrateHandle }
143-
);
135+
logger,
136+
utxo$
137+
}, { hydrateHandle: () => hydrateHandle });
144138

145139
expectObservable(handles$).toBe('-a', { a: [] });
146140
});
147141
});
148142

149143
it('filters out cip68 reference tokens', () => {
150144
createTestScheduler().run(({ hot, expectObservable }) => {
151-
const utxo$ = hot('-a', {
152-
a: [
153-
[
154-
utxo[0][0],
155-
{
156-
address: utxo[0][1].address,
157-
value: {
158-
assets: new Map([[handleReferenceTokenAssetId, 1n]]),
159-
coins: 9_825_963n
160-
}
161-
}
162-
] as Cardano.Utxo
163-
]
164-
});
145+
const utxo$ = hot('-a', { a: [[utxo[0][0], {
146+
address: utxo[0][1].address,
147+
value: {
148+
assets: new Map([
149+
[handleReferenceTokenAssetId, 1n]
150+
]),
151+
coins: 9_825_963n
152+
}
153+
}
154+
] as Cardano.Utxo] });
165155
const assetInfo$ = hot('-a', {
166156
a: new Map([
167157
[
168-
handleReferenceTokenAssetId,
169-
{
158+
handleReferenceTokenAssetId, {
170159
...handleAssetInfo,
171160
supply: 1n
172161
}
@@ -175,45 +164,39 @@ describe('createHandlesTracker', () => {
175164
});
176165
const handlePolicyIds$ = hot('-a-', { a: [handlePolicyId] });
177166

178-
const handles$ = createHandlesTracker(
179-
{
180-
assetInfo$,
181-
handlePolicyIds$,
182-
handleProvider: {
183-
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
184-
healthCheck: jest.fn(),
185-
resolveHandles: async () => []
186-
},
187-
logger,
188-
utxo$
167+
const handles$ = createHandlesTracker({
168+
assetInfo$,
169+
handlePolicyIds$,
170+
handleProvider: {
171+
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
172+
healthCheck: jest.fn(),
173+
resolveHandles: async () => []
189174
},
190-
{ hydrateHandle: () => hydrateHandle }
191-
);
175+
logger,
176+
utxo$
177+
}, { hydrateHandle: () => hydrateHandle });
192178

193179
expectObservable(handles$).toBe('-a', { a: [] });
194180
});
195181
});
196182

197183
it('does not emit duplicates with no changes', () => {
198184
createTestScheduler().run(({ hot, expectObservable }) => {
199-
const utxo$ = hot('-a-', { a: utxo });
200-
const assetInfo$ = hot('-aa', { a: new Map([[handleAssetId, handleAssetInfo]]) });
185+
const utxo$ = hot( '-a-', { a: utxo });
186+
const assetInfo$ = hot( '-aa', { a: new Map([[handleAssetId, handleAssetInfo]]) });
201187
const handlePolicyIds$ = hot('-a-', { a: [handlePolicyId] });
202188

203-
const handles$ = createHandlesTracker(
204-
{
205-
assetInfo$,
206-
handlePolicyIds$,
207-
handleProvider: {
208-
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
209-
healthCheck: jest.fn(),
210-
resolveHandles: async () => []
211-
},
212-
logger,
213-
utxo$
189+
const handles$ = createHandlesTracker({
190+
assetInfo$,
191+
handlePolicyIds$,
192+
handleProvider: {
193+
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
194+
healthCheck: jest.fn(),
195+
resolveHandles: async () => []
214196
},
215-
{ hydrateHandle: () => hydrateHandle }
216-
);
197+
logger,
198+
utxo$
199+
}, { hydrateHandle: () => hydrateHandle });
217200

218201
expectObservable(handles$).toBe('-ab', {
219202
a: [expectedHandleInfo],
@@ -224,25 +207,22 @@ describe('createHandlesTracker', () => {
224207

225208
it('shares a single subscription to dependency observables', () => {
226209
createTestScheduler().run(({ hot, expectSubscriptions }) => {
227-
const utxo$ = hot('-a', { a: utxo });
210+
const utxo$ = hot( '-a', { a: utxo });
228211
const assetInfo$ = hot('-a', {
229212
a: new Map([[handleAssetId, handleAssetInfo]])
230213
});
231214
const handlePolicyIds$ = hot('a-', { a: [handlePolicyId] });
232-
const handles$ = createHandlesTracker(
233-
{
234-
assetInfo$,
235-
handlePolicyIds$,
236-
handleProvider: {
237-
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
238-
healthCheck: jest.fn(),
239-
resolveHandles: async () => []
240-
},
241-
logger,
242-
utxo$
215+
const handles$ = createHandlesTracker({
216+
assetInfo$,
217+
handlePolicyIds$,
218+
handleProvider: {
219+
getPolicyIds: async (): Promise<Cardano.PolicyId[]> => [handlePolicyId],
220+
healthCheck: jest.fn(),
221+
resolveHandles: async () => []
243222
},
244-
{ hydrateHandle: () => hydrateHandle }
245-
);
223+
logger,
224+
utxo$
225+
}, { hydrateHandle: () => hydrateHandle });
246226
combineLatest([handles$, handles$]).pipe(take(1)).subscribe();
247227
expectSubscriptions(utxo$.subscriptions).toBe('^!');
248228
expectSubscriptions(assetInfo$.subscriptions).toBe('^!');

0 commit comments

Comments
 (0)