use coder/websocket for everything, get rid of gobwas.

supposedly it is faster, and anyway it's better to use it since we're already using it for wasm/js.

(previously named nhooyr/websocket).
This commit is contained in:
fiatjaf
2025-01-03 01:15:12 -03:00
parent b33cfb19fa
commit defc349e57
9 changed files with 101 additions and 243 deletions

View File

@@ -12,40 +12,33 @@ import (
"github.com/stretchr/testify/require"
)
func TestConnectContext(t *testing.T) {
var testRelayURL = func() string {
url := os.Getenv("TEST_RELAY_URL")
if url == "" {
t.Fatal("please set the environment: $TEST_RELAY_URL")
if url != "" {
return url
}
return "wss://nos.lol"
}()
func TestConnectContext(t *testing.T) {
// relay client
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
r, err := RelayConnect(ctx, url)
r, err := RelayConnect(ctx, testRelayURL)
assert.NoError(t, err)
defer r.Close()
}
func TestConnectContextCanceled(t *testing.T) {
url := os.Getenv("TEST_RELAY_URL")
if url == "" {
t.Fatal("please set the environment: $TEST_RELAY_URL")
}
// relay client
ctx, cancel := context.WithCancel(context.Background())
cancel() // make ctx expired
_, err := RelayConnect(ctx, url)
_, err := RelayConnect(ctx, testRelayURL)
assert.ErrorIs(t, err, context.Canceled)
}
func TestPublish(t *testing.T) {
url := os.Getenv("TEST_RELAY_URL")
if url == "" {
t.Fatal("please set the environment: $TEST_RELAY_URL")
}
// test note to be sent over websocket
priv, pub := makeKeyPair(t)
textNote := Event{
@@ -59,7 +52,7 @@ func TestPublish(t *testing.T) {
assert.NoError(t, err)
// connect a client and send the text note
rl := mustRelayConnect(t, url)
rl := mustRelayConnect(t, testRelayURL)
err = rl.Publish(context.Background(), textNote)
assert.NoError(t, err)
}