summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/replica.zig b/src/replica.zig
index 2af32cdb..6a01ec26 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -3205,6 +3205,33 @@ test "a replica joined from the session's dump replays the units after it" {
try std.testing.expectEqual(digestOf(a), r.digest());
}
+test "a host's Adopt and a terminal reader's failure are inputs: a replica makes the same pane" {
+ const gpa = std.testing.allocator;
+ // Its terminals as screen state, as a session's for its clients are.
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), true);
+ defer a.deinit();
+ const was = Stepping.begin(&a.t, null);
+ const bytes = try pardes.dump.dumpBytes(a.core);
+ tape.resync(&a.t);
+ was.end();
+ defer a.core.gpa.free(bytes);
+ const r = try Replica.initDump(gpa, 1, 0, bytes, .{ .cols = 80, .rows = 24 });
+ defer r.deinit();
+ // What tty.zig's and gui.zig's adoptShell and a failed reader do between
+ // steps: they wrote the core straight, and every client joined again.
+ const host = Stepping.begin(&a.t, null);
+ const id = a.core.adoptShell().?;
+ try std.testing.expect(a.core.panes[id].?.isTerminal() and !a.core.panes[id].?.greet);
+ a.core.readerFailed(id, error.InputOutput);
+ a.core.pump(a.host) catch {};
+ host.end();
+ a.seq += 1;
+ r.confirm(try a.unit(0, a.seq));
+ if (r.diverged) |why| std.debug.print("diverged: {s}\n", .{why});
+ try std.testing.expect(r.diverged == null);
+ try std.testing.expectEqual(digestOf(a), r.digest());
+}
+
test "a join's dump, its blobs put back where they go, is the session's dump" {
const gpa = std.testing.allocator;
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);