mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-05 04:54:31 +02:00
fix filter tests.
This commit is contained in:
@ -63,11 +63,11 @@ func (ef Filter) Matches(event *Event) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ef.Since != nil && event.CreatedAt <= *ef.Since {
|
if ef.Since != nil && event.CreatedAt < *ef.Since {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if ef.Until != nil && event.CreatedAt >= *ef.Until {
|
if ef.Until != nil && event.CreatedAt > *ef.Until {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,30 +39,6 @@ func TestFilterMarshal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterMatching(t *testing.T) {
|
|
||||||
if (Filter{Kinds: []int{4, 5}}).Matches(&Event{Kind: 6}) {
|
|
||||||
t.Error("matched event that shouldn't have matched")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !(Filter{Kinds: []int{4, 5}}).Matches(&Event{Kind: 4}) {
|
|
||||||
t.Error("failed to match event by kind")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !(Filter{
|
|
||||||
Kinds: []int{4, 5},
|
|
||||||
Tags: TagMap{
|
|
||||||
"p": {"ooo"},
|
|
||||||
},
|
|
||||||
IDs: []string{"prefix"},
|
|
||||||
}).Matches(&Event{
|
|
||||||
Kind: 4,
|
|
||||||
Tags: Tags{{"p", "ooo", ",x,x,"}, {"m", "yywyw", "xxx"}},
|
|
||||||
ID: "prefix123",
|
|
||||||
}) {
|
|
||||||
t.Error("failed to match event by kind+tags+id prefix")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFilterMatchingLive(t *testing.T) {
|
func TestFilterMatchingLive(t *testing.T) {
|
||||||
var filter Filter
|
var filter Filter
|
||||||
var event Event
|
var event Event
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const RELAY = "wss://relay.nostr.band"
|
const RELAY = "wss://nostr.mom"
|
||||||
|
|
||||||
// test if we can fetch a couple of random events
|
// test if we can fetch a couple of random events
|
||||||
func TestSubscribe(t *testing.T) {
|
func TestSubscribe(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user