go mod tidy works now at least.
This commit is contained in:
@@ -2,13 +2,12 @@ package test
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"fiatjaf.com/nostr/eventstore"
|
||||
"fiatjaf.com/nostr"
|
||||
"fiatjaf.com/nostr/eventstore"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -18,35 +17,35 @@ func manyAuthorsTest(t *testing.T, db eventstore.Store) {
|
||||
const total = 10000
|
||||
const limit = 500
|
||||
const authors = 1700
|
||||
kinds := []int{6, 7, 8}
|
||||
kinds := []uint16{6, 7, 8}
|
||||
|
||||
bigfilter := nostr.Filter{
|
||||
Authors: make([]string, authors),
|
||||
Authors: make([]nostr.PubKey, authors),
|
||||
Kinds: kinds,
|
||||
Limit: limit,
|
||||
}
|
||||
for i := 0; i < authors; i++ {
|
||||
sk := make([]byte, 32)
|
||||
binary.BigEndian.PutUint32(sk, uint32(i%(total/5))+1)
|
||||
pk, _ := nostr.GetPublicKey(hex.EncodeToString(sk))
|
||||
pk := nostr.GetPublicKey([32]byte(sk))
|
||||
bigfilter.Authors[i] = pk
|
||||
}
|
||||
|
||||
ordered := make([]*nostr.Event, 0, total)
|
||||
ordered := make([]nostr.Event, 0, total)
|
||||
for i := 0; i < total; i++ {
|
||||
sk := make([]byte, 32)
|
||||
binary.BigEndian.PutUint32(sk, uint32(i%(total/5))+1)
|
||||
|
||||
evt := &nostr.Event{
|
||||
evt := nostr.Event{
|
||||
CreatedAt: nostr.Timestamp(i*i) / 4,
|
||||
Content: fmt.Sprintf("lots of stuff %d", i),
|
||||
Tags: nostr.Tags{},
|
||||
Kind: i % 10,
|
||||
Kind: uint16(i % 10),
|
||||
}
|
||||
err := evt.Sign(hex.EncodeToString(sk))
|
||||
err := evt.Sign([32]byte(sk))
|
||||
require.NoError(t, err)
|
||||
|
||||
err = db.SaveEvent(ctx, evt)
|
||||
err = db.SaveEvent(evt)
|
||||
require.NoError(t, err)
|
||||
|
||||
if bigfilter.Matches(evt) {
|
||||
@@ -56,12 +55,11 @@ func manyAuthorsTest(t *testing.T, db eventstore.Store) {
|
||||
|
||||
w := eventstore.RelayWrapper{Store: db}
|
||||
|
||||
res, err := w.QuerySync(ctx, bigfilter)
|
||||
res := slices.Collect(w.QueryEvents(bigfilter))
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Len(t, res, limit)
|
||||
require.True(t, slices.IsSortedFunc(res, nostr.CompareEventPtrReverse))
|
||||
slices.SortFunc(ordered, nostr.CompareEventPtrReverse)
|
||||
require.True(t, slices.IsSortedFunc(res, nostr.CompareEventReverse))
|
||||
slices.SortFunc(ordered, nostr.CompareEventReverse)
|
||||
require.Equal(t, ordered[0], res[0])
|
||||
require.Equal(t, ordered[limit-1], res[limit-1])
|
||||
require.Equal(t, ordered[0:limit], res)
|
||||
|
||||
Reference in New Issue
Block a user