Skip to content

Commit

Permalink
Increment client sequence number properly
Browse files Browse the repository at this point in the history
  • Loading branch information
andre4i committed Jul 19, 2023
1 parent 510cdd5 commit 01d1417
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/runtime/test-runtime-utils/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,22 @@ export class MockContainerRuntime {
}

public submit(messageContent: any, localOpMetadata: unknown): number {
const clientSequenceNumber =
this.clientSequenceNumber + (this.runtimeOptions.enableGroupedBatching ? 0 : 1);
if (!this.runtimeOptions.enableGroupedBatching) {
this.clientSequenceNumber++;
}

switch (this.runtimeOptions.flushMode) {
case FlushMode.Immediate: {
const msg: Partial<ISequencedDocumentMessage> = {
clientId: this.clientId,
clientSequenceNumber,
clientSequenceNumber: this.clientSequenceNumber,
contents: messageContent,
referenceSequenceNumber: this.referenceSequenceNumber,
type: MessageType.Operation,
};
this.factory.pushMessage(msg);

this.addPendingMessage(messageContent, localOpMetadata, clientSequenceNumber);
this.addPendingMessage(messageContent, localOpMetadata, this.clientSequenceNumber);
break;
}
case FlushMode.TurnBased: {
Expand All @@ -196,7 +197,7 @@ export class MockContainerRuntime {
throw new Error(`Unsupported FlushMode ${this.runtimeOptions.flushMode}`);
}

return clientSequenceNumber;
return this.clientSequenceNumber;
}

public dirty(): void {}
Expand Down

0 comments on commit 01d1417

Please sign in to comment.