Skip to content

Commit

Permalink
test(json-crdt): 💍 add indexed JSON CRDT codec to fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Nov 6, 2023
1 parent 11a4934 commit 40c43ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/json-crdt/__tests__/fuzzer/SessionLogical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {encode as encodeJson} from '../../../json-crdt-patch/codec/verbose/encod
import {Encoder as BinaryEncoder} from '../../codec/structural/binary/Encoder';
import {Encoder as CompactEncoder} from '../../codec/structural/compact/Encoder';
import {Encoder as JsonEncoder} from '../../codec/structural/verbose/Encoder';
import {Encoder as IndexedBinaryEncoder} from '../../codec/indexed/binary/Encoder';
import {Decoder as IndexedBinaryDecoder} from '../../codec/indexed/binary/Decoder';
import {generateInteger} from './util';
import {Model} from '../..';
import {Patch} from '../../../json-crdt-patch/Patch';
Expand All @@ -27,6 +29,8 @@ const compactEncoder = new CompactEncoder();
const compactDecoder = new CompactDecoder();
const binaryEncoder = new BinaryEncoder();
const binaryDecoder = new BinaryDecoder();
const indexedBinaryEncoder = new IndexedBinaryEncoder();
const indexedBinaryDecoder = new IndexedBinaryDecoder();

export class SessionLogical {
public models: Model[] = [];
Expand Down Expand Up @@ -192,6 +196,7 @@ export class SessionLogical {
if (randomU32(0, 1)) model = jsonDecoder.decode(jsonEncoder.encode(model));
if (randomU32(0, 1)) model = compactDecoder.decode(compactEncoder.encode(model));
if (randomU32(0, 1)) model = binaryDecoder.decode(binaryEncoder.encode(model));
if (randomU32(0, 1)) model = indexedBinaryDecoder.decode(indexedBinaryEncoder.encode(model));
}
for (let j = 0; j < this.concurrency; j++) {
const patches = this.patches[j];
Expand Down

0 comments on commit 40c43ba

Please sign in to comment.