|
|
|
|
@@ -44,7 +44,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
|
|
|
|
|
// query
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{}, 500))
|
|
|
|
|
require.Len(t, results, len(allEvents))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
allEvents,
|
|
|
|
|
@@ -54,8 +54,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
|
since := nostr.Timestamp(i*10 + 1)
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Since: &since}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Since: nostr.Timestamp(i*10 + 1)}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
allEvents[i:],
|
|
|
|
|
results,
|
|
|
|
|
@@ -64,7 +63,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{IDs: []nostr.ID{allEvents[7].ID, allEvents[9].ID}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{IDs: []nostr.ID{allEvents[7].ID, allEvents[9].ID}}, 500))
|
|
|
|
|
require.Len(t, results, 2)
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[7], allEvents[9]},
|
|
|
|
|
@@ -73,7 +72,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{1}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{1}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[1], allEvents[3], allEvents[5], allEvents[7], allEvents[9]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -81,7 +80,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{9}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{9}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[0], allEvents[2], allEvents[4], allEvents[6], allEvents[8]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -90,7 +89,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
pk4 := nostr.GetPublicKey(sk4)
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Authors: []nostr.PubKey{pk4}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Authors: []nostr.PubKey{pk4}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[0], allEvents[3], allEvents[6], allEvents[9]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -99,7 +98,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
pk3 := nostr.GetPublicKey(sk3)
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{9}, Authors: []nostr.PubKey{pk3}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{9}, Authors: []nostr.PubKey{pk3}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[2], allEvents[4], allEvents[8]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -109,7 +108,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
{
|
|
|
|
|
pk3 := nostr.GetPublicKey(sk3)
|
|
|
|
|
pk4 := nostr.GetPublicKey(sk4)
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{9, 5, 7}, Authors: []nostr.PubKey{pk3, pk4}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{9, 5, 7}, Authors: []nostr.PubKey{pk3, pk4}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[0], allEvents[2], allEvents[4], allEvents[6], allEvents[8]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -117,7 +116,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"t": []string{"2", "4", "6"}}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"t": []string{"2", "4", "6"}}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[2], allEvents[4], allEvents[6]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -130,7 +129,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
|
|
|
|
|
// query again
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
slices.Concat(allEvents[0:4], allEvents[6:]),
|
|
|
|
|
results,
|
|
|
|
|
@@ -138,7 +137,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"t": []string{"2", "6"}}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"t": []string{"2", "6"}}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[2], allEvents[6]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -146,7 +145,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"e": []string{allEvents[3].Tags[1][1]}}}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"e": []string{allEvents[3].Tags[1][1]}}}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{allEvents[3]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -155,8 +154,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
for i := 0; i < 4; i++ {
|
|
|
|
|
until := nostr.Timestamp(i*10 + 1)
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Until: &until}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Until: nostr.Timestamp(i*10 + 1)}, 500))
|
|
|
|
|
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
allEvents[:i],
|
|
|
|
|
@@ -188,7 +186,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"p": []string{p}}, Kinds: []nostr.Kind{1984}, Limit: 2}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"p": []string{p}}, Kinds: []nostr.Kind{1984}, Limit: 2}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
[]nostr.Event{newEvents[2], newEvents[1]},
|
|
|
|
|
results,
|
|
|
|
|
@@ -197,7 +195,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"p": []string{p}, "t": []string{"x"}}, Limit: 4}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"p": []string{p}, "t": []string{"x"}}, Limit: 4}, 500))
|
|
|
|
|
require.ElementsMatch(t,
|
|
|
|
|
// the results won't be in canonical time order because this query is too awful, needs a kind
|
|
|
|
|
[]nostr.Event{newEvents[1]},
|
|
|
|
|
@@ -206,7 +204,7 @@ func runFirstTestOn(t *testing.T, db eventstore.Store) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"p": []string{p, p2}}, Kinds: []nostr.Kind{1}, Limit: 4}))
|
|
|
|
|
results := slices.Collect(db.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"p": []string{p, p2}}, Kinds: []nostr.Kind{1}, Limit: 4}, 500))
|
|
|
|
|
for _, idx := range []int{5, 6, 7} {
|
|
|
|
|
require.True(t,
|
|
|
|
|
slices.ContainsFunc(
|
|
|
|
|
|