Skip to content

Commit f88f6aa

Browse files
committed
tests: fixed intermittent fast-check failures for gestalts
1 parent 84249af commit f88f6aa

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

tests/gestalts/GestaltGraph.test.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import * as utils from '@/utils';
3131
import * as keysUtils from '@/keys/utils';
3232
import Token from '@/tokens/Token';
3333
import { encodeGestaltNodeId, encodeGestaltIdentityId } from '@/gestalts/utils';
34+
import * as nodesUtils from '@/nodes/utils';
3435
import * as testsGestaltsUtils from './utils';
3536
import * as testsIdentitiesUtils from '../identities/utils';
3637
import * as testsKeysUtils from '../keys/utils';
@@ -756,6 +757,11 @@ describe('GestaltGraph', () => {
756757
'getGestalts with nodes',
757758
[fc.array(gestaltNodeInfoComposedArb, { minLength: 2 })],
758759
async (gestaltNodeInfos) => {
760+
const ids = new Set<string>();
761+
for (const gestaltNodeInfo of gestaltNodeInfos) {
762+
ids.add(nodesUtils.encodeNodeId(gestaltNodeInfo.nodeId));
763+
}
764+
fc.pre(ids.size === gestaltNodeInfos.length);
759765
const gestaltGraph = await GestaltGraph.createGestaltGraph({
760766
db,
761767
acl,
@@ -788,6 +794,13 @@ describe('GestaltGraph', () => {
788794
'getGestalts with identities',
789795
[fc.array(gestaltIdentityInfoComposedArb, { minLength: 2 }).noShrink()],
790796
async (gestaltIdentityInfos) => {
797+
const ids = new Set<string>();
798+
for (const gestaltIdentityInfo of gestaltIdentityInfos) {
799+
ids.add(
800+
gestaltIdentityInfo.providerId + gestaltIdentityInfo.identityId,
801+
);
802+
}
803+
fc.pre(ids.size === gestaltIdentityInfos.length);
791804
const gestaltGraph = await GestaltGraph.createGestaltGraph({
792805
db,
793806
acl,
@@ -819,11 +832,27 @@ describe('GestaltGraph', () => {
819832
});
820833
}
821834
},
835+
{ seed: 1958145926, path: '81', endOnFailure: true },
822836
);
823837
testProp(
824838
'getGestalts with nodes and identities',
825839
[fc.array(gestaltInfoComposedArb, { minLength: 2 })],
826840
async (gestaltInfos) => {
841+
const ids = new Set<string>();
842+
for (const gestaltInfo of gestaltInfos) {
843+
const [type, data] = gestaltInfo;
844+
switch (type) {
845+
case 'identity':
846+
ids.add(data.providerId + data.identityId);
847+
break;
848+
case 'node':
849+
ids.add(nodesUtils.encodeNodeId(data.nodeId));
850+
break;
851+
default:
852+
break;
853+
}
854+
}
855+
fc.pre(ids.size === gestaltInfos.length);
827856
const gestaltGraph = await GestaltGraph.createGestaltGraph({
828857
db,
829858
acl,
@@ -1140,9 +1169,17 @@ describe('GestaltGraph', () => {
11401169
fc
11411170
.record({
11421171
keyPairs: fc.array(testsKeysUtils.keyPairArb, { minLength: 2 }),
1143-
identityInfos: fc.array(gestaltIdentityInfoComposedArb, {
1144-
minLength: 1,
1145-
}),
1172+
identityInfos: fc
1173+
.array(gestaltIdentityInfoComposedArb, {
1174+
minLength: 1,
1175+
})
1176+
.filter((v) => {
1177+
const ids = new Set<string>();
1178+
for (const identityInfo of v) {
1179+
ids.add(identityInfo.providerId + identityInfo.identityId);
1180+
}
1181+
return ids.size === v.length;
1182+
}),
11461183
})
11471184
.chain((verticies) => {
11481185
const { keyPairs, identityInfos } = verticies;

0 commit comments

Comments
 (0)