tests on root and khatru working.

This commit is contained in:
fiatjaf
2025-04-17 20:30:44 -03:00
parent 1c56906506
commit 32efaa7c58
13 changed files with 56 additions and 74 deletions

View File

@@ -17,7 +17,7 @@ func TestSubscribeBasic(t *testing.T) {
rl := mustRelayConnect(t, RELAY)
defer rl.Close()
sub, err := rl.Subscribe(context.Background(), Filters{{Kinds: []uint16{KindTextNote}, Limit: 2}})
sub, err := rl.Subscribe(context.Background(), Filter{Kinds: []uint16{KindTextNote}, Limit: 2}, SubscriptionOptions{})
assert.NoError(t, err)
timeout := time.After(5 * time.Second)
@@ -51,21 +51,21 @@ func TestNestedSubscriptions(t *testing.T) {
n := atomic.Uint32{}
// fetch 2 replies to a note
sub, err := rl.Subscribe(context.Background(), Filters{{Kinds: []uint16{KindTextNote}, Tags: TagMap{"e": []string{"0e34a74f8547e3b95d52a2543719b109fd0312aba144e2ef95cba043f42fe8c5"}}, Limit: 3}})
sub, err := rl.Subscribe(context.Background(), Filter{Kinds: []uint16{KindTextNote}, Tags: TagMap{"e": []string{"0e34a74f8547e3b95d52a2543719b109fd0312aba144e2ef95cba043f42fe8c5"}}, Limit: 3}, SubscriptionOptions{})
assert.NoError(t, err)
for {
select {
case event := <-sub.Events:
// now fetch author of this
sub, err := rl.Subscribe(context.Background(), Filters{{Kinds: []uint16{KindProfileMetadata}, Authors: []PubKey{event.PubKey}, Limit: 1}})
sub, err := rl.Subscribe(context.Background(), Filter{Kinds: []uint16{KindProfileMetadata}, Authors: []PubKey{event.PubKey}, Limit: 1}, SubscriptionOptions{})
assert.NoError(t, err)
for {
select {
case <-sub.Events:
// do another subscription here in "sync" mode, just so we're sure things are not blocking
rl.QuerySync(context.Background(), Filter{Limit: 1})
rl.QueryEvents(Filter{Limit: 1})
n.Add(1)
if n.Load() == 3 {