Skip to content

Commit

Permalink
ws: fix test #2 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-dionysos authored Dec 18, 2024
1 parent 71b13d7 commit 8d8478a
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions server/ws/subscriptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2566,45 +2566,19 @@ func TestRelayMultiEventsAndFilter(t *testing.T) {
require.NoError(t, err)
})

sub, err := relay.Subscribe(context.Background(), []model.Filter{
{
receivedEvents, err := relay.QuerySync(context.Background(),
model.Filter{
Kinds: []int{nostr.KindTextNote},
Tags: model.TagMap{}.
Set("e", model.PointerOf("bar"), nil, model.PointerOf("reply")),
},
})
})
require.NoError(t, err)

var wg sync.WaitGroup
var receivedEvents []*model.Event
{
t.Logf("subscribed to %v", sub.GetID())
wg.Add(1)
go func() {
defer wg.Done()
for ev := range sub.Events {
t.Logf("received event %v via sub", ev)
receivedEvents = append(receivedEvents, &model.Event{Event: *ev})
}
}()
}

select {
case <-sub.EndOfStoredEvents:
t.Logf("received EOS")

case <-time.After(5 * time.Second):
t.Fatalf("timeout waiting for EOS")
}

sub.Close()

// Want only one event that matches the filter.
require.Len(t, receivedEvents, 1)
require.Equal(t, generatedEvents[0], &receivedEvents[0].Event)
require.Equal(t, generatedEvents[0], receivedEvents[0])

helperMustCloseRelay(t, relay)
wg.Wait()
}

func TestCanForwardEvent(t *testing.T) {
Expand Down

0 comments on commit 8d8478a

Please sign in to comment.