-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: filter v2 tests push valid payload (#904)
- Loading branch information
Showing
6 changed files
with
195 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package filter | ||
|
||
import ( | ||
"context" | ||
"github.com/waku-org/go-waku/tests" | ||
"go.uber.org/zap" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
func (s *FilterTestSuite) TestValidPayloadsASCII() { | ||
|
||
// Subscribe | ||
s.subDetails = s.subscribe(s.testTopic, s.testContentTopic, s.fullNodeHost.ID()) | ||
|
||
// Prepare data | ||
messages := prepareData(100, false, false, true, tests.GenerateRandomASCIIString) | ||
|
||
// All messages should be received | ||
s.waitForMessages(func() { | ||
s.publishMessages(messages) | ||
}, s.subDetails, messages) | ||
|
||
_, err := s.lightNode.UnsubscribeAll(s.ctx) | ||
s.Require().NoError(err) | ||
|
||
} | ||
|
||
func (s *FilterTestSuite) TestValidPayloadsUTF8() { | ||
|
||
// Subscribe | ||
s.subDetails = s.subscribe(s.testTopic, s.testContentTopic, s.fullNodeHost.ID()) | ||
|
||
// Prepare data | ||
messages := prepareData(100, false, false, true, tests.GenerateRandomUTF8String) | ||
|
||
// All messages should be received | ||
s.waitForMessages(func() { | ||
s.publishMessages(messages) | ||
}, s.subDetails, messages) | ||
|
||
_, err := s.lightNode.UnsubscribeAll(s.ctx) | ||
s.Require().NoError(err) | ||
|
||
} | ||
|
||
func (s *FilterTestSuite) TestValidPayloadsBase64() { | ||
|
||
// Subscribe | ||
s.subDetails = s.subscribe(s.testTopic, s.testContentTopic, s.fullNodeHost.ID()) | ||
|
||
// Prepare data | ||
messages := prepareData(100, false, false, true, tests.GenerateRandomBase64String) | ||
|
||
// All messages should be received | ||
s.waitForMessages(func() { | ||
s.publishMessages(messages) | ||
}, s.subDetails, messages) | ||
|
||
_, err := s.lightNode.UnsubscribeAll(s.ctx) | ||
s.Require().NoError(err) | ||
|
||
} | ||
|
||
func (s *FilterTestSuite) TestValidPayloadsJSON() { | ||
|
||
// Subscribe | ||
s.subDetails = s.subscribe(s.testTopic, s.testContentTopic, s.fullNodeHost.ID()) | ||
|
||
// Prepare data | ||
messages := prepareData(100, false, false, true, tests.GenerateRandomJSONString) | ||
|
||
// All messages should be received | ||
s.waitForMessages(func() { | ||
s.publishMessages(messages) | ||
}, s.subDetails, messages) | ||
|
||
_, err := s.lightNode.UnsubscribeAll(s.ctx) | ||
s.Require().NoError(err) | ||
|
||
} | ||
|
||
func (s *FilterTestSuite) TestValidPayloadsURLEncoded() { | ||
|
||
// Subscribe | ||
s.subDetails = s.subscribe(s.testTopic, s.testContentTopic, s.fullNodeHost.ID()) | ||
|
||
// Prepare data | ||
messages := prepareData(100, false, false, true, tests.GenerateRandomURLEncodedString) | ||
|
||
// All messages should be received | ||
s.waitForMessages(func() { | ||
s.publishMessages(messages) | ||
}, s.subDetails, messages) | ||
|
||
_, err := s.lightNode.UnsubscribeAll(s.ctx) | ||
s.Require().NoError(err) | ||
|
||
} | ||
|
||
func (s *FilterTestSuite) TestValidPayloadsSQL() { | ||
|
||
// Subscribe | ||
s.subDetails = s.subscribe(s.testTopic, s.testContentTopic, s.fullNodeHost.ID()) | ||
|
||
// Prepare data | ||
messages := prepareData(100, false, false, true, tests.GenerateRandomSQLInsert) | ||
|
||
// All messages should be received | ||
s.waitForMessages(func() { | ||
s.publishMessages(messages) | ||
}, s.subDetails, messages) | ||
|
||
_, err := s.lightNode.UnsubscribeAll(s.ctx) | ||
s.Require().NoError(err) | ||
|
||
} | ||
|
||
func (s *FilterTestSuite) TestLargePayloadsUTF8() { | ||
|
||
s.ctx, s.ctxCancel = context.WithTimeout(context.Background(), 20*time.Second) | ||
|
||
// Subscribe | ||
s.subDetails = s.subscribe(s.testTopic, s.testContentTopic, s.fullNodeHost.ID()) | ||
|
||
// Prepare basic data | ||
messages := prepareData(10, false, false, false, nil) | ||
|
||
// Generate large string | ||
for i := range messages { | ||
messages[i].payload, _ = tests.GenerateRandomUTF8String(1048576) | ||
s.log.Info("Generated payload with ", zap.String("length", strconv.Itoa(len(messages[i].payload)))) | ||
} | ||
|
||
// All messages should be received | ||
s.waitForMessages(func() { | ||
s.publishMessages(messages) | ||
}, s.subDetails, messages) | ||
|
||
_, err := s.lightNode.UnsubscribeAll(s.ctx) | ||
s.Require().NoError(err) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.