summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/replica.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 6c4f0b2c..cf628291 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -3715,6 +3715,11 @@ fn endJoin(j: *Joined, have: ?*Have) void {
/// as `Peers.join` sends it: its state, its blobs put back where they go.
fn joinedNow(a: *Authority, id: u16, view: u8) !*Replica {
const gpa = std.testing.allocator;
+ // What was recorded goes first, as a join sends it (Peers.dumped):
+ // left on the tape, the joiner's first unit replayed it over the dump
+ // it loaded (a session's `init` first: a core made afresh).
+ a.seq += 1;
+ _ = try a.unit(0, a.seq);
const was = Stepping.begin(&a.t, null);
var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty;
defer blobs.deinit(a.core.gpa);
@@ -3783,6 +3788,33 @@ fn shows(p: *Pardes, text: []const u8) !bool {
return false;
}
+test "a client joined from a dump keeps the session's jump list through a step: two entries the same but for their place's undefined bytes are one entry on both" {
+ // The release soak's parting (the witness: `views[3].jumps`): a text's
+ // entry has `.place = .{}`, bytes undefined: a session's are its
+ // stack's (here 0x11 and 0x22, the two a release build left), a
+ // client's what its load left; the step drops the gone entry between
+ // the two and makes them one where they compare the same.
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host());
+ defer a.deinit();
+ const v = a.core.view();
+ const serial = a.core.panes[v.active].?.serial;
+ var at: pardes.Jump.Loc = .{ .pane = @intCast(v.active), .serial = serial, .line = 1, .col = 1 };
+ var again = at;
+ @memset(&at.place.bytes, 0x11);
+ @memset(&again.place.bytes, 0x22);
+ v.jumps.list[0] = at;
+ v.jumps.list[1] = .{ .pane = 5, .serial = 999, .line = 1, .col = 1 };
+ v.jumps.list[2] = again;
+ v.jumps.list[3] = .{ .pane = @intCast(v.active), .serial = serial, .line = 150, .col = 1 };
+ v.jumps.n, v.jumps.cur = .{ 4, 3 };
+ const r = try joinedNow(a, 1, 0);
+ defer r.deinit();
+ r.confirm(try a.local(.{ .key = .{ .cp = 'l', .text = "l" } }));
+ try agrees(a, r);
+ try std.testing.expectEqual(@as(usize, 2), r.core().view().jumps.n);
+}
+
test "a message past the wire's bound is named, never read as the link's end" {
var fds: [2]c_int = undefined;
try std.testing.expectEqual(0, libc.pipe(&fds));