Skip to content

Commit

Permalink
Update testClientLogger to show sides on obliterate ops (microsoft#22625
Browse files Browse the repository at this point in the history
)

Show the sides used in obliterate ops (if any) in the output of the
testClientLogger. When sidedness is not enabled, there is no change to
the logger output.
  • Loading branch information
jzaffiro authored Sep 25, 2024
1 parent 3b45dc6 commit ebcf800
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/dds/merge-tree/src/test/testClientLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ function getOpString(msg: ISequencedDocumentMessage | undefined): string {
}
const op = msg.contents as IMergeTreeOp;
const opType = op.type.toString();
// eslint-disable-next-line @typescript-eslint/dot-notation
const pos1Side = op?.["before1"] === undefined ? "" : op["before1"] ? "[" : "(";
// eslint-disable-next-line @typescript-eslint/dot-notation
const pos2Side = op?.["before2"] === undefined ? "" : op["before2"] ? ")" : "]";
const opPos =
// eslint-disable-next-line @typescript-eslint/dot-notation
op?.["pos1"] === undefined
? ""
: // eslint-disable-next-line @typescript-eslint/dot-notation
`@${op["pos1"]}${op["pos2"] === undefined ? "" : `,${op["pos2"]}`}`;
`@${pos1Side}${op["pos1"]}${op["pos2"] === undefined ? "" : `,${op["pos2"]}${pos2Side}`}`;

const seq = msg.sequenceNumber < 0 ? "L" : msg.sequenceNumber.toString();
const ref = msg.referenceSequenceNumber.toString();
Expand Down Expand Up @@ -313,9 +317,11 @@ export class TestClientLogger {
`-: Deleted ~:Deleted <= MinSeq\n` +
`*: Unacked Insert and Delete\n` +
`${this.clients[0].getCollabWindow().minSeq}: msn/offset\n` +
`Op format <seq>:<ref>:<client><type>@<pos1>,<pos2>\n` +
`Op format <seq>:<ref>:<client><type>@<side1><pos1>,<pos2><side2>\n` +
`sequence number represented as offset from msn. L means local.\n` +
`op types: 0) insert 1) remove 2) annotate 4) obliterate\n`;
`op types: 0) insert 1) remove 2) annotate 4) obliterate\n` +
`for obliterates: [] indicates that the range includes the position,\n` +
`and () indicates that the range excludes that position from the obliterate.\n`;

if (this.title) {
str += `${this.title}\n`;
Expand Down

0 comments on commit ebcf800

Please sign in to comment.