Skip to content

Commit f772bc8

Browse files
Merge pull request #47 from IntersectMBO/fix/flaky-auxiliarydata-test
fix: prevent duplicate keys in MetadatumMap arbitrary generator
2 parents 44b1b6c + 4c5ffd5 commit f772bc8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/evolution/src/core/TransactionMetadatum.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,15 @@ export const arbitrary: FastCheck.Arbitrary<TransactionMetadatum> = FastCheck.on
258258
),
259259
{ maxLength: 3 }
260260
).map((value) => new ArrayMetadatum({ value })),
261-
FastCheck.array(
261+
FastCheck.uniqueArray(
262262
FastCheck.tuple(
263263
FastCheck.string().map((value) => new TextMetadatum({ value })),
264264
int64Arbitrary.map((value) => new IntMetadatum({ value }))
265265
),
266-
{ maxLength: 3 }
266+
{
267+
maxLength: 3,
268+
selector: ([key]) => key.value // Ensure unique keys by their string value
269+
}
267270
).map((entries) => {
268271
const map = new Map()
269272
for (const [key, value] of entries) {

0 commit comments

Comments
 (0)