switch to gobwas/ws, add compression
This commit is contained in:
@@ -43,3 +43,44 @@ end:
|
||||
t.Errorf("expected 2 events, got %d", events)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubscribeEnableCompression(t *testing.T) {
|
||||
rl := &Relay{URL: NormalizeURL("wss://relay.damus.io"), EnableCompression: true}
|
||||
err := rl.Connect(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("connection failed: %v", err)
|
||||
}
|
||||
defer rl.Close()
|
||||
|
||||
sub, err := rl.Subscribe(context.Background(), Filters{{Kinds: []int{1}, Limit: 2}})
|
||||
if err != nil {
|
||||
t.Errorf("subscription failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
timeout := time.After(5 * time.Second)
|
||||
events := 0
|
||||
|
||||
for {
|
||||
select {
|
||||
case event := <-sub.Events:
|
||||
if event == nil {
|
||||
t.Errorf("event is nil: %v", event)
|
||||
}
|
||||
events++
|
||||
case <-sub.EndOfStoredEvents:
|
||||
goto end
|
||||
case <-rl.ConnectionContext.Done():
|
||||
t.Errorf("connection closed: %v", rl.ConnectionContext.Err())
|
||||
goto end
|
||||
case <-timeout:
|
||||
t.Errorf("timeout")
|
||||
goto end
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if events != 2 {
|
||||
t.Errorf("expected 2 events, got %d", events)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user