A3e item 1: the tool runner serves through mesh-sdk's gate, translating the contracts for it
Builds: design 47 G §677, §700, lead answers A-219, A-224, A-228 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
seat "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||
catalogseat "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
gate "git.novox.be/novox/mesh-sdk/go/approval"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
@@ -27,7 +28,7 @@ func newMem() *mem { return mt.NewState() }
|
||||
// world is a gate on a fixture mesh: the catalog half, the router's records as the router writes them (mesh-catalog's
|
||||
// messenger, asks.go), the asks published, the clock.
|
||||
type world struct {
|
||||
g *Gate
|
||||
g *gate.Gate
|
||||
state *mem
|
||||
cat *fakeCatalog
|
||||
records map[string]seat.AsksByAskerIDValue // by `<module>.<id>`
|
||||
@@ -43,6 +44,16 @@ type world struct {
|
||||
// warranted is what mesh-hand-acts.warranted answers, and recorded each ask it answered for.
|
||||
warranted error
|
||||
recorded []string
|
||||
// deps is the gate's, made anew by rebuild; publish and record are the bus's publish and the router's record read.
|
||||
deps gate.Deps
|
||||
publish func(module, subject string, body any, id string) error
|
||||
record func(module, id string) (*stdio.StateEntry, error)
|
||||
}
|
||||
|
||||
// rebuild makes the gate anew from w.deps, its module's bundle loaded.
|
||||
func (w *world) rebuild() {
|
||||
w.g = gate.New(w.deps)
|
||||
_ = w.g.Unserved("shell", "src2:1", []string{"wipe", "tidy"})
|
||||
}
|
||||
|
||||
// bounds is the runner's key-ttl state bound as a fixture: expire hands a key's expiry to the watch.
|
||||
@@ -72,7 +83,11 @@ func newWorld() *world {
|
||||
newest: map[string]catalogseat.CatalogEntry{"shell": shell},
|
||||
defs: map[string]seatdef.Definition{"node-login-shell": {Seat: "node-login-shell",
|
||||
Verbs: []seatdef.Verb{{Name: "execute", NeedsApproval: true}}}}}}
|
||||
w.g = New(Deps{Node: "n1", Runner: "node-tools", Catalog: w.cat, State: w.state, Findings: w.findings, Bounds: w.bounds,
|
||||
w.deps = gate.Deps{Node: "n1", Runner: "node-tools", Catalog: w.cat, State: w.state, Bounds: w.bounds,
|
||||
Findings: Findings(w.findings, "n1", "node-tools", func() time.Time { return w.now }),
|
||||
Channel: &operatorchannelclient.GateChannel{State: w.state, KeyPrefix: "n1.", Now: func() time.Time { return w.now },
|
||||
Publish: func(module, subject string, body any, id string) error { return w.publish(module, subject, body, id) },
|
||||
ReadRecord: func(module, id string) (*stdio.StateEntry, error) { return w.record(module, id) }},
|
||||
Go: func(f func()) { f() },
|
||||
Holder: HoldersIn(func() (map[string][]byte, error) { return w.holders, w.holdersErr }),
|
||||
Warranted: func(asker, ask string, open func() (bool, error)) error {
|
||||
@@ -91,27 +106,28 @@ func newWorld() *world {
|
||||
c <- w.now
|
||||
return c
|
||||
},
|
||||
Publish: func(module, subject string, body any, id string) error {
|
||||
if subject != seat.AcceptSubjectAsk(module) {
|
||||
return nil
|
||||
}
|
||||
a := body.(seat.Ask)
|
||||
w.asked = append(w.asked, a)
|
||||
if w.takes {
|
||||
w.records[module+"."+a.ID] = seat.AsksByAskerIDValue{Asker: module, Key: module + "." + a.ID, State: "open",
|
||||
Headline: a.Headline, Expires: a.Expires, Opened: operatorchannelclient.FormatTime(w.now), OfferedOn: []string{"telegram"}}
|
||||
}
|
||||
}
|
||||
w.publish = func(module, subject string, body any, id string) error {
|
||||
if subject != seat.AcceptSubjectAsk(module) {
|
||||
return nil
|
||||
},
|
||||
Record: func(module, id string) (*stdio.StateEntry, error) {
|
||||
rec, ok := w.records[module+"."+id]
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
raw, _ := json.Marshal(rec)
|
||||
return &stdio.StateEntry{Key: module + "." + id, Value: raw}, nil
|
||||
}})
|
||||
_ = w.g.Unserved("shell", "src2:1", []string{"wipe", "tidy"})
|
||||
}
|
||||
a := body.(seat.Ask)
|
||||
w.asked = append(w.asked, a)
|
||||
if w.takes {
|
||||
w.records[module+"."+a.ID] = seat.AsksByAskerIDValue{Asker: module, Key: module + "." + a.ID, State: "open",
|
||||
Headline: a.Headline, Expires: a.Expires, Opened: operatorchannelclient.FormatTime(w.now), OfferedOn: []string{"telegram"}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
w.record = func(module, id string) (*stdio.StateEntry, error) {
|
||||
rec, ok := w.records[module+"."+id]
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
raw, _ := json.Marshal(rec)
|
||||
return &stdio.StateEntry{Key: module + "." + id, Value: raw}, nil
|
||||
}
|
||||
w.rebuild()
|
||||
return w
|
||||
}
|
||||
|
||||
@@ -129,102 +145,38 @@ func (w *world) decide(option string, at time.Time) seat.Ask {
|
||||
}
|
||||
|
||||
// do makes a call through the gate, counting the runs.
|
||||
func (w *world) do(c Call) (any, error) {
|
||||
func (w *world) do(c gate.Call) (any, error) {
|
||||
return w.g.Run(c, func() (any, error) { w.runs++; return "done", nil })
|
||||
}
|
||||
|
||||
// call is a fixture call of the marked tool wipe, or of another tool of the module.
|
||||
func call(name, args string) Call {
|
||||
return Call{Address: "shell." + name, Module: "shell", Name: name, Fingerprint: "src2:1", Caller: "agent", Args: json.RawMessage(args),
|
||||
func call(name, args string) gate.Call {
|
||||
return gate.Call{Address: "shell." + name, Module: "shell", Name: name, Fingerprint: "src2:1", Caller: "agent", Args: json.RawMessage(args),
|
||||
Description: "Wipes a scratch directory.\nMore words."}
|
||||
}
|
||||
|
||||
// theActAndItsAsk is §8's and §11's rows: the act's fields, and how an ask shows a call's arguments.
|
||||
func theActAndItsAsk(t *testing.T) {
|
||||
base := call("wipe", `{"dir":"scratch","n":1}`)
|
||||
digest := func(c Call) string {
|
||||
act, err := ActOf(c, "n1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d, _ := operatorchannelclient.ActDigest(act)
|
||||
return d
|
||||
}
|
||||
act, _ := ActOf(base, "n1")
|
||||
want := operatorchannelclient.Act{"address": "shell.wipe", "node": "n1", "module": "shell", "tool": "wipe", "build": "src2:1",
|
||||
"arg.dir": "scratch", "arg.n": "1"}
|
||||
if len(act) != len(want) {
|
||||
t.Fatalf("act %v", act)
|
||||
}
|
||||
for k, v := range want {
|
||||
if act[k] != v {
|
||||
t.Errorf("act[%s] = %q, want %q", k, act[k], v)
|
||||
}
|
||||
}
|
||||
seen := map[string]string{digest(base): "the call"}
|
||||
for name, c := range map[string]Call{
|
||||
"an omitted argument": call("wipe", `{"dir":"scratch"}`),
|
||||
"another number": call("wipe", `{"dir":"scratch","n":2}`),
|
||||
"an object": call("wipe", `{"dir":{"name":"scratch"},"n":1}`),
|
||||
"a changed build": func() Call { c := base; c.Fingerprint = "src2:2"; return c }(),
|
||||
"another node's seat": {Address: "node-login-shell.execute", Module: "shell", Seat: "node-login-shell", Name: "execute", Fingerprint: "src2:1"},
|
||||
} {
|
||||
d := digest(c)
|
||||
if other, dup := seen[d]; dup {
|
||||
t.Errorf("%s gives the digest of %s", name, other)
|
||||
}
|
||||
seen[d] = name
|
||||
}
|
||||
if got, _ := Canonical(json.RawMessage(`{"b":[1.0,2.5e-7,1e21],"a":"é<"}`)); got != `{"a":"é<","b":[1,2.5e-7,1e+21]}` {
|
||||
t.Errorf("canonical form %s", got)
|
||||
}
|
||||
// §11: a path, an address and a long argument are shown in their shape and cut.
|
||||
text, whole := shown(json.RawMessage(`{"dir":"/home/someone/scratch","host":"10.0.0.7","ok":"yes"}`))
|
||||
if whole || text != "dir: ‹path›\nhost: ‹address›\nok: yes" {
|
||||
t.Errorf("shown %q whole %v", text, whole)
|
||||
}
|
||||
long, _ := json.Marshal(map[string]string{"text": strings.Repeat("word ", 500)})
|
||||
if text, whole := shown(long); whole || !strings.HasSuffix(text, "NOT SHOWN IN FULL") || len(text) > PartBytes+len("\nNOT SHOWN IN FULL") {
|
||||
t.Errorf("a long argument shown whole %v, %d bytes", whole, len(text))
|
||||
}
|
||||
// §10: the headline, cut with … to 60 characters, ending Part shown.
|
||||
for _, tc := range []struct{ name, node, want string }{
|
||||
{"wipe", "n1", "Run wipe on n1?"},
|
||||
{strings.Repeat("x", 50), "n1", "Run " + strings.Repeat("x", 50) + "?"},
|
||||
{strings.Repeat("y", 80), "n1", "Run " + strings.Repeat("y", 54) + "…?"},
|
||||
} {
|
||||
if got := headlineOf("Run", tc.name, tc.node, true); got != tc.want || len([]rune(got)) > 60 {
|
||||
t.Errorf("headline %q, want %q", got, tc.want)
|
||||
}
|
||||
}
|
||||
if got := headlineOf("Run", "wipe", "n1", false); got != "Run wipe on n1? Part shown" {
|
||||
t.Errorf("headline %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Design 46 7-approval-mark §22: the refusals and answers of a marked call, on the fixture mesh, the router's record and
|
||||
// the warrant written as the router writes them.
|
||||
func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
t.Run("§8, §10, §11: the act's fields give each its digest, and the ask shows the arguments", theActAndItsAsk)
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
run func(t *testing.T, w *world)
|
||||
}{
|
||||
{"§9: a secret in the arguments is refused asking nothing", func(t *testing.T, w *world) {
|
||||
_, err := w.g.firstCall(call("wipe", `{"token":"ghp_0123456789abcdefghijABCDEFGHIJ012345"}`))
|
||||
_, err := w.do(call("wipe", `{"token":"ghp_0123456789abcdefghijABCDEFGHIJ012345"}`))
|
||||
if err == nil || !strings.Contains(err.Error(), "which no ask may carry") || len(w.asked) != 0 {
|
||||
t.Fatalf("%v, asked %d", err, len(w.asked))
|
||||
}
|
||||
}},
|
||||
{"§9: more than 16 KiB of arguments is refused asking nothing", func(t *testing.T, w *world) {
|
||||
big, _ := json.Marshal(map[string]string{"text": strings.Repeat("a b ", 5000)})
|
||||
_, err := w.g.firstCall(call("wipe", string(big)))
|
||||
_, err := w.do(call("wipe", string(big)))
|
||||
if err == nil || !strings.Contains(err.Error(), "more than the 16384") || len(w.asked) != 0 {
|
||||
t.Fatalf("%v, asked %d", err, len(w.asked))
|
||||
}
|
||||
}},
|
||||
{"§10, §12: the published ask's fields, and Not run with the router's record", func(t *testing.T, w *world) {
|
||||
_, err := w.g.firstCall(call("wipe", `{"dir":"scratch"}`))
|
||||
_, err := w.do(call("wipe", `{"dir":"scratch"}`))
|
||||
if err == nil || !strings.HasPrefix(err.Error(), "Not run: this needs the operator's approval. Asked on telegram at ") ||
|
||||
!strings.Contains(err.Error(), "make the same call again within 30 minutes of the approval; the ask expires at ") {
|
||||
t.Fatalf("answer %v", err)
|
||||
@@ -233,9 +185,9 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
t.Fatalf("asked %d", len(w.asked))
|
||||
}
|
||||
a := w.asked[0]
|
||||
act, _ := ActOf(call("wipe", `{"dir":"scratch"}`), "n1")
|
||||
act, _ := gate.ActOf(call("wipe", `{"dir":"scratch"}`), "n1")
|
||||
d, _ := operatorchannelclient.ActDigest(act)
|
||||
if a.About != d || a.Who != "operator" || a.OnExpiry != OnExpiry || a.Headline != "Run wipe on n1?" ||
|
||||
if a.About != d || a.Who != "operator" || a.OnExpiry != gate.OnExpiry || a.Headline != "Run wipe on n1?" ||
|
||||
a.Expires != operatorchannelclient.FormatTime(time.Date(2026, 11, 12, 11, 0, 0, 0, time.UTC)) || len(a.Options) != 2 ||
|
||||
a.Options[0].ID != "approve" || a.Options[1].ID != "decline" || a.Options[0].Binds != d || a.Options[1].Binds != d ||
|
||||
a.Options[1].Level != "approve" {
|
||||
@@ -253,8 +205,8 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
{"§12: with no record within 5 seconds, Not run, asked; not yet taken by the router", func(t *testing.T, w *world) {
|
||||
w.takes = false
|
||||
start := w.now
|
||||
_, err := w.g.firstCall(call("wipe", `{}`))
|
||||
if err == nil || !strings.HasPrefix(err.Error(), "Not run, asked; not yet taken by the router (ask ") || w.now.Sub(start) > RecordWithin {
|
||||
_, err := w.do(call("wipe", `{}`))
|
||||
if err == nil || !strings.HasPrefix(err.Error(), "Not run, asked; not yet taken by the router (ask ") || w.now.Sub(start) > gate.RecordWithin {
|
||||
t.Fatalf("answer %v after %s", err, w.now.Sub(start))
|
||||
}
|
||||
}},
|
||||
@@ -277,10 +229,10 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}},
|
||||
{"§14, §15: approved, the same call runs once; made again it is already run and asks anew", func(t *testing.T, w *world) {
|
||||
_, _ = w.do(call("wipe", `{"dir":"scratch"}`))
|
||||
w.decide(OptionApprove, w.now.Add(time.Minute))
|
||||
w.decide(gate.OptionApprove, w.now.Add(time.Minute))
|
||||
w.now = w.now.Add(2 * time.Minute)
|
||||
if got, err := w.do(call("wipe", `{"dir":"scratch"}`)); err != nil || got.(Answered).Answer != "done" || w.runs != 1 ||
|
||||
!strings.HasPrefix(got.(Answered).Approval, "run on the operator's approval via telegram at 2026-11-12T10:01:00Z, ask ") {
|
||||
if got, err := w.do(call("wipe", `{"dir":"scratch"}`)); err != nil || got.(gate.Answered).Answer != "done" || w.runs != 1 ||
|
||||
!strings.HasPrefix(got.(gate.Answered).Approval, "run on the operator's approval via telegram at 2026-11-12T10:01:00Z, ask ") {
|
||||
t.Fatalf("%v %v, runs %d", got, err, w.runs)
|
||||
}
|
||||
_, err := w.do(call("wipe", `{"dir":"scratch"}`))
|
||||
@@ -290,7 +242,7 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}},
|
||||
{"§15: two calls at the same moment run it once", func(t *testing.T, w *world) {
|
||||
_, _ = w.do(call("wipe", `{}`))
|
||||
w.decide(OptionApprove, w.now)
|
||||
w.decide(gate.OptionApprove, w.now)
|
||||
var wg sync.WaitGroup
|
||||
var mu sync.Mutex
|
||||
runs := 0
|
||||
@@ -308,9 +260,9 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}},
|
||||
{"§14: approved for other arguments runs nothing", func(t *testing.T, w *world) {
|
||||
_, _ = w.do(call("wipe", `{"dir":"scratch"}`))
|
||||
a := w.decide(OptionApprove, w.now)
|
||||
a := w.decide(gate.OptionApprove, w.now)
|
||||
rec := w.records["shell."+a.ID]
|
||||
other, _ := ActOf(call("wipe", `{"dir":"home"}`), "n1")
|
||||
other, _ := gate.ActOf(call("wipe", `{"dir":"home"}`), "n1")
|
||||
d, _ := operatorchannelclient.ActDigest(other)
|
||||
a.Options[0].Binds = d // the ask the person was shown bound another act
|
||||
rec.Warrant.AskDigest = operatorchannelclient.Digest(a)
|
||||
@@ -326,7 +278,7 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}},
|
||||
{"§14: approved 31 minutes ago asks anew", func(t *testing.T, w *world) {
|
||||
_, _ = w.do(call("wipe", `{}`))
|
||||
w.decide(OptionApprove, w.now)
|
||||
w.decide(gate.OptionApprove, w.now)
|
||||
w.now = w.now.Add(31 * time.Minute)
|
||||
if _, err := w.do(call("wipe", `{}`)); err == nil || !strings.Contains(err.Error(), "approved too long ago") || w.runs != 0 || len(w.asked) != 2 {
|
||||
t.Fatalf("%v, runs %d, asked %d", err, w.runs, len(w.asked))
|
||||
@@ -334,7 +286,7 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}},
|
||||
{"§14, §17: declined, the same call is not asked again for 10 minutes", func(t *testing.T, w *world) {
|
||||
_, _ = w.do(call("wipe", `{}`))
|
||||
w.decide(OptionDecline, w.now)
|
||||
w.decide(gate.OptionDecline, w.now)
|
||||
w.now = w.now.Add(9 * time.Minute)
|
||||
if _, err := w.do(call("wipe", `{}`)); err == nil || !strings.Contains(err.Error(), "declined") || len(w.asked) != 1 || w.runs != 0 {
|
||||
t.Fatalf("%v, asked %d", err, len(w.asked))
|
||||
@@ -356,7 +308,7 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}},
|
||||
{"§14: another asker's warrant runs nothing", func(t *testing.T, w *world) {
|
||||
_, _ = w.do(call("wipe", `{}`))
|
||||
a := w.decide(OptionApprove, w.now)
|
||||
a := w.decide(gate.OptionApprove, w.now)
|
||||
rec := w.records["shell."+a.ID]
|
||||
rec.Warrant.Asker = "mail"
|
||||
w.records["shell."+a.ID] = rec
|
||||
@@ -382,7 +334,8 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}
|
||||
}},
|
||||
{"§13: with no binding, an unmarked call runs and a marked one is refused", func(t *testing.T, w *world) {
|
||||
w.g.d.State = nil
|
||||
w.deps.State = nil
|
||||
w.rebuild()
|
||||
if got, err := w.do(call("tidy", `{}`)); err != nil || got != "done" {
|
||||
t.Fatalf("unmarked: %v %v", got, err)
|
||||
}
|
||||
@@ -410,37 +363,38 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}
|
||||
}},
|
||||
{"§3, §2: a seat verb its seat marks is asked for its holder", func(t *testing.T, w *world) {
|
||||
c := Call{Address: "node-login-shell.execute", Module: "shell", Seat: "node-login-shell", Name: "execute", Fingerprint: "src2:1", Args: json.RawMessage(`{"command":"ls"}`)}
|
||||
c := gate.Call{Address: "node-login-shell.execute", Module: "shell", Seat: "node-login-shell", Name: "execute", Fingerprint: "src2:1", Args: json.RawMessage(`{"command":"ls"}`)}
|
||||
if _, err := w.do(c); err == nil || !strings.HasPrefix(err.Error(), "Not run") || len(w.asked) != 1 || w.asked[0].Headline != "Run node-login-shell.execute on n1?" {
|
||||
t.Fatalf("%v, asked %d", err, len(w.asked))
|
||||
}
|
||||
}},
|
||||
{"§16: the run is recorded once; unanswered within five minutes it is a finding, cleared when warranted answers", func(t *testing.T, w *world) {
|
||||
_, _ = w.do(call("wipe", `{}`))
|
||||
a := w.decide(OptionApprove, w.now)
|
||||
a := w.decide(gate.OptionApprove, w.now)
|
||||
stop, _ := w.g.WatchBounds()
|
||||
defer stop()
|
||||
w.warranted = errors.New("no responders")
|
||||
if _, err := w.do(call("wipe", `{}`)); err != nil || w.runs != 1 || len(w.recorded) != 0 {
|
||||
t.Fatalf("%v, runs %d, recorded %v", err, w.runs, w.recorded)
|
||||
}
|
||||
if w.bounds.keys["n1.unanswered."+a.ID] != UnansweredAfter || w.bounds.keys["n1.unrecorded."+a.ID] != KeptFor-SaidBefore {
|
||||
if w.bounds.keys["n1.unanswered."+a.ID] != gate.UnansweredAfter || w.bounds.keys["n1.unrecorded."+a.ID] != gate.KeptFor-gate.SaidBefore {
|
||||
t.Fatalf("bounds %v", w.bounds.keys)
|
||||
}
|
||||
w.bounds.expire("n1.unanswered." + a.ID)
|
||||
if w.findings.raised[keys.EscapeName("n1."+a.ID)] != KindCallUnanswered {
|
||||
if w.findings.raised[keys.EscapeName("n1."+a.ID)] != gate.KindCallUnanswered {
|
||||
t.Fatalf("findings %v", w.findings.raised)
|
||||
}
|
||||
w.warranted = nil
|
||||
// At a start each acted, unrecorded ask is pending in the runner's findings-stated until warranted is made again
|
||||
// (design 47 G §384).
|
||||
pendingKey := views.FindingKey("machine", keys.EscapeName("n1."+a.ID), KindCallUnanswered)
|
||||
warranted := w.g.d.Warranted
|
||||
pendingKey := views.FindingKey("machine", keys.EscapeName("n1."+a.ID), gate.KindCallUnanswered)
|
||||
warranted := w.deps.Warranted
|
||||
var pendingAtCall bool
|
||||
w.g.d.Warranted = func(asker, ask string, open func() (bool, error)) error {
|
||||
w.deps.Warranted = func(asker, ask string, open func() (bool, error)) error {
|
||||
_, pendingAtCall = w.findings.pends[pendingKey]
|
||||
return warranted(asker, ask, open)
|
||||
}
|
||||
w.rebuild() // a start
|
||||
w.g.Recover() // a start, or the hand-act seat's holder heard again
|
||||
w.g.Recover()
|
||||
if !pendingAtCall || len(w.findings.pended) != 1 || len(w.findings.pends) != 0 || w.findings.pended[0] != pendingKey {
|
||||
@@ -466,15 +420,15 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
}
|
||||
}},
|
||||
{"§19: a publish that fails and a record that cannot be read refuse, running nothing", func(t *testing.T, w *world) {
|
||||
pub := w.g.d.Publish
|
||||
w.g.d.Publish = func(string, string, any, string) error { return errors.New("the bus refused it") }
|
||||
pub := w.publish
|
||||
w.publish = func(string, string, any, string) error { return errors.New("the bus refused it") }
|
||||
if _, err := w.do(call("wipe", `{}`)); err == nil || !strings.Contains(err.Error(), "the ask could not be raised") {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
w.g.d.Publish = pub
|
||||
w.publish = pub
|
||||
w.state.Vals = map[string]json.RawMessage{}
|
||||
_, _ = w.do(call("wipe", `{}`))
|
||||
w.g.d.Record = func(string, string) (*stdio.StateEntry, error) { return nil, errors.New("timeout") }
|
||||
w.record = func(string, string) (*stdio.StateEntry, error) { return nil, errors.New("timeout") }
|
||||
if _, err := w.do(call("wipe", `{}`)); err == nil || !strings.Contains(err.Error(), "the router's record of its ask") || w.runs != 0 {
|
||||
t.Fatalf("%v, runs %d", err, w.runs)
|
||||
}
|
||||
@@ -489,11 +443,13 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
{"§19: the marks unread, a call waits within 5 seconds and is refused naming mesh_first_views", func(t *testing.T, w *world) {
|
||||
w.cat.ready = errors.New("the catalog half has no first view of main yet")
|
||||
waited := time.Duration(0)
|
||||
w.g.d.Wait = func(d time.Duration) error { waited = d; return w.cat.ready }
|
||||
if _, err := w.do(call("tidy", `{}`)); err == nil || !strings.Contains(err.Error(), "mesh_first_views") || waited != RecordWithin || w.runs != 0 {
|
||||
w.deps.Wait = func(d time.Duration) error { waited = d; return w.cat.ready }
|
||||
w.rebuild()
|
||||
if _, err := w.do(call("tidy", `{}`)); err == nil || !strings.Contains(err.Error(), "mesh_first_views") || waited != gate.RecordWithin || w.runs != 0 {
|
||||
t.Fatalf("%v, waited %s", err, waited)
|
||||
}
|
||||
w.g.d.Wait = func(time.Duration) error { w.cat.ready = nil; return nil }
|
||||
w.deps.Wait = func(time.Duration) error { w.cat.ready = nil; return nil }
|
||||
w.rebuild()
|
||||
if _, err := w.do(call("tidy", `{}`)); err != nil || w.runs != 1 {
|
||||
t.Fatalf("read within the wait: %v, runs %d", err, w.runs)
|
||||
}
|
||||
@@ -505,11 +461,11 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
if _, err := w.do(call("wipe", `{}`)); err == nil || !strings.Contains(err.Error(), "cannot be read") {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
if w.bounds.keys["n1.unreadable.approvals"] != UnreadableAfter || len(w.findings.raised) != 0 {
|
||||
if w.bounds.keys["n1.unreadable.approvals"] != gate.UnreadableAfter || len(w.findings.raised) != 0 {
|
||||
t.Fatalf("bounds %v, findings %v", w.bounds.keys, w.findings.raised)
|
||||
}
|
||||
w.bounds.expire("n1.unreadable.approvals")
|
||||
if w.findings.raised[keys.EscapeName("n1.approvals")] != KindApprovalsUnreadable {
|
||||
if w.findings.raised[keys.EscapeName("n1.approvals")] != gate.KindApprovalsUnreadable {
|
||||
t.Fatalf("findings %v", w.findings.raised)
|
||||
}
|
||||
w.state.Fail = nil
|
||||
@@ -542,7 +498,7 @@ func TestTheRefusalsAndAnswers(t *testing.T) {
|
||||
t.Error("an ask not run was asked its hand-act again")
|
||||
}
|
||||
cancelled := ""
|
||||
w.g.d.Publish = func(module, subject string, body any, id string) error { cancelled = subject + " " + id; return nil }
|
||||
w.publish = func(module, subject string, body any, id string) error { cancelled = subject + " " + id; return nil }
|
||||
if err := w.g.Cancel(list[0].Ask); err != nil || cancelled != "mesh.seat.operator-channel.accept.cancel.shell cancel."+list[0].Ask {
|
||||
t.Fatalf("cancel %v %q", err, cancelled)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user