MR1: the recovery module's whole test waits its start by the setup bound

The module's start is the test's setup: its two waits on the bus take
testbus.SetupBound (half of MESH_TEST_LEVEL_BOUND) and say a starved setup
in the one line testbus.Starved writes; its 30 s values go.

Builds: design 47 H2 §800; H-A-327, H-A-368
This commit is contained in:
2026-11-22 00:43:38 +01:00
parent 5d2d0bade8
commit cb5de6fd31
@@ -15,6 +15,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"
@@ -258,7 +259,8 @@ func TestRecoveryWhole(t *testing.T) {
events <- heard{m.Subject, b}
})
var kept []heard
waitEvent := func(t *testing.T, what string, ok func(heard) bool) map[string]any {
// saidWithin waits for an event ok takes, within bound, and ends the test by fail when none came.
saidWithin := func(t *testing.T, what string, bound time.Duration, fail func(string), ok func(heard) bool) map[string]any {
t.Helper()
for i, h := range kept {
if ok(h) {
@@ -266,7 +268,7 @@ func TestRecoveryWhole(t *testing.T) {
return h.body
}
}
deadline := time.After(30 * time.Second)
deadline := time.After(bound)
for {
select {
case h := <-events:
@@ -275,10 +277,15 @@ func TestRecoveryWhole(t *testing.T) {
}
kept = append(kept, h)
case <-deadline:
t.Fatalf("not said within 30s: %s", what)
fail(fmt.Sprintf("not said within %s: %s", bound, what))
return nil
}
}
}
waitEvent := func(t *testing.T, what string, ok func(heard) bool) map[string]any {
t.Helper()
return saidWithin(t, what, 30*time.Second, func(words string) { t.Helper(); t.Fatal(words) }, ok)
}
endOf := func(t *testing.T, event, act string) map[string]any {
t.Helper()
return waitEvent(t, event+" of "+act, func(h heard) bool {
@@ -347,13 +354,16 @@ func TestRecoveryWhole(t *testing.T) {
done := make(chan error, 1)
go func() { done <- run(runCtx, func(k string) string { return env[k] }, testLog{t}) }()
defer func() { stop(); <-done }()
waitEvent(t, "the start's removal of points past their keep days", func(h heard) bool {
// The module's start is the test's setup: its waits on the bus take the setup bound of the level's bound and say a starved
// setup in its one line, never a value of the test's own (design 47 H2 §800, H-A-327, H-A-368).
setup := testbus.SetupBound(t)
saidWithin(t, "the start's removal of points past their keep days", setup, func(words string) { testbus.Starved(t, words) }, func(h heard) bool {
return h.subject == "mesh.seat.mesh-recovery.event."+seat.EventExpiryEnded
})
select {
case <-listed:
case <-time.After(30 * time.Second):
t.Fatal("the module did not read its seat's definition from the seat list within 30s")
case <-time.After(setup):
testbus.Starved(t, fmt.Sprintf("the module did not read its seat's definition from the seat list within %s", setup))
}
var first string