From 8d869009b074efbe088acd31eb63d9320e1c28c6 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 10 Mar 2025 02:49:08 -0300 Subject: [PATCH] localhost and 127.0.0.1 are "virtual" relays, but not when running `go test` --- sdk/feeds.go | 4 ++-- sdk/utils.go | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk/feeds.go b/sdk/feeds.go index 0ec40a4..5333cd3 100644 --- a/sdk/feeds.go +++ b/sdk/feeds.go @@ -67,7 +67,7 @@ func (sys *System) StreamLiveFeed( } go func() { - sub := sys.Pool.SubMany(ctx, relays, nostr.Filters{filter}, nostr.WithLabel("livefeed")) + sub := sys.Pool.SubscribeMany(ctx, relays, filter, nostr.WithLabel("livefeed")) for evt := range sub { sys.StoreRelay.Publish(ctx, *evt.Event) if latest < evt.CreatedAt { @@ -153,7 +153,7 @@ func (sys *System) FetchFeedPage( fUntil := oldestTimestamp + 1 filter.Until = &fUntil filter.Since = nil - for ie := range sys.Pool.SubManyEose(ctx, relays, nostr.Filters{filter}, nostr.WithLabel("feedpage")) { + for ie := range sys.Pool.FetchMany(ctx, relays, filter, nostr.WithLabel("feedpage")) { sys.StoreRelay.Publish(ctx, *ie.Event) // we shouldn't need this check here, but against rogue relays we'll do it diff --git a/sdk/utils.go b/sdk/utils.go index 5bb72c2..34388ec 100644 --- a/sdk/utils.go +++ b/sdk/utils.go @@ -4,6 +4,7 @@ import ( "math" "strings" "sync" + "testing" "time" ) @@ -21,12 +22,16 @@ func IsVirtualRelay(url string) bool { if strings.HasPrefix(url, "wss://feeds.nostr.band") || strings.HasPrefix(url, "wss://filter.nostr.wine") || - strings.HasPrefix(url, "ws://localhost") || - strings.HasPrefix(url, "ws://127.0.0.1") || strings.HasPrefix(url, "wss://cache") { return true } + if !testing.Testing() && + strings.HasPrefix(url, "ws://localhost") || + strings.HasPrefix(url, "ws://127.0.0.1") { + return true + } + return false }