summaryrefslogtreecommitdiff
path: root/test/replicas.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/replicas.zig')
-rw-r--r--test/replicas.zig26
1 files changed, 15 insertions, 11 deletions
diff --git a/test/replicas.zig b/test/replicas.zig
index 88881dd7..57b6ff23 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -102,7 +102,8 @@ const Host = struct {
return h.draws;
}
- fn ptyWrite(ctx: ?*anyopaque, pane: u8, bytes: []const u8) void {
+ fn ptyWrite(ctx: ?*anyopaque, id: pardes.Pane.Id, bytes: []const u8) void {
+ const pane = id.index();
const h: *Host = @ptrCast(@alignCast(ctx.?));
h.echo.append(gpa, .{ .pane = pane, .bytes = gpa.dupe(u8, bytes) catch return }) catch {};
}
@@ -123,7 +124,8 @@ const Host = struct {
/// it at once on the core's side, inside the perform that asked it,
/// where no tape records it: a client replays that perform without it).
/// At the setup, before any client, at once inside this call.
- fn job(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void {
+ fn job(ctx: ?*anyopaque, id: pardes.Pane.Id, serial: u32, token: u32) void {
+ const pane = id.index();
const h: *Host = @ptrCast(@alignCast(ctx.?));
const j = pardes.host_io.KindJob.take(h.core.?, pane, serial, token) orelse return;
if (Draws.go(null, j)) return;
@@ -807,7 +809,8 @@ const Soak = struct {
return of(ctx).at_frame;
}
- fn ptyWrite(ctx: ?*anyopaque, pane: u8, bytes: []const u8) void {
+ fn ptyWrite(ctx: ?*anyopaque, id: pardes.Pane.Id, bytes: []const u8) void {
+ const pane = id.index();
const s = of(ctx);
s.echo.append(gpa, .{ .pane = pane, .bytes = gpa.dupe(u8, bytes) catch return }) catch {};
}
@@ -827,7 +830,8 @@ const Soak = struct {
/// its loop's event (with no `job`, Effect.perform runs it at once on
/// the core's side, inside the perform that asked it, where no tape
/// records it: a client replays that perform without it).
- fn job(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void {
+ fn job(ctx: ?*anyopaque, id: pardes.Pane.Id, serial: u32, token: u32) void {
+ const pane = id.index();
const core = of(ctx).l.core;
const j = pardes.host_io.KindJob.take(core, pane, serial, token) orelse return;
if (Draws.go(null, j)) return;
@@ -1014,7 +1018,7 @@ const Soak = struct {
cl.read_done = false;
cl.gen += 1;
cl.id = welcome.client;
- cl.view = welcome.view;
+ cl.view = welcome.view.index();
cl.digest = welcome.digest;
s.totals.joins += 1;
try net.toClient(c, now, .dump, cl.gen, try whole.toOwnedSlice(gpa));
@@ -1185,7 +1189,7 @@ const Soak = struct {
// program's output a frame a tick (tui.zig `waitInput`).
.echo => {
s.clock();
- core.update(.{ .output = .{ .pane = @intCast(m.who), .bytes = m.bytes } });
+ core.update(.{ .output = .{ .pane = .at(m.who), .bytes = m.bytes } });
return false;
},
.output => {
@@ -1205,7 +1209,7 @@ const Soak = struct {
if (s.program.at < s.program.bytes.len)
try net.send(.{ .at = m.at + if (m.who == 1) @as(u64, 450) else 3_000, .n = 0, .kind = .output, .who = m.who, .bytes = &.{} })
else if (m.who == 1) s.flood_end = m.at;
- core.update(.{ .output = .{ .pane = s.shell, .bytes = chunk } });
+ core.update(.{ .output = .{ .pane = .at(s.shell), .bytes = chunk } });
took_output = true;
},
.frame => {
@@ -1271,7 +1275,7 @@ const Soak = struct {
// A state job's answer: a step of the session's own.
if (j.draw == null) {
s.clock();
- core.update(.{ .job = .{ .pane = j.pane, .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } });
+ core.update(.{ .job = .{ .pane = .at(j.pane), .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } });
j.drop();
return false;
}
@@ -2139,7 +2143,7 @@ const EchoHost = struct {
return false;
}
- fn ptyWrite(ctx: ?*anyopaque, _: u8, bytes: []const u8) void {
+ fn ptyWrite(ctx: ?*anyopaque, _: pardes.Pane.Id, bytes: []const u8) void {
const h: *EchoHost = @ptrCast(@alignCast(ctx.?));
h.writes.append(gpa, .{ .seq = h.current, .bytes = gpa.dupe(u8, bytes) catch return }) catch {};
}
@@ -2287,7 +2291,7 @@ fn runEcho(seed: u64, rtt_ms: u64, on: bool, et: *EchoTotals) !void {
// The shell's first prompt.
sh.put(prompt_bytes);
- a.output(.{ .output = .{ .pane = shell, .bytes = sh.out.items } });
+ a.output(.{ .output = .{ .pane = .at(shell), .bytes = sh.out.items } });
sh.out.clearRetainingCapacity();
var next_step: usize = 0;
try push(&queue, &n, .{ .at = corpus.steps.items[0].gap, .n = 0, .kind = .input, .who = 1, .bytes = &.{} });
@@ -2351,7 +2355,7 @@ fn runEcho(seed: u64, rtt_ms: u64, on: bool, et: *EchoTotals) !void {
}
sh.key(m.bytes);
if (sh.out.items.len > 0) {
- a.output(.{ .output = .{ .pane = shell, .bytes = sh.out.items } });
+ a.output(.{ .output = .{ .pane = .at(shell), .bytes = sh.out.items } });
sh.out.clearRetainingCapacity();
if (ty) |k| k.echoed = true;
}