Skip to content

Commit 377efc2

Browse files
committed
chore: fixed discovery tests failing
1 parent 343b30b commit 377efc2

File tree

4 files changed

+23
-54
lines changed

4 files changed

+23
-54
lines changed

src/discovery/Discovery.ts

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,13 @@ class Discovery {
180180
undefined,
181181
gestaltsUtils.decodeGestaltId(parent ?? undefined),
182182
true,
183-
undefined,
184-
ctx,
185183
);
186184
return;
187185
}
188186
// Aborting a duplicate task is not an error
189187
if (e === abortSingletonTaskReason) return;
190188
// Destroying tasks is not an error
191189
if (e === discoveryDestroyedTaskReason) return;
192-
// Abortion due to cancellation is not an error
193-
if (e === ctx.signal.reason) return;
194190
this.dispatchEvent(
195191
new discoveryEvents.EventDiscoveryVertexFailed({
196192
detail: {
@@ -352,10 +348,6 @@ class Discovery {
352348
['node', nodeId],
353349
undefined,
354350
lastProcessedCutoffTime,
355-
undefined,
356-
undefined,
357-
undefined,
358-
ctx,
359351
);
360352
}
361353

@@ -381,10 +373,6 @@ class Discovery {
381373
['identity', [providerId, identityId]],
382374
undefined,
383375
lastProcessedCutoffTime,
384-
undefined,
385-
undefined,
386-
undefined,
387-
ctx,
388376
);
389377
}
390378

@@ -438,10 +426,8 @@ class Discovery {
438426
const [type, id] = vertexId;
439427
switch (type) {
440428
case 'node':
441-
// Return await this.processNode(id, lastProcessedCutoffTime, ctx);
442429
return await this.processNode(id, lastProcessedCutoffTime, ctx);
443430
case 'identity':
444-
// Return await this.processIdentity(id, lastProcessedCutoffTime, ctx);
445431
return await this.processIdentity(id, lastProcessedCutoffTime, ctx);
446432
default:
447433
never(`type must be either "node" or "identity" got "${type}"`);
@@ -489,7 +475,6 @@ class Discovery {
489475
}
490476
// Iterate over each of the claims in the chain (already verified).
491477
for (const signedClaim of Object.values(vertexChainData)) {
492-
ctx.signal.throwIfAborted();
493478
switch (signedClaim.payload.typ) {
494479
case 'ClaimLinkNode':
495480
await this.processClaimLinkNode(
@@ -581,9 +566,6 @@ class Discovery {
581566
undefined,
582567
lastProcessedCutoffTime,
583568
['node', nodeId],
584-
undefined,
585-
undefined,
586-
ctx,
587569
);
588570
}
589571
}
@@ -687,9 +669,6 @@ class Discovery {
687669
undefined,
688670
lastProcessedCutoffTime,
689671
['node', nodeId],
690-
undefined,
691-
undefined,
692-
ctx,
693672
);
694673
}
695674
}
@@ -766,9 +745,6 @@ class Discovery {
766745
undefined,
767746
lastProcessedCutoffTime,
768747
['identity', providerIdentityId],
769-
undefined,
770-
undefined,
771-
ctx,
772748
);
773749
}
774750
}
@@ -828,13 +804,12 @@ class Discovery {
828804
*/
829805
protected async scheduleDiscoveryForVertex(
830806
vertex: GestaltId,
831-
delay: number | undefined,
832-
lastProcessedCutoffTime: number | undefined,
833-
parent: GestaltId | undefined,
807+
delay?: number,
808+
lastProcessedCutoffTime?: number,
809+
parent?: GestaltId,
834810
ignoreActive: boolean = false,
835-
tran: DBTransaction | undefined,
836-
ctx: ContextTimed,
837-
) {
811+
tran?: DBTransaction,
812+
): Promise<void> {
838813
if (tran == null) {
839814
return this.db.withTransactionF((tran) =>
840815
this.scheduleDiscoveryForVertex(
@@ -844,7 +819,6 @@ class Discovery {
844819
parent,
845820
ignoreActive,
846821
tran,
847-
ctx,
848822
),
849823
);
850824
}
@@ -864,9 +838,7 @@ class Discovery {
864838
true,
865839
[this.constructor.name, this.discoverVertexHandlerId, gestaltIdEncoded],
866840
tran,
867-
ctx,
868841
)) {
869-
ctx.signal.throwIfAborted();
870842
// Ignore active tasks
871843
if (ignoreActive && task.status === 'active') continue;
872844
if (taskExisting == null) {

src/tasks/TaskManager.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -397,33 +397,23 @@ class TaskManager {
397397
};
398398
}
399399

400-
public getTasks(
401-
order?: 'asc' | 'desc',
402-
lazy?: boolean,
403-
path?: TaskPath,
404-
tran?: DBTransaction,
405-
ctx?: Partial<ContextTimedInput>,
406-
): AsyncGenerator<Task>;
407400
@ready(new tasksErrors.ErrorTaskManagerNotRunning())
408-
@timed()
409401
public async *getTasks(
410402
order: 'asc' | 'desc' = 'asc',
411403
lazy: boolean = false,
412-
path: TaskPath | undefined,
413-
tran: DBTransaction | undefined,
414-
@context ctx: ContextTimed,
404+
path?: TaskPath,
405+
tran?: DBTransaction,
415406
): AsyncGenerator<Task> {
416407
if (tran == null) {
417408
return yield* this.db.withTransactionG((tran) =>
418-
this.getTasks(order, lazy, path, tran, ctx),
409+
this.getTasks(order, lazy, path, tran),
419410
);
420411
}
421412
if (path == null) {
422413
for await (const [[taskIdBuffer]] of tran.iterator(
423414
[...this.tasksTaskDbPath],
424415
{ values: false, reverse: order !== 'asc' },
425416
)) {
426-
ctx.signal.throwIfAborted();
427417
const taskId = IdInternal.fromBuffer<TaskId>(taskIdBuffer as Buffer);
428418
const task = (await this.getTask(taskId, lazy, tran))!;
429419
yield task;

tests/discovery/Discovery.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,17 @@ describe('Discovery', () => {
293293
await discovery.stop();
294294
await discovery.destroy();
295295
await expect(
296-
discovery.queueDiscoveryByIdentity('' as ProviderId, '' as IdentityId),
296+
async () =>
297+
await discovery.queueDiscoveryByIdentity(
298+
'' as ProviderId,
299+
'' as IdentityId,
300+
),
297301
).rejects.toThrow(discoveryErrors.ErrorDiscoveryNotRunning);
298302
await expect(
299-
discovery.queueDiscoveryByNode(testNodesUtils.generateRandomNodeId()),
303+
async () =>
304+
await discovery.queueDiscoveryByNode(
305+
testNodesUtils.generateRandomNodeId(),
306+
),
300307
).rejects.toThrow(discoveryErrors.ErrorDiscoveryNotRunning);
301308
});
302309
test('discovery by node', async () => {

tests/vaults/VaultInternal.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ describe('VaultInternal', () => {
117117

118118
test('VaultInternal readiness', async () => {
119119
await vault.stop();
120-
await expect(async () => {
121-
await vault.log();
122-
}).rejects.toThrow(vaultsErrors.ErrorVaultNotRunning);
120+
await expect(async () => await vault.log()).rejects.toThrow(
121+
vaultsErrors.ErrorVaultNotRunning,
122+
);
123123
await vault.destroy();
124-
await expect(async () => {
125-
await vault.start();
126-
}).rejects.toThrow(vaultsErrors.ErrorVaultDestroyed);
124+
await expect(async () => await vault.start()).rejects.toThrow(
125+
vaultsErrors.ErrorVaultDestroyed,
126+
);
127127
});
128128
test('is type correct', async () => {
129129
expect(vault).toBeInstanceOf(VaultInternal);

0 commit comments

Comments
 (0)