Skip to content

Commit

Permalink
chore: find with specific criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Aug 17, 2023
1 parent d86d0d6 commit fe5814f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
19 changes: 4 additions & 15 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"sync"
"time"

"github.com/stretchr/testify/require"
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
)

Expand All @@ -21,9 +20,10 @@ var nodeList = []string{
// If using vscode, go to Preferences > Settings, and edit Go: Test Timeout to at least 60s

func (s *StoreSuite) TestBasic() {
numMsgToSend := 100
pubsubTopic := relay.DefaultWakuTopic
contentTopic := "test1"
contentTopics := []string{"test1"}
startTime := time.Now()
endTime := time.Now()

ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Test shouldnt take more than 60s
defer cancel()
Expand All @@ -39,16 +39,6 @@ func (s *StoreSuite) TestBasic() {

s.NotZero(len(s.node.Relay().PubSub().ListPeers(relay.DefaultWakuTopic)), "no peers available")

// Sending messages
// ================================================================
startTime := s.node.Timesource().Now()

// err := sendMessages( to send the msgs sequentially
err := sendMessagesConcurrent(ctx, s.node, numMsgToSend, pubsubTopic, contentTopic)
require.NoError(s.T(), err)

endTime := s.node.Timesource().Now()

// Store
// ================================================================

Expand All @@ -59,9 +49,8 @@ func (s *StoreSuite) TestBasic() {
wg.Add(1)
func(addr string) {
defer wg.Done()
cnt, err := queryNode(ctx, s.node, addr, pubsubTopic, contentTopic, startTime, endTime)
_, err := queryNode(ctx, s.node, addr, pubsubTopic, contentTopics, startTime, endTime)
s.NoError(err)
s.Equal(numMsgToSend, cnt)
}(addr)
}
wg.Wait()
Expand Down
4 changes: 2 additions & 2 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func sendMessagesConcurrent(ctx context.Context, node *node.WakuNode, numMsgToSe
return nil
}

func queryNode(ctx context.Context, node *node.WakuNode, addr string, pubsubTopic string, contentTopic string, startTime time.Time, endTime time.Time) (int, error) {
func queryNode(ctx context.Context, node *node.WakuNode, addr string, pubsubTopic string, contentTopics []string, startTime time.Time, endTime time.Time) (int, error) {
p, err := multiaddr.NewMultiaddr(addr)
if err != nil {
return -1, err
Expand All @@ -102,7 +102,7 @@ func queryNode(ctx context.Context, node *node.WakuNode, addr string, pubsubTopi

result, err := node.Store().Query(ctx, store.Query{
Topic: pubsubTopic,
ContentTopics: []string{contentTopic},
ContentTopics: contentTopics,
StartTime: startTime.UnixNano(),
EndTime: endTime.UnixNano(),
}, store.WithPeer(info.ID), store.WithPaging(false, 100), store.WithRequestId([]byte{1, 2, 3, 4, 5, 6, 7, 8}))
Expand Down

0 comments on commit fe5814f

Please sign in to comment.