mirror of
https://github.com/logos-messaging/logos-messaging-test-query.git
synced 2026-01-07 16:33:09 +00:00
Merge fe5814f8755ca4c81c22e7a7ce3315f861cc8273 into d86d0d6cd71c9ea09e0683e9745e8519456c77b3
This commit is contained in:
commit
923386a504
19
main_test.go
19
main_test.go
@ -5,7 +5,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,9 +20,10 @@ var nodeList = []string{
|
|||||||
// If using vscode, go to Preferences > Settings, and edit Go: Test Timeout to at least 60s
|
// If using vscode, go to Preferences > Settings, and edit Go: Test Timeout to at least 60s
|
||||||
|
|
||||||
func (s *StoreSuite) TestBasic() {
|
func (s *StoreSuite) TestBasic() {
|
||||||
numMsgToSend := 100
|
|
||||||
pubsubTopic := relay.DefaultWakuTopic
|
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
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Test shouldnt take more than 60s
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -39,16 +39,6 @@ func (s *StoreSuite) TestBasic() {
|
|||||||
|
|
||||||
s.NotZero(len(s.node.Relay().PubSub().ListPeers(relay.DefaultWakuTopic)), "no peers available")
|
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
|
// Store
|
||||||
// ================================================================
|
// ================================================================
|
||||||
|
|
||||||
@ -59,9 +49,8 @@ func (s *StoreSuite) TestBasic() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
func(addr string) {
|
func(addr string) {
|
||||||
defer wg.Done()
|
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.NoError(err)
|
||||||
s.Equal(numMsgToSend, cnt)
|
|
||||||
}(addr)
|
}(addr)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|||||||
@ -86,7 +86,7 @@ func sendMessagesConcurrent(ctx context.Context, node *node.WakuNode, numMsgToSe
|
|||||||
return nil
|
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)
|
p, err := multiaddr.NewMultiaddr(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
@ -102,7 +102,7 @@ func queryNode(ctx context.Context, node *node.WakuNode, addr string, pubsubTopi
|
|||||||
|
|
||||||
result, err := node.Store().Query(ctx, store.Query{
|
result, err := node.Store().Query(ctx, store.Query{
|
||||||
Topic: pubsubTopic,
|
Topic: pubsubTopic,
|
||||||
ContentTopics: []string{contentTopic},
|
ContentTopics: contentTopics,
|
||||||
StartTime: startTime.UnixNano(),
|
StartTime: startTime.UnixNano(),
|
||||||
EndTime: endTime.UnixNano(),
|
EndTime: endTime.UnixNano(),
|
||||||
}, store.WithPeer(info.ID), store.WithPaging(false, 100), store.WithRequestId([]byte{1, 2, 3, 4, 5, 6, 7, 8}))
|
}, store.WithPeer(info.ID), store.WithPaging(false, 100), store.WithRequestId([]byte{1, 2, 3, 4, 5, 6, 7, 8}))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user