package thintest import ( "crypto/sha256" "encoding/base64" "encoding/hex" "strings" "testing" "time" "amadan.net/oficina/equipo/internal/equipo/chat" "amadan.net/oficina/equipo/internal/wire" ) // peer is a scripted runner with the frames it received but has not // looked at yet. type peer struct { t *testing.T r *toolRig fr *FakeRunner held []heldFrame seq int } func (p *peer) id(prefix string) string { p.seq++ return prefix + "-" + itoa(p.seq) } // send sends a frame and, for a durable one, waits for its ack. func (p *peer) send(kind string, body any) string { p.t.Helper() id := p.id("p-" + kind) if err := p.fr.Send(p.r.ctx, id, kind, body); err != nil { p.t.Fatal(err) } if !(wire.Frame{Type: kind}).Durable() && kind != wire.FrameLease { return id } for { f, body, err := p.fr.Next(p.r.ctx) if err != nil { p.t.Fatalf("waiting for the ack of %s: %v", id, err) } if a, ok := body.(*wire.Ack); ok && a.ID == id { return id } if rf, ok := body.(*wire.Refused); ok && rf.ID == id { p.held = append(p.held, heldFrame{f, body, nil}) return id } if f.Type != wire.FrameAck { p.held = append(p.held, heldFrame{f, body, p.fr.Received[len(p.fr.Received)-1]}) } } } // lease asks for the start authorization of an attempt: true when acked, // false when refused. func (p *peer) lease(step string, attempt int64) bool { p.t.Helper() id := p.send(wire.FrameLease, wire.LeaseCheck{Generation: p.fr.Welcome.Generation, StepID: step, Attempt: attempt}) for i, h := range p.held { if rf, ok := h.body.(*wire.Refused); ok && rf.ID == id { p.held = append(p.held[:i:i], p.held[i+1:]...) return false } } return true } // leasePublication is the primary's confirmation before it pushes. func (p *peer) leasePublication(step string, attempt int64, publication string) bool { p.t.Helper() id := p.send(wire.FrameLease, wire.LeaseCheck{Generation: p.fr.Welcome.Generation, StepID: step, Attempt: attempt, Publication: publication}) for i, h := range p.held { if rf, ok := h.body.(*wire.Refused); ok && rf.ID == id { p.held = append(p.held[:i:i], p.held[i+1:]...) return false } } return true } // expect returns the next frame of kind (held first), acking it. func (p *peer) expect(kind string) (wire.Frame, any) { p.t.Helper() for i, h := range p.held { if h.f.Type == kind { p.held = append(p.held[:i:i], p.held[i+1:]...) p.ack(h.f) return h.f, h.body } } for { f, body, err := p.fr.Next(p.r.ctx) if err != nil { p.t.Fatalf("waiting for %s: %v", kind, err) } if f.Type == kind { p.ack(f) return f, body } if f.Type != wire.FrameAck { p.held = append(p.held, heldFrame{f, body, p.fr.Received[len(p.fr.Received)-1]}) } } } // none checks, after d, that nothing of kind was sent to this runner and // none waits in its mailbox. (A read deadline would close the socket.) func (p *peer) none(kind string, d time.Duration) { p.t.Helper() time.Sleep(d) for _, h := range p.held { if h.f.Type == kind { p.t.Fatalf("unexpected %s: %s", kind, h.raw) } } var n int if err := p.r.inst.DB.Writer().QueryRow("SELECT count(*) FROM runner_commands WHERE runner_id = ? AND kind = ? AND acked_at IS NULL", p.fr.Welcome.RunnerID, kind).Scan(&n); err != nil { p.t.Fatal(err) } if n != 0 { p.t.Fatalf("%d %s waiting for this runner", n, kind) } } // heartbeat says hello again (under the store's clock), then waits for a // lease round trip so it has been applied. func (p *peer) heartbeat(h wire.Hello) { p.t.Helper() h.Generation = p.fr.Welcome.Generation if err := p.fr.Send(p.r.ctx, p.id("hb"), wire.FrameHello, h); err != nil { p.t.Fatal(err) } p.lease("", 0) } func (p *peer) ack(f wire.Frame) { if f.Durable() { if err := p.fr.Send(p.r.ctx, "a-"+f.ID, wire.FrameAck, wire.Ack{ID: f.ID}); err != nil { p.t.Fatal(err) } } } // primaryHello is the tool rig's hello at protocol 2 from a Linux primary. func primaryHello(generation int64) wire.Hello { h := toolHello(generation) h.Protocol, h.Platform, h.Label, h.Sandbox = wire.Protocol2, &wire.Platform{OS: "linux", Arch: "amd64"}, "docs-t1", wire.SandboxBubblewrap h.Capabilities = &wire.Capabilities{Simulators: []wire.Simulator{}, Tags: []string{wire.TagLinux, wire.TagClaude, wire.TagGo}} return h } // runnersRig is the tool rig with its primary at protocol 2. type runnersRig struct { *toolRig primary *peer // creds are each worker connection's credential and label. creds map[*FakeRunner][2]string } func newRunnersRig(t *testing.T) *runnersRig { return newRunnersRigAt(t, wire.Protocol2) } // newRunnersRigAt is the runners rig with its primary at protocol // (wire.ProtocolMergeFacts where Equipo should merge on its own). func newRunnersRigAt(t *testing.T, protocol int) *runnersRig { r := newToolRig(t) gen := r.runner.Welcome.Generation r.runner.Close() h := primaryHello(gen) h.Protocol = protocol p, err := DialRunnerHello(r.ctx, r.inst.URL, r.rig.runner, h) if err != nil { t.Fatal(err) } t.Cleanup(p.Close) if p.Welcome.Role != wire.RolePrimary || p.Welcome.Protocol != protocol { t.Fatalf("primary welcome %+v", p.Welcome) } r.runner = p rr := &runnersRig{toolRig: r, primary: &peer{t: t, r: r, fr: p}, creds: map[*FakeRunner][2]string{}} return rr } // worker enrols and connects a Mac worker. func (r *runnersRig) newWorker(label string) (*peer, string) { r.t.Helper() token := r.inst.EnrolRunner(r.t).Token return r.dialWorker(token, label, 0), token } func (r *runnersRig) dialWorker(token, label string, gen int64) *peer { r.t.Helper() h := WorkerHello(gen) h.Label = label w, err := DialRunnerHello(r.ctx, r.inst.URL, token, h) if err != nil { r.t.Fatal(err) } r.t.Cleanup(w.Close) r.creds[w] = [2]string{token, label} return &peer{t: r.t, r: r.toolRig, fr: w} } // candidate records a task and runs its Engineering step on the primary to // a pushed candidate that touched Apple files, so its checks need a Mac. // It returns the task and the checks step's id once it exists. func (r *runnersRig) candidate(title string, apple bool) (task, sha string) { r.t.Helper() task = taskID(r.t, r.call("c-"+title, wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": title, "brief": "b"})) r.call("s-"+title, wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) _, body := r.expect(wire.FrameDispatch) d := body.(*wire.DispatchCommand) if d.RunnerID == "" || len(d.Needs) != 0 { r.t.Fatalf("engineering dispatch %+v", d) } sha = strings.Repeat(string(rune('a'+len(title)%6)), 40) r.step("e1-"+task, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: strings.Repeat("1", 40), Findings: []wire.Finding{}}) r.step("e2-"+task, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, CandidateSHA: sha, Findings: []wire.Finding{}}) r.step("e3-"+task, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepDone, CandidateSHA: sha, Pushed: true, Termination: true, TerminationKind: wire.TerminationNamespace, Apple: apple, Findings: []wire.Finding{}}) return task, sha } func (r *runnersRig) checksStep(task string) wire.Step { r.t.Helper() k, err := r.client.Task(r.ctx, task) if err != nil { r.t.Fatal(err) } for _, s := range k.Steps { if s.Specialist == wire.SpecialistChecks { return s } } r.t.Fatalf("no checks step: %+v", k.Steps) return wire.Step{} } // relay uploads a one-chunk pack from the primary for the inbound // transfer it was asked for, and returns the chunk the worker receives. func (r *runnersRig) relay(w *peer, data []byte) *wire.Blob { r.t.Helper() _, body := r.primary.expect(wire.FrameSendPack) sp := body.(*wire.SendPackCommand) sum := sha256.Sum256(data) r.primary.send(wire.FrameBlob, wire.Blob{Transfer: sp.Transfer, Index: 0, Total: 1, SHA256: hex.EncodeToString(sum[:]), Data: base64.StdEncoding.EncodeToString(data)}) _, got := w.expect(wire.FrameBlob) return got.(*wire.Blob) } func passed(task, step string, attempt int64, sha string) wire.StepReport { zero := 0 return wire.StepReport{TaskID: task, StepID: step, Attempt: attempt, State: wire.StepDone, CandidateSHA: sha, Checks: wire.ChecksPassed, Gate: "xcodebuild test", ExitCode: &zero, Output: "** TEST SUCCEEDED **", Termination: true, TerminationKind: wire.TerminationProcessGroup, Findings: []wire.Finding{}} } // M1 at the contract: an iOS change's checks are placed on the Mac // worker, the candidate is relayed as a pack from the primary, the worker // starts the attempt with its start authorization and passes it, and // review is placed back on the primary. Linux checks stay on the primary. func TestContractChecksPlacedOnTheWorker(t *testing.T) { r := newRunnersRig(t) w, _ := r.newWorker("Tito Studio") task, sha := r.candidate("iOS swipe", true) _, body := w.expect(wire.FrameDispatch) d := body.(*wire.DispatchCommand) shape(t, "frames/dispatch-needs.json", w.fr.Received[len(w.fr.Received)-1]) if d.Specialist != wire.SpecialistChecks || d.CandidateSHA != sha || d.RunnerID == "" || strings.Join(d.Needs, ",") != "macos,xcode" { t.Fatalf("worker dispatch %+v", d) } blob := r.relay(w, []byte("PACK one commit")) shape(t, "frames/blob.json", w.fr.Received[len(w.fr.Received)-1]) if blob.Transfer.Direction != wire.TransferInbound || blob.Transfer.StepID != d.StepID || blob.Transfer.Attempt != 1 || blob.Transfer.CandidateSHA != sha { t.Fatalf("relayed header %+v", blob.Transfer) } s := r.checksStep(task) if s.RunnerLabel != "Tito Studio" || s.Placement != "" || strings.Join(s.Needs, ",") != "macos,xcode" { t.Fatalf("checks step %+v", s) } if !w.lease(d.StepID, 1) { t.Fatal("start refused") } if !w.lease(d.StepID, 1) { t.Fatal("a repeated start authorization (a resent lease) was refused") } w.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, CandidateSHA: sha, Findings: []wire.Finding{}}) // P2 did not deny every attempt, so the worker ran checks outside the // sandbox and says so; step and task carry it (Paul's ruling 2). pass := passed(task, d.StepID, 1, sha) pass.ChecksSandbox = wire.SandboxNone w.send(wire.FrameStep, pass) _, body = r.expect(wire.FrameDispatch) if rv := body.(*wire.DispatchCommand); rv.Specialist != wire.SpecialistReview || len(rv.Needs) != 0 { t.Fatalf("review dispatch %+v", rv) } k, _ := r.client.Task(r.ctx, task) if k.Checks != wire.ChecksPassed || k.Steps[1].TerminationKind != wire.TerminationProcessGroup || k.Steps[1].StartedAt == nil { t.Fatalf("task %+v", k) } if k.ChecksSandbox != wire.SandboxNone || k.Steps[1].ChecksSandbox != wire.SandboxNone { t.Fatalf("checks outside the sandbox not labelled: task %q step %q", k.ChecksSandbox, k.Steps[1].ChecksSandbox) } runners, err := r.client.Runners(r.ctx) if err != nil || len(runners.Items) != 2 || runners.Items[0].Role != wire.RolePrimary || runners.Items[1].Label != "Tito Studio" || !runners.Items[1].Online { t.Fatalf("runners %+v %v", runners, err) } if c := runners.Items[1].Capabilities; c == nil || len(c.Probes) != 7 || c.Probes[1].ID != "P2" || c.Probes[1].Verdict != wire.ProbeFailed { t.Fatalf("the worker's probes are not on the runners view: %+v", c) } // Approved, checks passed outside the sandbox: Equipo does not merge // on its own; it asks (no merge dispatched; the next dispatch below is // the next task's Engineering). r.primary.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: body.(*wire.DispatchCommand).StepID, Attempt: 1, State: wire.StepDone, CandidateSHA: sha, Verdict: wire.VerdictApprove, ReviewLabel: wire.ReviewOtherFamily, Family: "codex", Termination: true, TerminationKind: wire.TerminationNamespace, Findings: []wire.Finding{}}) deadline := time.Now().Add(5 * time.Second) for { k, _ = r.client.Task(r.ctx, task) if k.Stage == wire.StageReadyToMerge || time.Now().After(deadline) { break } time.Sleep(50 * time.Millisecond) } if k.Stage != wire.StageReadyToMerge || k.NeedsYou != wire.NeedsMerge { t.Fatalf("checks outside the sandbox merged on their own: %+v", k) } // A change that needs no Mac stays on the primary, worker or not. plain, _ := r.candidate("Go fix", false) _, body = r.expect(wire.FrameDispatch) c := body.(*wire.DispatchCommand) if c.Specialist != wire.SpecialistChecks || c.TaskID != plain || len(c.Needs) != 0 { t.Fatalf("plain checks %+v", c) } // The primary's checks carry no worker label, whatever it reports. own := passed(plain, c.StepID, 1, c.CandidateSHA) own.ChecksSandbox = wire.SandboxNone r.primary.send(wire.FrameStep, own) r.expect(wire.FrameDispatch) if k, _ := r.client.Task(r.ctx, plain); k.Checks != wire.ChecksPassed || k.ChecksSandbox != "" { t.Fatalf("primary's checks labelled: %+v", k) } } // M3 at the contract: with no worker that fits, checks no longer go to // the Linux primary (2026-11-28): they wait for a Mac runner, nothing // dispatched (TestContractChecksWaitForAMacRunner follows them to a Mac). func TestContractChecksWithoutAWorker(t *testing.T) { r := newRunnersRig(t) task, _ := r.candidate("iOS swipe", true) r.primary.none(wire.FrameDispatch, 200*time.Millisecond) if s := r.checksStep(task); s.Placement != wire.PlacementMac || s.RunnerID != "" { t.Fatalf("checks step %+v", s) } } // M2 at the contract: the fitting worker is offline, so checks wait // (placement waiting_runner, no dispatch anywhere); it reconnects and the // step is placed on it. A second task waits 30 minutes (a fake clock) and // resolves as not run, runner_offline, never a pass; review proceeds. func TestContractChecksWaitForTheWorker(t *testing.T) { r := newRunnersRig(t) w, token := r.newWorker("Tito Studio") gen := w.fr.Welcome.Generation w.fr.Close() time.Sleep(100 * time.Millisecond) task, _ := r.candidate("iOS swipe", true) if s := r.checksStep(task); s.Placement != wire.PlacementWaiting || s.RunnerID != "" { t.Fatalf("checks did not wait: %+v", s) } r.primary.none(wire.FrameSendPack, 200*time.Millisecond) w = r.dialWorker(token, "Tito Studio", gen) _, body := w.expect(wire.FrameDispatch) if d := body.(*wire.DispatchCommand); d.TaskID != task || d.Attempt != 1 { t.Fatalf("dispatch after reconnect %+v", d) } if s := r.checksStep(task); s.Placement != "" || s.RunnerLabel != "Tito Studio" { t.Fatalf("not placed after reconnect: %+v", s) } w.fr.Close() time.Sleep(100 * time.Millisecond) other, _ := r.candidate("iOS other", true) if s := r.checksStep(other); s.Placement != wire.PlacementWaiting { t.Fatalf("second checks did not wait: %+v", s) } clock := time.Now().UTC() r.inst.Store.Chat().SetClock(func() time.Time { return clock }) if err := r.inst.Store.Chat().Place(r.ctx); err != nil { t.Fatal(err) } if s := r.checksStep(other); s.State != wire.StepQueued { t.Fatalf("resolved before 30 minutes: %+v", s) } clock = clock.Add(chat.OfflineLimit) if err := r.inst.Store.Chat().Place(r.ctx); err != nil { t.Fatal(err) } k, _ := r.client.Task(r.ctx, other) s := r.checksStep(other) if s.State != wire.StepDone || s.Checks != wire.ChecksCannotRun || s.Reason != "runner_offline" || k.Checks == wire.ChecksPassed || k.ChecksReason != "runner_offline" { t.Fatalf("offline checks %+v task %+v", s, k) } _, body = r.expect(wire.FrameDispatch) if rv := body.(*wire.DispatchCommand); rv.TaskID != other || rv.Specialist != wire.SpecialistReview { t.Fatalf("review did not proceed: %+v", rv) } } // M6 placement at the contract: a worker that lacks a need refuses the // dispatch (placement_refused) and the step is placed on another worker. // The first worker's later reports for that attempt are refused. func TestContractPlacementRefused(t *testing.T) { r := newRunnersRig(t) a, _ := r.newWorker("Mac A") task, sha := r.candidate("iOS swipe", true) _, body := a.expect(wire.FrameDispatch) d := body.(*wire.DispatchCommand) b, _ := r.newWorker("Mac B") a.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepFailed, Reason: "placement_refused", Termination: true, Findings: []wire.Finding{}}) _, body = b.expect(wire.FrameDispatch) d2 := body.(*wire.DispatchCommand) if d2.StepID != d.StepID || d2.Attempt != 2 { t.Fatalf("re-placed dispatch %+v", d2) } if a.lease(d.StepID, 1) || a.lease(d.StepID, 2) { t.Fatal("the refusing worker may still start the step") } // A delayed result from the first attempt is refused. a.send(wire.FrameStep, passed(task, d.StepID, 1, sha)) if s := r.checksStep(task); s.Attempt != 2 || s.State != wire.StepQueued || s.RunnerLabel != "Mac B" { t.Fatalf("after a stale report %+v", s) } } // Withdrawal (M6): an unacked dispatch on a worker that went offline is // withdrawn when another fitting worker is online; it never started, so // the next attempt is placed at once and the first can never start. An // attempt that did start is cancelled instead, and the next attempt // exists only once its termination is reported. func TestContractWithdrawal(t *testing.T) { r := newRunnersRig(t) a, tokenA := r.newWorker("Mac A") genA := a.fr.Welcome.Generation task, _ := r.candidate("iOS swipe", true) if _, _, err := a.fr.Expect(r.ctx, wire.FrameDispatch); err != nil { // received, never acked t.Fatal(err) } step := r.checksStep(task).ID a.fr.Close() b, _ := r.newWorker("Mac B") // A short absence withdraws nothing. if err := r.inst.Store.Chat().Place(r.ctx); err != nil { t.Fatal(err) } b.none(wire.FrameDispatch, 100*time.Millisecond) clock := time.Now().UTC().Add(chat.WithdrawAfter) r.inst.Store.Chat().SetClock(func() time.Time { return clock }) b.heartbeat(withLabel(WorkerHello(0), "Mac B")) if err := r.inst.Store.Chat().Place(r.ctx); err != nil { t.Fatal(err) } _, body := b.expect(wire.FrameDispatch) if d := body.(*wire.DispatchCommand); d.StepID != step || d.Attempt != 2 { t.Fatalf("withdrawn and re-placed %+v", d) } r.inst.Store.Chat().SetClock(func() time.Time { return time.Now().UTC() }) a = r.dialWorker(tokenA, "Mac A", genA) if a.lease(step, 1) { t.Fatal("a withdrawn attempt was authorised to start") } a.none(wire.FrameDispatch, 200*time.Millisecond) // Attempt 2 starts on B, then B goes away; A is online and fits. if !b.lease(step, 2) { t.Fatal("attempt 2 refused") } b.fr.Close() // (B's last heartbeat was stamped by the first fake clock.) clock = time.Now().UTC().Add(2*chat.WithdrawAfter + time.Second) r.inst.Store.Chat().SetClock(func() time.Time { return clock }) a.heartbeat(withLabel(WorkerHello(0), "Mac A")) if err := r.inst.Store.Chat().Place(r.ctx); err != nil { t.Fatal(err) } r.inst.Store.Chat().SetClock(func() time.Time { return time.Now().UTC() }) a.none(wire.FrameDispatch, 300*time.Millisecond) if s := r.checksStep(task); s.Attempt != 2 || s.State == wire.StepDone { t.Fatalf("a started attempt was replaced before its termination: %+v", s) } // B comes back, is told to cancel, and proves termination: only then // is attempt 3 placed (on A). bb := r.reconnectPeer(b) _, body = bb.expect(wire.FrameCancelStep) if c := body.(*wire.CancelStepCommand); c.StepID != step || c.Attempt != 2 { t.Fatalf("cancel %+v", c) } bb.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: step, Attempt: 2, State: wire.StepCancelled, Reason: "cancelled", Termination: true, TerminationKind: wire.TerminationProcessGroup, Findings: []wire.Finding{}}) _, body = a.expect(wire.FrameDispatch) if d := body.(*wire.DispatchCommand); d.StepID != step || d.Attempt != 3 { t.Fatalf("attempt 3 %+v", d) } } // reconnectPeer dials a runner again with the same credential and // generation. func (r *runnersRig) reconnectPeer(p *peer) *peer { r.t.Helper() c, ok := r.creds[p.fr] if !ok { r.t.Fatal("unknown peer") } return r.dialWorker(c[0], c[1], p.fr.Welcome.Generation) } func withLabel(h wire.Hello, label string) wire.Hello { h.Label = label return h } // macChecks runs one task's checks on the worker to a passed report // labelled sandbox, and returns the task. func (r *runnersRig) macChecks(w *peer, title, sandbox string) wire.Task { r.t.Helper() task, sha := r.candidate(title, true) _, body := w.expect(wire.FrameDispatch) d := body.(*wire.DispatchCommand) r.relay(w, []byte("PACK "+title)) if !w.lease(d.StepID, 1) { r.t.Fatal("start refused") } pass := passed(task, d.StepID, 1, sha) pass.ChecksSandbox = sandbox w.send(wire.FrameStep, pass) r.expect(wire.FrameDispatch) // review on the primary k, err := r.client.Task(r.ctx, task) if err != nil { r.t.Fatal(err) } return k } // The taint is the instance's to keep: once a worker reports checks run // outside the sandbox, no later check is placed on it in the sandbox, // whatever it says (they wait for its sandbox); its welcome says it is tainted (so a runner whose // file was deleted takes it back); a hello saying tainted is enough too. func TestContractWorkerTaintIsSticky(t *testing.T) { r := newRunnersRig(t) w, token := r.newWorker("Tito Studio") if k := r.macChecks(w, "first", wire.SandboxSeatbelt); k.ChecksSandbox != wire.SandboxSeatbelt { t.Fatalf("a clean runner's sandboxed checks: %q", k.ChecksSandbox) } if w.fr.Welcome.Tainted { t.Fatal("a clean runner welcomed as tainted") } if k := r.macChecks(w, "second", wire.SandboxNone); k.ChecksSandbox != wire.SandboxNone { t.Fatalf("outside the sandbox: %q", k.ChecksSandbox) } // Tainted, so its sandbox is not trusted again, whatever its hello // says: the next checks wait for it instead of running. third, _ := r.candidate("third", true) r.waitsForSandbox(w, third, 1) again := r.dialWorker(token, "Tito Studio", w.fr.Welcome.Generation) if !again.fr.Welcome.Tainted { t.Fatal("the welcome does not say tainted") } // A second Mac that says it is tainted is, from then on. other, _ := r.newWorker("Mac mini") h := WorkerHello(other.fr.Welcome.Generation) h.Label, h.Capabilities.Tainted = "Mac mini", true other.send(wire.FrameHello, h) deadline := time.Now().Add(5 * time.Second) for { var n int if err := r.inst.DB.Writer().QueryRow("SELECT count(*) FROM runners WHERE id = ? AND tainted_at IS NOT NULL", other.fr.Welcome.RunnerID).Scan(&n); err != nil { t.Fatal(err) } if n == 1 { break } if time.Now().After(deadline) { t.Fatal("a tainted hello not recorded") } time.Sleep(50 * time.Millisecond) } }