From a62ddd1326b1dfe56b9824052953866607703de7 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 20 Nov 2025 23:48:51 -0300 Subject: [PATCH] remove relay_js_test.go for now since we lost wasm support. --- relay_js_test.go | 76 ------------------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 relay_js_test.go diff --git a/relay_js_test.go b/relay_js_test.go deleted file mode 100644 index 7914aaa..0000000 --- a/relay_js_test.go +++ /dev/null @@ -1,76 +0,0 @@ -//go:build js - -package nostr - -import ( - "context" - "os" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var testRelayURL = func() string { - url := os.Getenv("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, testRelayURL, RelayOptions{}) - assert.NoError(t, err) - - defer r.Close() -} - -func TestConnectContextCanceled(t *testing.T) { - // relay client - ctx, cancel := context.WithCancel(context.Background()) - cancel() // make ctx expired - _, err := RelayConnect(ctx, testRelayURL, RelayOptions{}) - assert.ErrorIs(t, err, context.Canceled) -} - -func TestPublish(t *testing.T) { - // test note to be sent over websocket - priv, pub := makeKeyPair(t) - textNote := Event{ - Kind: KindTextNote, - Content: "hello", - CreatedAt: Timestamp(1672068534), // random fixed timestamp - Tags: Tags{[]string{"foo", "bar"}}, - PubKey: pub, - } - err := textNote.Sign(priv) - assert.NoError(t, err) - - // connect a client and send the text note - rl := mustRelayConnect(t, testRelayURL) - err = rl.Publish(context.Background(), textNote) - assert.NoError(t, err) -} - -func makeKeyPair(t *testing.T) (priv, pub [32]byte) { - t.Helper() - - privkey := Generate() - pubkey := GetPublicKey(privkey) - - return privkey, pubkey -} - -func mustRelayConnect(t *testing.T, url string) *Relay { - t.Helper() - - rl, err := RelayConnect(context.Background(), url, RelayOptions{}) - require.NoError(t, err) - - return rl -}