Files
mesh-sdk/go/process/event_hub_test.go
T
jschoubben dda65f1cf2 S2 events-unheard: the hub says each pattern it does not hear, and the process reader raises the finding
OnUnheard is told the patterns not heard with stream and why (no stream carries it, not composed,
refused, registered after Start), the journal says each; the process reader raises events-unheard
(id module.node) from it and clears it on an empty list. A reader with no findings writer says
them in the journal alone. A late first adopt is among the unheard patterns.

Builds: design 47 H2b §836 4.; H-A-834, H-A-840, H-A-854
2026-11-27 03:00:35 +01:00

573 lines
22 KiB
Go

package process
import (
"context"
"errors"
"fmt"
stdio "git.novox.be/novox/mesh-sdk/go"
"slices"
"strings"
"sync"
"testing"
"time"
"github.com/nats-io/nats.go/jetstream"
)
func TestTheHubMatchesSubjectsAndRefusesOverlappingPatterns(t *testing.T) {
for _, c := range []struct {
a, b string
match, overlap bool
}{
{"mesh.mod.*.event.views.*", "mesh.mod.o.event.views.x", true, true},
{"mesh.mod.p.event.>", "mesh.mod.p.event", false, false},
{"mesh.mod.p.event.a", "mesh.mod.q.event.a", false, false},
{"mesh.mod.p.event.>", "mesh.mod.*.event.a", false, true},
{"mesh.mod.p.event.a", "mesh.mod.p.event.a.b", false, false},
} {
if got := subjectMatches(c.a, c.b); got != c.match && c.match {
t.Errorf("%s should match %s", c.a, c.b)
}
if got := subjectsOverlap(c.a, c.b); got != c.overlap {
t.Errorf("overlap(%s, %s) = %v", c.a, c.b, got)
}
}
t.Run("TheHubStartBindsEveryPatternAndSaysWhenAllAreHeard", subTheHubStartBindsEveryPatternAndSaysWhenAllAreHeard)
h := NewEventHub(nil)
nop := func(jetstream.Msg) {}
if err := h.Handle("mesh.mod.p.event.>", nop); err != nil {
t.Fatal(err)
}
if err := h.Handle("mesh.mod.*.event.a", nop); err == nil {
t.Fatal("an overlapping pattern was accepted")
}
if err := h.Handle("mesh.mod.q.event.>", nop); err != nil {
t.Fatal(err)
}
// H-A-169: a message no handler takes is acknowledged and told to each OnUnhandled hook, with its subject; one taken is not.
var told []string
h.OnUnhandled(func(subject string) { told = append(told, subject) })
taken, lost := &bindMsg{subject: "mesh.mod.q.event.x"}, &bindMsg{subject: "mesh.seat.s.event.nobody"}
h.hear(taken)
h.hear(lost)
if !lost.acked || len(told) != 1 || told[0] != "mesh.seat.s.event.nobody" {
t.Errorf("the unhandled message: acked %v, told %v", lost.acked, told)
}
// W1.12: a seat's event kept in a stream of its own is heard on one bus name and one durable, the maker's and the
// hearer's alike; an event kept last per subject is delivered from the last of each subject. The name is the
// contract's Stream<E> as it stands (seatdef.KeptStream), never made again here: a dotted or unprefixed name is
// refused by name before the bus is asked.
a := Account{Node: "ace", Module: "mesh-grants"}
for _, stream := range []string{"node-engine.running", "SEAT_node-engine.running", "SEAT_", "EVENTS"} {
if _, err := a.HearSeatEvents(context.Background(), nil, stream, func(jetstream.Msg) {}, nil); err == nil ||
!strings.Contains(err.Error(), "is not the bus's name of a seat event's stream") {
t.Errorf("hearing %q: %v", stream, err)
}
}
cfg := a.SeatEventConsumerConfig([]string{"mesh.seat.node-engine.event.running.>"}, true)
if cfg.Durable != "ace_mesh-grants" || cfg.DeliverPolicy != jetstream.DeliverLastPerSubjectPolicy ||
cfg.AckPolicy != jetstream.AckExplicitPolicy || len(cfg.FilterSubjects) != 1 {
t.Errorf("the durable on a stream kept last per subject: %+v", cfg)
}
if cfg := a.SeatEventConsumerConfig(nil, false); cfg.DeliverPolicy != jetstream.DeliverAllPolicy {
t.Errorf("the durable on a stream kept with an age starts from its first message, got %v", cfg.DeliverPolicy)
}
}
type pullConsumer struct {
jetstream.Consumer
info *jetstream.ConsumerInfo
handle jetstream.MessageHandler
options []jetstream.PullConsumeOpt
}
func (c *pullConsumer) CachedInfo() *jetstream.ConsumerInfo { return c.info }
func (c *pullConsumer) Consume(handle jetstream.MessageHandler, opts ...jetstream.PullConsumeOpt) (jetstream.ConsumeContext, error) {
c.handle, c.options = handle, opts
return &pullContext{closed: make(chan struct{})}, nil
}
type pullContext struct {
jetstream.ConsumeContext
closed chan struct{}
}
func (p *pullContext) Stop() { close(p.closed) }
func (p *pullContext) Closed() <-chan struct{} { return p.closed }
type slowMsg struct {
jetstream.Msg
said chan struct{}
}
func (m *slowMsg) InProgress() error { m.said <- struct{}{}; return nil }
// H-A-281: the hub pulls at most twenty messages per pull, and says in progress for a message whose handler runs past a
// third of the consumer's ack wait, at each third until it returns; a handler that returns first says nothing.
func TestTheHubPullsSmallBatchesAndKeepsSlowHandlersAlive(t *testing.T) {
cons := &pullConsumer{info: &jetstream.ConsumerInfo{Config: jetstream.ConsumerConfig{AckWait: 30 * time.Second}}}
ticks := make(chan time.Time)
var every time.Duration
stopped := 0
tick := func(d time.Duration) (<-chan time.Time, func()) { every = d; return ticks, func() { stopped++ } }
var handled func(jetstream.Msg)
cc, err := hearEvents(cons, "the test", func(m jetstream.Msg) { handled(m) }, t.Logf, tick)
if err != nil {
t.Fatal(err)
}
defer cc.Stop()
pulls := 0
for _, o := range cons.options {
if n, ok := o.(jetstream.PullMaxMessages); ok {
pulls = int(n)
}
}
if pulls != 20 {
t.Errorf("the hub pulls %d messages per pull, want 20 (0: the bus client's default of 500)", pulls)
}
slow := &slowMsg{said: make(chan struct{}, 4)}
handled = func(jetstream.Msg) {
for range 2 { // two thirds of the ack wait pass while the handler runs
select {
case ticks <- time.Time{}:
case <-time.After(5 * time.Second):
t.Error("no ticker runs while the handler runs")
return
}
select {
case <-slow.said:
case <-time.After(5 * time.Second):
t.Error("a handler running past a third of the ack wait said no in progress")
return
}
}
}
cons.handle(slow)
if every != 10*time.Second || stopped != 1 {
t.Errorf("in progress every %v (want 10s, a third of the ack wait), ticker stopped %d times (want 1)", every, stopped)
}
fast := &slowMsg{said: make(chan struct{}, 1)}
handled = func(jetstream.Msg) {}
cons.handle(fast)
if len(fast.said) != 0 {
t.Error("a handler that returned before a third of the ack wait said in progress")
}
}
// seqMsg is a message of the stream EVENTS at a sequence, counting what is said of it.
type seqMsg struct {
jetstream.Msg
subject string
seq uint64
mu sync.Mutex
progress int
acked bool
}
func (m *seqMsg) Subject() string { return m.subject }
func (m *seqMsg) Data() []byte { return nil }
func (m *seqMsg) Ack() error { m.mu.Lock(); m.acked = true; m.mu.Unlock(); return nil }
func (m *seqMsg) InProgress() error {
m.mu.Lock()
m.progress++
m.mu.Unlock()
return nil
}
func (m *seqMsg) Metadata() (*jetstream.MsgMetadata, error) {
return &jetstream.MsgMetadata{Stream: "EVENTS", Sequence: jetstream.SequencePair{Stream: m.seq}}, nil
}
func (m *seqMsg) said() int { m.mu.Lock(); defer m.mu.Unlock(); return m.progress }
// Design 47 H2 H-A-683 (1), H-A-695 (1) to (3): the hub hands events by key, one key's events one at a time in the order heard
// and different keys side by side, at most events-at-once keys at once; the patterns given no key share one key; every message
// held is said in progress at every third of its durable's ack wait by one ticker, with the handling of its key blocked past
// five ack waits, and handled once; a delivery again of a held sequence reaches no handler; holding events-waiting messages the
// hub takes no more and says so once; a setting not composed reads its default.
func TestTheHubHoldsEventsByKeyAndSaysThemInProgress(t *testing.T) {
events := make(chan string, 32)
gate := map[string]chan struct{}{"a1": make(chan struct{}), "b1": make(chan struct{})}
handler := func(m jetstream.Msg) {
name := m.Subject()[len("mesh.mod.m.event."):]
events <- "start " + name
if g := gate[name]; g != nil {
<-g
}
_ = m.Ack()
events <- "end " + name
}
lastToken := func(subject string, _ []byte) string { return subject[len(subject)-2 : len(subject)-1] }
var journal []string
var jmu sync.Mutex
logf := func(f string, a ...any) { jmu.Lock(); journal = append(journal, fmt.Sprintf(f, a...)); jmu.Unlock() }
newHub := func() (*EventHub, chan time.Time) {
h := NewEventHub(logf)
ticks := make(chan time.Time)
h.tick = func(time.Duration) (<-chan time.Time, func()) { return ticks, func() {} }
if err := h.HandleByKey("mesh.mod.m.event.>", lastToken, handler); err != nil {
t.Fatal(err)
}
if err := h.held.settle(); err != nil {
t.Fatal(err)
}
return h, ticks
}
next := func(want string) {
t.Helper()
select {
case got := <-events:
if got != want {
t.Fatalf("the hub did %q, want %q", got, want)
}
case <-time.After(5 * time.Second):
t.Fatalf("the hub did nothing, want %q", want)
}
}
msg := func(name string, seq uint64) *seqMsg { return &seqMsg{subject: "mesh.mod.m.event." + name, seq: seq} }
t.Run("a blocked key holds back no other key, its own events keep their order, every held message is said in progress", func(t *testing.T) {
h, ticks := newHub()
feed := h.newFeed()
feed.start(30 * time.Second)
first, second, other := msg("a1", 1), msg("a2", 2), msg("b1", 3)
for _, m := range []*seqMsg{first, second, other} {
h.hearOn(feed)(m)
}
started := []string{<-events, <-events}
if slices.Sort(started); strings.Join(started, ",") != "start a1,start b1" {
t.Fatalf("with one key's handler blocked another key's was not handled: %v", started)
}
// five ack waits pass: every held message, handled or waiting, is said in progress at each tick
for range 15 {
ticks <- time.Time{}
}
again := msg("a1", 1) // given again: handed to no handler
h.hearOn(feed)(again)
close(gate["b1"])
next("end b1")
close(gate["a1"])
next("end a1")
next("start a2")
next("end a2")
for _, m := range []*seqMsg{first, second, other} {
if m.said() < 14 {
t.Errorf("%s was said in progress %d times, want one at every tick", m.subject, m.said())
}
}
select {
case got := <-events:
t.Errorf("a delivery again reached a handler: %s", got)
default:
}
h.Stop()
})
t.Run("the patterns given no key share one, and events-at-once bounds the keys", func(t *testing.T) {
started := make(chan string, 8)
blockOn := func(release chan struct{}) func(jetstream.Msg) {
return func(m jetstream.Msg) { started <- m.Subject(); <-release }
}
release := make(chan struct{})
noOther := func(want string, why string) {
t.Helper()
select {
case got := <-started:
t.Fatalf("%s: %s", why, got)
case <-time.After(50 * time.Millisecond):
}
_ = want
}
shared := NewEventHub(logf)
for _, p := range []string{"x.>", "y.>"} {
if err := shared.Handle(p, blockOn(release)); err != nil {
t.Fatal(err)
}
}
go shared.hearOn(nil)(&seqMsg{subject: "x.1", seq: 1})
<-started
go shared.hearOn(nil)(&seqMsg{subject: "y.1", seq: 2})
noOther("", "two patterns given no key were handled side by side")
close(release)
<-started
t.Setenv(stdio.SettingWord(EventsAtOnceSetting), "1")
release2 := make(chan struct{})
one := NewEventHub(logf)
if err := one.HandleByKey("k.>", func(subject string, _ []byte) string { return subject }, blockOn(release2)); err != nil {
t.Fatal(err)
}
if err := one.held.settle(); err != nil {
t.Fatal(err)
}
go one.hearOn(nil)(&seqMsg{subject: "k.a", seq: 1})
<-started
go one.hearOn(nil)(&seqMsg{subject: "k.b", seq: 2})
noOther("", "a second key ran with events-at-once 1")
close(release2)
if got := <-started; got != "k.b" {
t.Fatalf("the waiting key ran %s", got)
}
})
t.Run("holding events-waiting messages it takes no more, said once; defaults when not composed", func(t *testing.T) {
h := NewEventHub(logf)
if err := h.held.settle(); err != nil || h.held.atOnce != 8 || h.held.bound != 100 {
t.Fatalf("defaults: %d at once, %d waiting (%v)", h.held.atOnce, h.held.bound, err)
}
t.Setenv(stdio.SettingWord(EventsWaitingSetting), "2")
release := make(chan struct{})
if err := h.Handle("w.>", func(m jetstream.Msg) { <-release }); err != nil {
t.Fatal(err)
}
if err := h.held.settle(); err != nil {
t.Fatal(err)
}
h.hearOn(nil)(&seqMsg{subject: "w.1", seq: 1})
taken := make(chan struct{})
go func() { h.hearOn(nil)(&seqMsg{subject: "w.2", seq: 2}); close(taken) }()
select {
case <-taken:
t.Fatal("the hub took a message past its bound")
case <-time.After(50 * time.Millisecond):
}
close(release)
select {
case <-taken:
case <-time.After(5 * time.Second):
t.Fatal("the hub took no message once room was made")
}
jmu.Lock()
said := 0
for _, l := range journal {
if strings.Contains(l, "its bound: it pulls no more") {
said++
}
}
jmu.Unlock()
if said != 1 {
t.Errorf("the bound was said %d times, want once", said)
}
t.Setenv(stdio.SettingWord(EventsWaitingSetting), "0")
if err := h.held.settle(); err == nil {
t.Error("a bound of 0 was accepted")
}
})
}
// Design 47 H2 H-A-683 (3), H-A-697 (3): a handling past event-overrun tells the hook once while it runs, naming its subject, key
// and since when, the oldest first, and once more when it ends with none past it; a handling past slow-event is said in the
// journal with its key and how long it took; a setting outside 1 second to 1 hour is refused naming it.
func TestAHandlingPastEventOverrunTellsItsHookWhileItRuns(t *testing.T) {
now := time.Date(2026, 11, 25, 12, 0, 0, 0, time.UTC)
var clock sync.Mutex
var lines []string
h := NewEventHub(func(f string, a ...any) { clock.Lock(); lines = append(lines, fmt.Sprintf(f, a...)); clock.Unlock() })
h.held.now = func() time.Time { clock.Lock(); defer clock.Unlock(); return now }
advance := func(d time.Duration) { clock.Lock(); now = now.Add(d); clock.Unlock() }
var fire []func()
h.held.after = func(d time.Duration, f func()) func() {
if d != 60*time.Second {
t.Errorf("the overrun is timed at %s, want the default 60s", d)
}
clock.Lock()
fire = append(fire, f)
clock.Unlock()
return func() {}
}
release := make(chan struct{})
entered := make(chan struct{}, 4)
if err := h.HandleByKey("mesh.mod.m.event.>", func(subject string, _ []byte) string { return subject[len("mesh.mod.m.event."):] },
func(jetstream.Msg) { entered <- struct{}{}; <-release }); err != nil {
t.Fatal(err)
}
var told [][]Handling
h.OnOverrun(func(past []Handling) { clock.Lock(); told = append(told, past); clock.Unlock() })
if err := h.held.settle(); err != nil {
t.Fatal(err)
}
h.hearOn(nil)(&seqMsg{subject: "mesh.mod.m.event.first", seq: 1})
<-entered
advance(time.Second)
h.hearOn(nil)(&seqMsg{subject: "mesh.mod.m.event.second", seq: 2})
<-entered
advance(59 * time.Second)
clock.Lock()
timers := fire
clock.Unlock()
for _, f := range timers {
f()
}
clock.Lock()
if len(told) != 2 || len(told[1]) != 2 || told[1][0].Subject != "mesh.mod.m.event.first" || told[1][0].Key != "first" ||
!told[1][0].Since.Equal(now.Add(-60*time.Second)) || told[1][1].Key != "second" {
t.Fatalf("the hook was told %+v", told)
}
clock.Unlock()
close(release)
deadline := time.After(5 * time.Second)
for {
clock.Lock()
n, last := len(told), []Handling(nil)
if n > 0 {
last = told[n-1]
}
clock.Unlock()
if n >= 4 && len(last) == 0 {
break
}
select {
case <-deadline:
t.Fatalf("the hook was told %d times, the last of %v", n, last)
case <-time.After(5 * time.Millisecond):
}
}
clock.Lock()
said := strings.Join(lines, "\n")
clock.Unlock()
if !strings.Contains(said, "the event mesh.mod.m.event.first (key first) took 1m0s to handle, over 100ms") {
t.Errorf("the journal says %q", said)
}
t.Setenv(stdio.SettingWord(EventOverrunSetting), "500ms")
if err := h.held.settle(); err == nil || !strings.Contains(err.Error(), EventOverrunSetting) {
t.Errorf("an overrun of 500ms was accepted: %v", err)
}
}
// Design 47 H2 H-A-737 (1): Handle keeps its earlier form, so a hub handed to a module's own interface (seatlist.ProcessBus's
// EventHandlers) is still one; holding by key is HandleByKey's.
var _ interface {
Handle(string, func(jetstream.Msg)) error
} = (*EventHub)(nil)
// fakeHubBus is the bus the hub's start asks of: which durables are composed, and the wakes it is given.
type fakeHubBus struct {
mu sync.Mutex
streams []string
subjects []string
composed map[string]error // a stream whose durable is composed has a nil entry; any other is not
binds []string
wakeAt string
onWake func()
reconn func()
stopped bool
}
func (b *fakeHubBus) streamNames(context.Context) ([]string, error) { return b.streams, nil }
func (b *fakeHubBus) streamSubjects(context.Context, string) ([]string, error) {
return b.subjects, nil
}
func (b *fakeHubBus) bind(stream string) (jetstream.ConsumeContext, time.Time, error) {
b.mu.Lock()
defer b.mu.Unlock()
err, ok := b.composed[stream]
if !ok {
return nil, time.Time{}, fmt.Errorf("no durable: %w", jetstream.ErrConsumerNotFound)
}
if err != nil {
return nil, time.Time{}, err
}
b.binds = append(b.binds, stream)
return &pullContext{closed: make(chan struct{})}, time.Date(2026, 1, 2, 3, 4, 5, 0, time.UTC), nil
}
func (b *fakeHubBus) hearEvents(_ context.Context, _ *eventFeed, _ func(jetstream.Msg), _ func(string, ...any)) (jetstream.ConsumeContext, time.Time, error) {
return b.bind(EventsStream)
}
func (b *fakeHubBus) hearKept(_ context.Context, stream string, _ *eventFeed, _ func(jetstream.Msg), _ func(string, ...any)) (jetstream.ConsumeContext, time.Time, error) {
return b.bind(stream)
}
func (b *fakeHubBus) wake(subject string, f func()) (func(), error) {
b.wakeAt, b.onWake = subject, f
return func() { b.stopped = true }, nil
}
func (b *fakeHubBus) reconnected(f func()) { b.reconn = f }
// Design 47 H2b §836 1., 2. (1984/AC-836a, AC-836b): Start alone binds a kept seat event's stream beside EVENTS and tells OnAllHeard
// once; a durable not composed at Start is bound when the grants part says it composed the module's durables, and again at a
// reconnect when its bind was refused, OnAllHeard told once each time the patterns are all heard, a bound stream never bound again.
func subTheHubStartBindsEveryPatternAndSaysWhenAllAreHeard(t *testing.T) {
kept := "SEAT_node-engine_running"
cred := Account{Node: "ace", Module: "teller"}
var unheardTold [][]Unheard // what OnUnheard was told, in order (1984/AC-836e)
newHub := func(bus *fakeHubBus) (h *EventHub, allHeard *int, created *[]time.Time) {
h, allHeard, created = NewEventHub(t.Logf), new(int), new([]time.Time)
unheardTold = nil
h.OnUnheard(func(list []Unheard) { unheardTold = append(unheardTold, list) })
h.OnAllHeard(func() { *allHeard++ })
h.OnBound(func(at time.Time) { *created = append(*created, at) })
if err := h.Handle("mesh.seat.node-engine.event.running.>", func(jetstream.Msg) {}); err != nil {
t.Fatal(err)
}
if err := h.Handle("mesh.mod.p.event.x", func(jetstream.Msg) {}); err != nil {
t.Fatal(err)
}
return h, allHeard, created
}
base := func(composed map[string]error) *fakeHubBus {
return &fakeHubBus{streams: []string{kept, "SEAT_other_thing", "EVENTS"}, subjects: []string{"mesh.mod.*.event.>"}, composed: composed}
}
t.Run("start alone", func(t *testing.T) {
bus := base(map[string]error{EventsStream: nil, kept: nil})
h, allHeard, created := newHub(bus)
if err := h.start(context.Background(), bus, cred); err != nil {
t.Fatal(err)
}
defer h.Stop()
if err := h.Handle("mesh.mod.late.event.y", func(jetstream.Msg) {}); err == nil || !strings.Contains(err.Error(), `"mesh.mod.late.event.y"`) {
t.Errorf("a handler registered after Start: %v", err) // 1984/AC-836d
}
if *allHeard != 1 || len(bus.binds) != 2 || len(*created) != 2 {
t.Errorf("all heard %d times, binds %v, bound told %d times", *allHeard, bus.binds, len(*created))
}
if bus.wakeAt != "mesh.seat.mesh-grants.event.durables-composed.ace.teller" {
t.Errorf("the wake is on %q", bus.wakeAt)
}
bus.onWake()
bus.reconn()
if len(unheardTold) != 2 || len(unheardTold[0]) != 0 || len(unheardTold[1]) != 1 {
t.Errorf("a start that binds everything tells an empty list once, a later wake and reconnect nothing, and the refused late pattern: %v", unheardTold)
}
if *allHeard != 1 || len(bus.binds) != 2 {
t.Errorf("a bound stream was told or bound again: %d, %v", *allHeard, bus.binds)
}
})
t.Run("composed late, refused then bound at a reconnect", func(t *testing.T) {
bus := base(map[string]error{EventsStream: nil})
h, allHeard, _ := newHub(bus)
h.start(context.Background(), bus, cred)
defer h.Stop()
if *allHeard != 0 || len(h.unheardNow) != 1 || h.unheardNow[0].Stream != kept || !strings.Contains(h.unheardNow[0].Why, "not composed") {
t.Fatalf("all heard %d, unheard %+v", *allHeard, h.unheardNow)
}
bus.composed[kept] = errors.New("the bus refuses")
bus.onWake()
if *allHeard != 0 || !strings.Contains(h.unheardNow[0].Why, "refused") {
t.Fatalf("a refused bind: all heard %d, unheard %+v", *allHeard, h.unheardNow)
}
bus.onWake() // the same reason again: nothing new to tell
bus.composed[kept] = nil
bus.reconn()
bus.onWake()
if *allHeard != 1 || len(h.unheardNow) != 0 || len(bus.binds) != 2 {
t.Errorf("all heard %d, unheard %+v, binds %v", *allHeard, h.unheardNow, bus.binds)
}
if len(unheardTold) != 3 || len(unheardTold[2]) != 0 || len(unheardTold[0]) != 1 || len(unheardTold[1]) != 1 ||
unheardTold[0][0] == unheardTold[1][0] {
t.Errorf("OnUnheard was told %v: the list at Start, its change, then empty once heard", unheardTold)
}
// 1984/AC-836s: a pattern registered after Start is refused and is among those not heard
if err := h.Handle("mesh.mod.p.event.late", func(jetstream.Msg) {}); err == nil {
t.Error("a handler after Start was accepted")
}
if n := len(unheardTold); n != 4 || len(unheardTold[3]) != 1 || unheardTold[3][0] != (Unheard{"mesh.mod.p.event.late", "", "registered after Start"}) {
t.Errorf("OnUnheard was told %v", unheardTold)
}
})
t.Run("no stream carries a pattern", func(t *testing.T) {
bus := base(map[string]error{EventsStream: nil, kept: nil})
bus.subjects = []string{"mesh.seat.*.event.>"}
h, allHeard, _ := newHub(bus)
h.start(context.Background(), bus, cred)
defer h.Stop()
if *allHeard != 0 || len(h.unheardNow) != 1 || h.unheardNow[0].Pattern != "mesh.mod.p.event.x" || h.unheardNow[0].Why != "no stream carries it" {
t.Errorf("all heard %d, unheard %+v", *allHeard, h.unheardNow)
}
})
}