Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dda3bfd5b7 | |||
| b5b0ec77ba | |||
| c11e40b48a |
+8
-1
@@ -16,8 +16,11 @@ func TestAuthManager(t *testing.T) {
|
||||
p, envoy := newMockEnvoy(t, WithEmbassyObserver(obs))
|
||||
|
||||
signed := []byte(`{"kind":22242}`)
|
||||
var mu sync.Mutex
|
||||
var calledWith string
|
||||
callback := func(challenge string) ([]byte, error) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
calledWith = challenge
|
||||
return signed, nil
|
||||
}
|
||||
@@ -28,7 +31,11 @@ func TestAuthManager(t *testing.T) {
|
||||
p.connect()
|
||||
p.receive([]byte(envelope.EncloseAuthChallenge("abc")))
|
||||
|
||||
Eventually(t, func() bool { return calledWith == "abc" },
|
||||
Eventually(t, func() bool {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return calledWith == "abc"
|
||||
},
|
||||
"callback not called with challenge")
|
||||
|
||||
Eventually(t, func() bool {
|
||||
|
||||
@@ -3,9 +3,9 @@ module git.wisehodl.dev/jay/go-mana-prism
|
||||
go 1.25.0
|
||||
|
||||
require (
|
||||
git.wisehodl.dev/jay/go-honeybee v0.5.0
|
||||
git.wisehodl.dev/jay/go-mana-component v0.1.0
|
||||
git.wisehodl.dev/jay/go-roots-ws v0.1.0
|
||||
git.wisehodl.dev/jay/go-honeybee v0.5.1
|
||||
git.wisehodl.dev/jay/go-mana-component v0.2.0
|
||||
git.wisehodl.dev/jay/go-roots-ws v0.2.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
)
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
git.wisehodl.dev/jay/go-honeybee v0.5.0 h1:tAhXMLJnxMMhWJstA1f3OYVsdQf0rstl5/AaJVzuCWk=
|
||||
git.wisehodl.dev/jay/go-honeybee v0.5.0/go.mod h1:91H66sH5t1BHERGMihybeL1CDMu6vJgGuxjkUxfaqi4=
|
||||
git.wisehodl.dev/jay/go-honeybee v0.5.1 h1:PuJeIOysCj8FV2GKfi2UL9xITOYJhkftFze8IdOuJZ0=
|
||||
git.wisehodl.dev/jay/go-honeybee v0.5.1/go.mod h1:lOz4/P3ultn/PgFz1JiaetxMXvff48GiLK0b+s1rvUc=
|
||||
git.wisehodl.dev/jay/go-mana-component v0.1.0 h1:wWYN5MzC9Hq3tEt4z7FjrwNuQz3rZY3RWAmgmNE8EZE=
|
||||
git.wisehodl.dev/jay/go-mana-component v0.1.0/go.mod h1:r2ZaTjKzwV5JJfC5boikxtjAKusPrzlJU/7qul0EUqA=
|
||||
git.wisehodl.dev/jay/go-mana-component v0.2.0 h1:uuk8YeFH/yQCtcpotkgQERDwFGY85/rNCUgk6hCGhW4=
|
||||
git.wisehodl.dev/jay/go-mana-component v0.2.0/go.mod h1:r2ZaTjKzwV5JJfC5boikxtjAKusPrzlJU/7qul0EUqA=
|
||||
git.wisehodl.dev/jay/go-roots-ws v0.1.0 h1:p1veCkpOmL26N//Qz7ekJOYj1Ck30ai4OKq9dxLjodk=
|
||||
git.wisehodl.dev/jay/go-roots-ws v0.1.0/go.mod h1:ANQOOP13lHs2uQwYhrSQGAlL7+zR6QvbLzNPmNBJssQ=
|
||||
git.wisehodl.dev/jay/go-roots-ws v0.2.0 h1:XzlrGu0//09SrTWWd6A8b/bGck2EZnJq2JOA+UJql28=
|
||||
git.wisehodl.dev/jay/go-roots-ws v0.2.0/go.mod h1:ANQOOP13lHs2uQwYhrSQGAlL7+zR6QvbLzNPmNBJssQ=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
|
||||
+2
-2
@@ -139,8 +139,6 @@ func (p *EventPublisher) Close() {
|
||||
p.wg.Wait()
|
||||
}
|
||||
|
||||
// trySend sends the EVENT envelope. It does not modify entry.sent — callers
|
||||
// are responsible for setting it under p.mu before and/or after this call.
|
||||
func (p *EventPublisher) trySend(entry *pendingEntry) error {
|
||||
entry.mu.Lock()
|
||||
defer entry.mu.Unlock()
|
||||
@@ -212,9 +210,11 @@ func (p *EventPublisher) handleEvents() {
|
||||
p.mu.Lock()
|
||||
var toSend []*pendingEntry
|
||||
for _, e := range p.pending {
|
||||
e.mu.Lock()
|
||||
if !e.sent {
|
||||
toSend = append(toSend, e)
|
||||
}
|
||||
e.mu.Unlock()
|
||||
}
|
||||
p.mu.Unlock()
|
||||
|
||||
|
||||
+3
-1
@@ -364,7 +364,9 @@ func TestEventPublisher(t *testing.T) {
|
||||
}, "Publish did not return a send error")
|
||||
|
||||
assert.ErrorContains(t, err, "send failed")
|
||||
assert.Len(t, EventsOf[PublishSendFailed](obs), 1)
|
||||
|
||||
// on connect event handler may race with Publish()
|
||||
assert.GreaterOrEqual(t, len(EventsOf[PublishSendFailed](obs)), 1)
|
||||
})
|
||||
|
||||
t.Run("disconnect then send failure on reconnect", func(t *testing.T) {
|
||||
|
||||
+2
-4
@@ -333,15 +333,13 @@ func TestRequestManager_Stream(t *testing.T) {
|
||||
p.connect()
|
||||
Eventually(t, envoy.IsConnected, "envoy should be reconnected")
|
||||
|
||||
// prevent activate() race between Stream and on-connect handler
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
|
||||
filters := [][]byte{[]byte(`{}`)}
|
||||
id, _, _, err := m.Stream(filters)
|
||||
assert.NoError(t, err)
|
||||
|
||||
Eventually(t, func() bool {
|
||||
return len(EventsOf[ReqSendFailed](obs)) == 1
|
||||
// on connect event handler may race with Stream()
|
||||
return len(EventsOf[ReqSendFailed](obs)) >= 1
|
||||
}, "expected ReqSendFailed observable")
|
||||
failed := EventsOf[ReqSendFailed](obs)
|
||||
assert.Equal(t, id, failed[0].SubID)
|
||||
|
||||
Reference in New Issue
Block a user