diff options
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig index 4ba08849..c895618d 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -7124,6 +7124,37 @@ test "a 9P open the session made over a copy taken ahead, replayed after a rollb try agrees(a, r); } +test "a script's half line held over a copy taken ahead, its next write run and its rest moved to the front in place, put back by a rollback: the line replayed is the session's" { + var n = try NinepJoin.init("one\n", TestHost.host()); + defer n.deinit(); + try n.join(); + const r = n.late.?; + const exec = n.node(.exec); + const h = (try n.serve(.{ .tag = 1, .op = .open, .node = exec, .omode = 1 }, true)).handle; + _ = try n.serve(.{ .tag = 2, .op = .write, .node = exec, .handle = h, .data = "Ta" }, true); + r.ready(); + // Replayed over the copy and kept: `Tab 8` runs, `Un` is held where + // `Ta` was, in the buffer the copy holds. + _ = try n.serve(.{ .tag = 3, .op = .write, .node = exec, .handle = h, .data = "b 8\nUn" }, true); + try std.testing.expect(r.copy.held and r.since.items.len > 0); + var sent: std.ArrayListUnmanaged([]u8) = .empty; + defer { + for (sent.items) |m| std.testing.allocator.free(m); + sent.deinit(std.testing.allocator); + } + try key(r, 'l', &sent); + try std.testing.expectEqual(@as(usize, 1), r.applied); + // The session's key first: a rollback, the write replayed again. + try n.send(try n.a.local(.{ .key = .{ .cp = 'j', .text = "j" } })); + try std.testing.expect(r.stats.foreign > 0); + try n.send(try n.a.take(sent.items[0])); + _ = try n.serve(.{ .tag = 4, .op = .write, .node = exec, .handle = h, .data = "do\n" }, true); + _ = try n.serve(.{ .tag = 5, .op = .release, .node = exec, .handle = h, .opened = true }, true); + if (r.diverged) |why| std.debug.print("diverged: {s}\n", .{why}); + try std.testing.expect(r.diverged == null and r.quiet()); + try n.agree(); +} + // Del with a pane above and below asks which way the space goes, its // question shown once a delay is up (builtins.zig): its time was the // host's clock read in the step, an answering entry a speculation stops at. |
