Skip to content

Commit 678a0a4

Browse files
committed
fix: removed unnecessary console log from utils and merged asc and desc tests for nodesClaimsGet
1 parent 8526f29 commit 678a0a4

File tree

3 files changed

+9
-34
lines changed

3 files changed

+9
-34
lines changed

src/network/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ async function resolveHostnames(
440440
// TODO: review and fix the `toError` and `fromError` code here.
441441
// Right now it's very basic and need fleshing out.
442442
function fromError(error: any) {
443-
console.error(error);
444443
switch (typeof error) {
445444
case 'symbol':
446445
case 'bigint':

tests/nodes/agent/handlers/nodesAuditsGet.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type Discovery from '@/discovery/Discovery';
44
import fs from 'fs';
55
import path from 'path';
66
import os from 'os';
7+
import { test } from '@fast-check/jest';
78
import fc from 'fast-check';
89
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
910
import { QUICClient, QUICServer, events as quicEvents } from '@matrixai/quic';

tests/nodes/agent/handlers/nodesClaimsGet.test.ts

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ describe('nodesClaimsGet', () => {
234234
expect(chainIds).toHaveLength(5);
235235
});
236236

237-
test('Should get chain data with order desc', async () => {
237+
test('Should get chain data with order asc and desc', async () => {
238238
const srcNodeIdEncoded = nodesUtils.encodeNodeId(keyRing.getNodeId());
239239
// Add 10 claims
240240
for (let i = 1; i <= 5; i++) {
@@ -260,10 +260,11 @@ describe('nodesClaimsGet', () => {
260260
await sigchain.addClaim(identityLink);
261261
}
262262

263-
const response = await rpcClient.methods.nodesClaimsGet({
263+
// Test for descending order
264+
let response = await rpcClient.methods.nodesClaimsGet({
264265
order: 'desc',
265266
});
266-
const chainIds: Array<string> = [];
267+
let chainIds: Array<string> = [];
267268
for await (const claim of response) {
268269
chainIds.push(claim.claimIdEncoded ?? '');
269270
}
@@ -277,44 +278,18 @@ describe('nodesClaimsGet', () => {
277278
}
278279
}
279280
expect(isSorted).toBe(true);
280-
});
281281

282-
test('Should get chain data with order asc', async () => {
283-
const srcNodeIdEncoded = nodesUtils.encodeNodeId(keyRing.getNodeId());
284-
// Add 10 claims
285-
for (let i = 1; i <= 5; i++) {
286-
const node2 = nodesUtils.encodeNodeId(
287-
testNodesUtils.generateRandomNodeId(),
288-
);
289-
const nodeLink = {
290-
type: 'ClaimLinkNode',
291-
iss: srcNodeIdEncoded,
292-
sub: node2,
293-
};
294-
await sigchain.addClaim(nodeLink);
295-
}
296-
for (let i = 6; i <= 10; i++) {
297-
const identityLink = {
298-
type: 'ClaimLinkIdentity',
299-
iss: srcNodeIdEncoded,
300-
sub: encodeProviderIdentityId([
301-
('ProviderId' + i.toString()) as ProviderId,
302-
('IdentityId' + i.toString()) as IdentityId,
303-
]),
304-
};
305-
await sigchain.addClaim(identityLink);
306-
}
307-
308-
const response = await rpcClient.methods.nodesClaimsGet({
282+
// Test for ascending order
283+
response = await rpcClient.methods.nodesClaimsGet({
309284
order: 'asc',
310285
});
311-
const chainIds: Array<string> = [];
286+
chainIds = [];
312287
for await (const claim of response) {
313288
chainIds.push(claim.claimIdEncoded ?? '');
314289
}
315290

316291
// Verify that chainIds are in ascending order
317-
let isSorted = true;
292+
isSorted = true;
318293
for (let i = 0; i < chainIds.length - 1; i++) {
319294
if (chainIds[i] > chainIds[i + 1]) {
320295
isSorted = false;

0 commit comments

Comments
 (0)