fix: remove store node envelopes ordering hotfix (#4622)

This commit is contained in:
Igor Sirotin 2024-01-27 13:02:12 +00:00 committed by GitHub
parent f6c219c839
commit ab641c0c78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 9 deletions

View File

@ -4,9 +4,9 @@ import (
"errors" "errors"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-go/contracts/balancechecker"
"github.com/status-im/status-go/contracts/directory" "github.com/status-im/status-go/contracts/directory"
"github.com/status-im/status-go/contracts/ethscan" "github.com/status-im/status-go/contracts/ethscan"
"github.com/status-im/status-go/contracts/balancechecker"
"github.com/status-im/status-go/contracts/hop" "github.com/status-im/status-go/contracts/hop"
hopBridge "github.com/status-im/status-go/contracts/hop/bridge" hopBridge "github.com/status-im/status-go/contracts/hop/bridge"
hopSwap "github.com/status-im/status-go/contracts/hop/swap" hopSwap "github.com/status-im/status-go/contracts/hop/swap"

View File

@ -21,10 +21,6 @@ func defaultStoreNodeRequestConfig() StoreNodeRequestConfig {
func buildStoreNodeRequestConfig(opts []StoreNodeRequestOption) StoreNodeRequestConfig { func buildStoreNodeRequestConfig(opts []StoreNodeRequestOption) StoreNodeRequestConfig {
cfg := defaultStoreNodeRequestConfig() cfg := defaultStoreNodeRequestConfig()
// TODO: remove these 2 when fixed: https://github.com/waku-org/nwaku/issues/2317
opts = append(opts, WithStopWhenDataFound(false))
opts = append(opts, WithInitialPageSize(defaultStoreNodeRequestPageSize))
for _, opt := range opts { for _, opt := range opts {
opt(&cfg) opt(&cfg)
} }

View File

@ -455,7 +455,7 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityPagingAlgorithm() {
// First we fetch a more up-to-date, but an invalid spam message, fail to decrypt it as community description, // First we fetch a more up-to-date, but an invalid spam message, fail to decrypt it as community description,
// then we fetch another page of data and successfully decrypt a community description. // then we fetch another page of data and successfully decrypt a community description.
s.Require().Equal(spamAmount+1, stats.FetchedEnvelopesCount) s.Require().Equal(spamAmount+1, stats.FetchedEnvelopesCount)
s.Require().Equal(2, stats.FetchedPagesCount) // TODO: revert to 3 when fixed: https://github.com/waku-org/nwaku/issues/2317 s.Require().Equal(3, stats.FetchedPagesCount)
} }
func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityWithSameContentTopic() { func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityWithSameContentTopic() {
@ -685,10 +685,11 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityEnvelopesOrder() {
s.createOwner() s.createOwner()
s.createBob() s.createBob()
const descriptionsCount = 4
community := s.createCommunity(s.owner) community := s.createCommunity(s.owner)
// Push 5 descriptions to the store node // Push a few descriptions to the store node
for i := 0; i < 4; i++ { for i := 0; i < descriptionsCount-1; i++ {
err := s.owner.publishOrg(community) err := s.owner.publishOrg(community)
s.Require().NoError(err) s.Require().NoError(err)
} }
@ -699,15 +700,17 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityEnvelopesOrder() {
contentTopic := wakuV2common.BytesToTopic(transport.ToTopic(community.IDString())) contentTopic := wakuV2common.BytesToTopic(transport.ToTopic(community.IDString()))
var prevEnvelope *wakuV2common.ReceivedMessage var prevEnvelope *wakuV2common.ReceivedMessage
receivedEnvelopesCount := 0
s.setupEnvelopesWatcher(bobWakuV2, &contentTopic, func(envelope *wakuV2common.ReceivedMessage) { s.setupEnvelopesWatcher(bobWakuV2, &contentTopic, func(envelope *wakuV2common.ReceivedMessage) {
// We check that each next envelope fetched is newer than the previous one // We check that each next envelope fetched is newer than the previous one
if prevEnvelope != nil { if prevEnvelope != nil {
s.Require().Greater( s.Require().Less(
envelope.Envelope.Message().GetTimestamp(), envelope.Envelope.Message().GetTimestamp(),
prevEnvelope.Envelope.Message().GetTimestamp()) prevEnvelope.Envelope.Message().GetTimestamp())
} }
prevEnvelope = envelope prevEnvelope = envelope
receivedEnvelopesCount++
}) })
// Force a single-envelope page size to be able to check the order. // Force a single-envelope page size to be able to check the order.
@ -725,6 +728,9 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityEnvelopesOrder() {
fetchedCommunity, _, err := s.bob.storeNodeRequestsManager.FetchCommunity(community.CommunityShard(), options) fetchedCommunity, _, err := s.bob.storeNodeRequestsManager.FetchCommunity(community.CommunityShard(), options)
s.Require().NoError(err) s.Require().NoError(err)
s.requireCommunitiesEqual(fetchedCommunity, community) s.requireCommunitiesEqual(fetchedCommunity, community)
// Ensure all expected envelopes were received
s.Require().Equal(receivedEnvelopesCount, descriptionsCount)
} }
/* /*