surface honeybee.EventDialFailed through the prism event pipeline

This commit is contained in:
Jay
2026-06-04 17:46:47 -04:00
parent df0a968907
commit 69f9219819
7 changed files with 86 additions and 21 deletions
+56
View File
@@ -1,6 +1,7 @@
package prism
import (
"errors"
"git.wisehodl.dev/jay/go-honeybee"
"git.wisehodl.dev/jay/go-roots-ws"
"github.com/stretchr/testify/assert"
@@ -91,3 +92,58 @@ func TestEmbassy_Dispatch(t *testing.T) {
envoy = embassy.Call(p.url)
assert.Nil(t, envoy)
}
func TestEmbassy_DialFailed_Routing(t *testing.T) {
t.Run("routed to correct subscriber with Err set", func(t *testing.T) {
p, envoy := newMockEnvoy(t)
sub := envoy.SubscribeEvents()
dialErr := errors.New("connection refused")
p.dialFail(dialErr)
var got PoolEvent
Eventually(t, func() bool {
select {
case ev := <-sub:
got = ev
return true
default:
return false
}
}, "expected EventDialFailed to be routed to subscriber")
assert.Equal(t, EventDialFailed, got.Kind)
assert.ErrorIs(t, got.Err, dialErr)
assert.Equal(t, p.url, got.ID)
})
t.Run("not routed to unrelated envoy subscriber", func(t *testing.T) {
p := newMockPool(t)
url1 := "wss://peer1"
url2 := "wss://peer2"
added := make(chan struct{}, 2)
p.plugin.Connect = func(url string, opts ...honeybee.ConnectOption) error {
added <- struct{}{}
return nil
}
emb := NewEmbassy(p.ctx, p.plugin)
emb.Dispatch(url1)
emb.Dispatch(url2)
envoy2 := emb.Call(url2)
sub2 := envoy2.SubscribeEvents()
p.dialFail(errors.New("refused"))
Never(t, func() bool {
select {
case <-sub2:
return true
default:
return false
}
}, "EventDialFailed for a different peer must not reach unrelated subscriber")
})
}