mesh/delivery merged: source.main moved to novox/mesh-controller@c58b311ea774
mesh/delivery-group group feat/072-moves merged: every member is merged
mesh/check failed: shanks: the check of novox/mesh-controller#487 failed: go mod download in modules/route-proxy: go: git.novox.be/novox/mesh-controll…
The controller is being removed, so its root module goes back to origin/main's mesh-sdk pin (2da0de7) and
testdata/beside's capture; route-proxy keeps its own pins. Its one functional change stays the account issue:
- Before the grants part's take-over (its key user-list.sealed not saying FollowGrants) the bus loads the
controller's list, whose hashes come only from its store, so the controller mints as before and hands every
account it mints, covered or not, to an installed vault at once: no account waits on a node reporting its hash.
- From the take-over it forwards the issue to the vault's issue-account (d791052f) and mints nothing.
And the controller no longer declares or asserts the ASSIGNMENTS stream, which the bus module's tools delete at the
lease write and nothing may make again (research 072 row 33); the verified-sender re-issue stops once it is gone.
Research 072 piece: the gap "vault mints after the lease", the minting piece moves to the vault from the take-over.
86 lines
3.1 KiB
Go
86 lines
3.1 KiB
Go
//go:build integration
|
|
|
|
package broker
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/novox/mesh-controller/internal/testbus"
|
|
)
|
|
|
|
// On a real bus: a module's stream is made beside EVENTS without a clash, keeps what the module publishes on
|
|
// its own subjects, a granted consumer hears only its part, a narrowed grant narrows it, and a withdrawn one
|
|
// is removed (novox/hq ADR 0363).
|
|
//
|
|
// go test ./internal/broker/ -run TestAModuleStreamOnARealBus
|
|
func TestAModuleStreamOnARealBus(t *testing.T) {
|
|
js, err := Dial(testbus.URL(t))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer js.Close()
|
|
var events Stream
|
|
for _, s := range MeshStreams() {
|
|
if s.Name == EventsStream {
|
|
events = s
|
|
}
|
|
}
|
|
for _, s := range []Stream{events, mailStream.Stream()} {
|
|
_ = js.js.DeleteStream(s.Name)
|
|
if err := js.EnsureStream(s); err != nil {
|
|
t.Fatalf("%s: %v", s.Name, err)
|
|
}
|
|
defer func(name string) { _ = js.js.DeleteStream(name) }(s.Name)
|
|
}
|
|
for _, account := range []string{"mesh", "work"} {
|
|
if _, err := js.js.Publish(ModuleStreamSubject("mesh-mail", "mail."+account+".message.added"), []byte("{}")); err != nil {
|
|
t.Fatalf("publishing %s's mail: %v", account, err)
|
|
}
|
|
}
|
|
if info, _ := js.js.StreamInfo(EventsStream); info.State.Msgs != 0 {
|
|
t.Fatalf("EVENTS kept %d of the module stream's events", info.State.Msgs)
|
|
}
|
|
|
|
reader := Principal{Kind: KindModule, Node: "ace", Module: "reader", Hears: []Heard{mailHeard}}
|
|
c := heardConsumer(reader, mailHeard)
|
|
if err := js.EnsureConsumer(c); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// Made from now (novox/hq ADR 0443 §1): the two mails published above are its past, not its news.
|
|
time.Sleep(50 * time.Millisecond)
|
|
if info, _ := js.js.ConsumerInfo("MAIL", c.Name); info.NumPending != 0 {
|
|
t.Fatalf("the reader made after two mails has %d of them pending, want 0", info.NumPending)
|
|
}
|
|
for _, account := range []string{"mesh", "work"} {
|
|
if _, err := js.js.Publish(ModuleStreamSubject("mesh-mail", "mail."+account+".message.added"), []byte("{}")); err != nil {
|
|
t.Fatalf("publishing %s's mail: %v", account, err)
|
|
}
|
|
}
|
|
if got := pendingOf(js, "MAIL", c.Name, 1); got != 1 {
|
|
t.Fatalf("the reader granted `mesh` has %d pending, want 1", got)
|
|
}
|
|
narrowed := c
|
|
narrowed.Filters = []string{"mesh.stream.mesh-mail.event.mail.mesh.message.changed"}
|
|
if err := EnsureHeard(js, narrowed, true); err != nil {
|
|
t.Fatalf("narrowing the grant: %v", err)
|
|
}
|
|
if info, _ := js.js.ConsumerInfo("MAIL", c.Name); info.Config.FilterSubject != narrowed.Filters[0] || len(info.Config.FilterSubjects) != 0 {
|
|
t.Fatalf("narrowed to %q %v, want only %s", info.Config.FilterSubject, info.Config.FilterSubjects, narrowed.Filters[0])
|
|
}
|
|
if info, _ := js.js.ConsumerInfo("MAIL", c.Name); info.NumPending != 0 {
|
|
t.Fatalf("after narrowing, %d of the reader's former grant are still pending", info.NumPending)
|
|
}
|
|
removed, err := PruneHeard(js, []ModuleStream{mailStream}, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !slices.Equal(removed, []string{"MAIL/ace_reader"}) {
|
|
t.Fatalf("removed %v", removed)
|
|
}
|
|
if names, _ := js.ConsumerNames("MAIL"); len(names) != 0 {
|
|
t.Fatalf("still on MAIL: %v", names)
|
|
}
|
|
}
|