@fluidframework/merge-tree 2.22.0 → 2.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1499,6 +1499,58 @@ for (const incremental of [true, false]) {
1499
1499
  helper.processAllOps();
1500
1500
  helper.logger.validate({ baseText: "8m" });
1501
1501
  });
1502
+ // See 'Local obliterate wins post-insertion of segment previously thought to have won' (below) for a simpler
1503
+ // to understand version of this test. This test is the original partial synchronization fuzz variant which
1504
+ // demonstrated that issue, and has been preserved for now in case it catches additional related problems.
1505
+ // Once fuzz testing more meaninfully leverages ops being sent to different clients at different types (partial
1506
+ // synchronization), it's probably fine to remove this.
1507
+ it("fuzz regression: Local obliterate wins post-insertion of segment previously thought to have won", () => {
1508
+ const helper = new partialSyncHelper_js_1.PartialSyncTestHelper();
1509
+ helper.insertText("A", 0, "Hx15J");
1510
+ helper.processAllOps();
1511
+ helper.insertText("A", 0, "9T");
1512
+ helper.insertText("B", 0, "c8v");
1513
+ helper.advanceClients("A", "C");
1514
+ helper.removeRange("A", 2, 5);
1515
+ helper.removeRange("A", 0, 1);
1516
+ helper.obliterateRange("A", 0, 3);
1517
+ helper.obliterateRange("C", { pos: 1, side: sequencePlace_js_1.Side.After }, { pos: 4, side: sequencePlace_js_1.Side.Before });
1518
+ helper.insertText("B", 0, "4qpo");
1519
+ helper.insertText("C", 2, "fP");
1520
+ helper.insertText("A", 0, "hn");
1521
+ helper.advanceClients("A", "C");
1522
+ helper.obliterateRange("A", { pos: 5, side: sequencePlace_js_1.Side.After }, { pos: 9, side: sequencePlace_js_1.Side.After });
1523
+ helper.obliterateRange("B", { pos: 3, side: sequencePlace_js_1.Side.Before }, { pos: 9, side: sequencePlace_js_1.Side.After });
1524
+ // At the time of the original bug, this would hit 0xa3f.
1525
+ helper.processAllOps();
1526
+ helper.logger.validate({ baseText: "hn4qpJ" });
1527
+ });
1528
+ // Simpler version of the above test which has the same root cause but reproduces a slightly different failure mode.
1529
+ it("Local obliterate wins post-insertion of segment previously thought to have won", () => {
1530
+ const helper = new partialSyncHelper_js_1.PartialSyncTestHelper();
1531
+ helper.insertText("A", 0, "1xx2");
1532
+ helper.processAllOps();
1533
+ // A and B both obliterate the 'xx' segment with an expanding obliterate, then try to insert
1534
+ // into the gap that it leaves.
1535
+ helper.obliterateRange("A", { pos: 0, side: sequencePlace_js_1.Side.After }, { pos: 3, side: sequencePlace_js_1.Side.Before });
1536
+ helper.insertText("A", 1, "aaaa");
1537
+ helper.obliterateRange("B", { pos: 0, side: sequencePlace_js_1.Side.After }, { pos: 3, side: sequencePlace_js_1.Side.Before });
1538
+ helper.insertText("B", 1, "bbb");
1539
+ helper.advanceClients("A", "B");
1540
+ // Meanwhile, C attempts the same thing without seeing A or B's obliterate & insertions
1541
+ helper.obliterateRange("C", { pos: 0, side: sequencePlace_js_1.Side.After }, { pos: 3, side: sequencePlace_js_1.Side.Before });
1542
+ helper.insertText("C", 1, "ccc");
1543
+ // Before seeing C's ops, B attempts to insert more content. Since B hasn't yet seen C's obliterate,
1544
+ // A and B are under the impression that B's obliterate has won and the string contents are '1bbb2'.
1545
+ helper.insertText("B", 5, "B");
1546
+ helper.insertText("A", 5, "A");
1547
+ helper.processAllOps();
1548
+ // By now, all clients realize C actually won the obliterate and should have additionally applied B's
1549
+ // op correctly as it was outside of the obliterated range.
1550
+ // At the time this test was written, client C had trouble recognizing that A and B think that B has won
1551
+ // and merged incorrectly, hitting 'MergeTree insert failed'.
1552
+ helper.logger.validate({ baseText: "1ccc2AB" });
1553
+ });
1502
1554
  });
1503
1555
  });
1504
1556
  }