mirror of https://github.com/status-im/go-waku.git
fix: make test work without buffered channel from relay.Subcribe
This commit is contained in:
parent
60edf95c48
commit
128999b763
|
@ -393,7 +393,6 @@ func (wf *WakuFilter) Subscribe(ctx context.Context, f ContentFilter, opts ...Fi
|
|||
ContentFilters: f.ContentTopics,
|
||||
Chan: make(chan *protocol.Envelope, 1024), // To avoid blocking
|
||||
}
|
||||
|
||||
wf.filters.Set(filterID, theFilter)
|
||||
|
||||
return
|
||||
|
|
|
@ -35,7 +35,12 @@ func makeFilterService(t *testing.T, isFullNode bool) *FilterService {
|
|||
require.NoError(t, err)
|
||||
|
||||
if isFullNode {
|
||||
_, err = n.Relay().SubscribeToTopic(context.Background(), testTopic)
|
||||
sub, err := n.Relay().SubscribeToTopic(context.Background(), testTopic)
|
||||
go func() {
|
||||
for range sub.Ch {
|
||||
}
|
||||
fmt.Println("stuck")
|
||||
}()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -254,8 +254,8 @@ func (p *PrivateService) GetV1AsymmetricMessages(req *http.Request, args *Asymme
|
|||
decodedMessages = append(decodedMessages, msg)
|
||||
}
|
||||
|
||||
for i := range decodedMessages {
|
||||
*reply = append(*reply, ProtoToRPC(decodedMessages[i]))
|
||||
for _, msg := range decodedMessages {
|
||||
*reply = append(*reply, ProtoToRPC(msg))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -2,7 +2,6 @@ package rpc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -94,9 +93,13 @@ func TestGetV1SymmetricMessages(t *testing.T) {
|
|||
defer d.node.Stop()
|
||||
|
||||
// Subscribing topic to test getter
|
||||
_, err := d.node.Relay().SubscribeToTopic(context.TODO(), "test")
|
||||
sub, err := d.node.Relay().SubscribeToTopic(context.TODO(), "test")
|
||||
require.NoError(t, err)
|
||||
fmt.Println("here")
|
||||
go func() {
|
||||
for range sub.Ch {
|
||||
}
|
||||
}()
|
||||
|
||||
var reply SuccessReply
|
||||
err = d.PostV1SymmetricMessage(
|
||||
makeRequest(t),
|
||||
|
@ -123,6 +126,7 @@ func TestGetV1SymmetricMessages(t *testing.T) {
|
|||
)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, getReply, 1)
|
||||
d.Stop() // not neccessary as wakuNode.Stop() calls broadcaster.Stop() which calls uses all the receiving channels
|
||||
}
|
||||
|
||||
func TestGetV1AsymmetricMessages(t *testing.T) {
|
||||
|
@ -131,8 +135,12 @@ func TestGetV1AsymmetricMessages(t *testing.T) {
|
|||
defer d.node.Stop()
|
||||
|
||||
// Subscribing topic to test getter
|
||||
_, err := d.node.Relay().SubscribeToTopic(context.TODO(), "test")
|
||||
sub, err := d.node.Relay().SubscribeToTopic(context.TODO(), "test")
|
||||
require.NoError(t, err)
|
||||
go func() {
|
||||
for range sub.Ch {
|
||||
}
|
||||
}()
|
||||
|
||||
prvKey, err := crypto.GenerateKey()
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Reference in New Issue