mesh/merge-gate pass: builds mesh-tools, node-tools → ace, g14, novox, shanks; no bus step; every machine composes with the change as it did without (4 of …
mesh/repo-check pass: THE CHANGE ALTERS ITS OWN CHECK (merge-check.sh): main's version judged it; the change's judges the pull requests after it merges; it…
mesh/delivery delivered
callerOn reads a caller only under the call kind, so a tool subscription ending in a wildcard never yields one. A caller-named call that reached nobody is said once per subject before it is asked on the old subject, so a runtime or grant that drifted behind is seen rather than a quiet unproven. The caller tests wait for their bundle's exit, which reads the launcher's restart pauses another test sets.
73 lines
3.3 KiB
Go
73 lines
3.3 KiB
Go
package bus
|
|
|
|
import "testing"
|
|
|
|
// A call names its caller under the `call` kind, the caller's bus user its last token (novox/hq issue 365).
|
|
func TestACallerNamedSubjectIsTheToolsAddressUnderCallWithTheCallerLast(t *testing.T) {
|
|
for subject, want := range map[string]string{
|
|
"mesh.mod.ledger.tool.who": "mesh.mod.ledger.call.who.shanks~node-tools",
|
|
"mesh.mod.ledger.tool.who.anchor": "mesh.mod.ledger.call.who.anchor.shanks~node-tools",
|
|
"mesh.seat.issue-tracker.tool.open": "mesh.seat.issue-tracker.call.open.shanks~node-tools",
|
|
"mesh.seat.node-desk.tool.who.anchor": "mesh.seat.node-desk.call.who.anchor.shanks~node-tools",
|
|
"mesh.mod.ledger.event.opened": "",
|
|
"mesh.seat.intake.accept.ask.x": "",
|
|
"mesh.mod.ledger.tool.>": "",
|
|
"mesh.mod.*.tool.who": "mesh.mod.*.call.who.shanks~node-tools",
|
|
"mesh.node.anchor.ask.report": "",
|
|
"mesh.seat.operator-channel.proof.x.y": "",
|
|
} {
|
|
if subject == "mesh.mod.*.tool.who" {
|
|
continue // a wildcard is never asked on
|
|
}
|
|
if got := CalledSubject(subject, "shanks.node-tools"); got != want {
|
|
t.Errorf("%s → %q, want %q", subject, got, want)
|
|
}
|
|
}
|
|
for _, user := range []string{"", "a b", "x.*", "x.>", "a~b", "a..b"} {
|
|
if got := CalledSubject("mesh.mod.ledger.tool.who", user); got != "" {
|
|
t.Errorf("a caller %q that is not a bus user was named: %s", user, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The caller is read back from the subject a call arrived on, and only under the pattern that names one.
|
|
func TestTheCallerIsTheLastTokenOfTheSubjectTheCallArrivedOn(t *testing.T) {
|
|
pattern := calledPattern("mesh.mod.ledger.tool.who.anchor")
|
|
if pattern != "mesh.mod.ledger.call.who.anchor.*" {
|
|
t.Fatalf("pattern %q", pattern)
|
|
}
|
|
for subject, want := range map[string]string{
|
|
"mesh.mod.ledger.call.who.anchor.shanks~node-tools": "shanks.node-tools",
|
|
"mesh.mod.ledger.call.who.anchor.controller": "controller",
|
|
"mesh.mod.ledger.call.who.anchor.person~jochen": "person.jochen",
|
|
"mesh.mod.ledger.call.who.anchor.a~~b": "",
|
|
"mesh.mod.ledger.call.what.anchor.controller": "",
|
|
} {
|
|
if got := callerOn(pattern, subject); got != want {
|
|
t.Errorf("%s → %q, want %q", subject, got, want)
|
|
}
|
|
}
|
|
if got := callerOn("mesh.mod.ledger.tool.who.anchor", "mesh.mod.ledger.tool.who.anchor"); got != "" {
|
|
t.Errorf("a call on the subject that names no caller was handed %q", got)
|
|
}
|
|
for _, user := range []string{"controller", "shanks.node-tools", "person.jochen", "node.ace"} {
|
|
if back := UserOfToken(CallerToken(user)); back != user {
|
|
t.Errorf("%s → %s → %s", user, CallerToken(user), back)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Only a pattern of the `call` kind names a caller: a `tool` subscription with a wildcard last — a node seat's
|
|
// verb on any machine, say — never yields one, whatever token a call arrived with.
|
|
func TestAToolPatternNeverYieldsACaller(t *testing.T) {
|
|
for pattern, subject := range map[string]string{
|
|
"mesh.mod.ledger.tool.who.*": "mesh.mod.ledger.tool.who.controller",
|
|
"mesh.seat.node-desk.tool.who.*": "mesh.seat.node-desk.tool.who.shanks~node-tools",
|
|
"mesh.mod.ledger.event.*": "mesh.mod.ledger.event.controller",
|
|
} {
|
|
if got := callerOn(pattern, subject); got != "" {
|
|
t.Errorf("%s on %s yielded caller %q", pattern, subject, got)
|
|
}
|
|
}
|
|
}
|