mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-25 21:21:57 +02:00
localhost and 127.0.0.1 are "virtual" relays, but not when running go test
This commit is contained in:
@@ -67,7 +67,7 @@ func (sys *System) StreamLiveFeed(
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
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 {
|
for evt := range sub {
|
||||||
sys.StoreRelay.Publish(ctx, *evt.Event)
|
sys.StoreRelay.Publish(ctx, *evt.Event)
|
||||||
if latest < evt.CreatedAt {
|
if latest < evt.CreatedAt {
|
||||||
@@ -153,7 +153,7 @@ func (sys *System) FetchFeedPage(
|
|||||||
fUntil := oldestTimestamp + 1
|
fUntil := oldestTimestamp + 1
|
||||||
filter.Until = &fUntil
|
filter.Until = &fUntil
|
||||||
filter.Since = nil
|
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)
|
sys.StoreRelay.Publish(ctx, *ie.Event)
|
||||||
|
|
||||||
// we shouldn't need this check here, but against rogue relays we'll do it
|
// we shouldn't need this check here, but against rogue relays we'll do it
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,12 +22,16 @@ func IsVirtualRelay(url string) bool {
|
|||||||
|
|
||||||
if strings.HasPrefix(url, "wss://feeds.nostr.band") ||
|
if strings.HasPrefix(url, "wss://feeds.nostr.band") ||
|
||||||
strings.HasPrefix(url, "wss://filter.nostr.wine") ||
|
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") {
|
strings.HasPrefix(url, "wss://cache") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !testing.Testing() &&
|
||||||
|
strings.HasPrefix(url, "ws://localhost") ||
|
||||||
|
strings.HasPrefix(url, "ws://127.0.0.1") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user