@@ -4,7 +4,7 @@ import {decode as decodeJson} from '../../../json-crdt-patch/codec/verbose/decod
44import { Decoder as BinaryDecoder } from '../../codec/structural/binary/Decoder' ;
55import { Decoder as CompactDecoder } from '../../codec/structural/compact/Decoder' ;
66import { Decoder as JsonDecoder } from '../../codec/structural/verbose/Decoder' ;
7- import { DelOp , InsObjOp , InsStrOp , InsBinOp , InsArrOp } from '../../../json-crdt-patch/operations' ;
7+ import { DelOp , InsObjOp , InsStrOp , InsBinOp , InsArrOp , UpdArrOp } from '../../../json-crdt-patch/operations' ;
88import { encode as encodeCompact } from '../../../json-crdt-patch/codec/compact/encode' ;
99import { encode as encodeJson } from '../../../json-crdt-patch/codec/verbose/encode' ;
1010import { Encoder as BinaryEncoder } from '../../codec/structural/binary/Encoder' ;
@@ -161,7 +161,7 @@ export class SessionLogical {
161161 const opcode = this . fuzzer . picker . pickArrayOperation ( node ) ;
162162 const builder = new PatchBuilder ( model . clock ) ;
163163 const length = node . length ( ) ;
164- if ( opcode === InsArrOp ) {
164+ if ( ! length || ( opcode === InsArrOp ) ) {
165165 const json = RandomJson . generate ( { nodeCount : Math . ceil ( Math . random ( ) * 5 ) } ) ;
166166 const valueId = builder . json ( json ) ;
167167 if ( ! length ) builder . insArr ( node . id , node . id , [ valueId ] ) ;
@@ -173,6 +173,14 @@ export class SessionLogical {
173173 builder . insArr ( node . id , afterId , [ valueId ] ) ;
174174 }
175175 }
176+ } else if ( opcode === UpdArrOp ) {
177+ const pos = Math . floor ( Math . random ( ) * length ) ;
178+ const keyId = node . find ( pos ) ;
179+ if ( keyId ) {
180+ const json = RandomJson . generate ( { nodeCount : Math . ceil ( Math . random ( ) * 5 ) } ) ;
181+ const valueId = builder . json ( json ) ;
182+ builder . updArr ( node . id , keyId , valueId ) ;
183+ }
176184 } else {
177185 if ( ! length ) return builder . patch ;
178186 const pos = Math . floor ( Math . random ( ) * length ) ;
0 commit comments