mirror of
https://github.com/status-im/status-go.git
synced 2025-02-19 18:28:18 +00:00
chore: test filters are in the right place after store node requests (#4500)
This commit is contained in:
parent
1d3c618fb4
commit
a90589f4f7
@ -135,6 +135,7 @@ func (s *MessengerStoreNodeRequestSuite) newMessenger(shh types.Waku, logger *za
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *MessengerStoreNodeRequestSuite) createCommunity(m *Messenger) *communities.Community {
|
func (s *MessengerStoreNodeRequestSuite) createCommunity(m *Messenger) *communities.Community {
|
||||||
|
s.waitForAvailableStoreNode(m)
|
||||||
|
|
||||||
createCommunityRequest := &requests.CreateCommunity{
|
createCommunityRequest := &requests.CreateCommunity{
|
||||||
Name: RandomLettersString(10),
|
Name: RandomLettersString(10),
|
||||||
@ -144,7 +145,7 @@ func (s *MessengerStoreNodeRequestSuite) createCommunity(m *Messenger) *communit
|
|||||||
Membership: protobuf.CommunityPermissions_AUTO_ACCEPT,
|
Membership: protobuf.CommunityPermissions_AUTO_ACCEPT,
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := s.owner.CreateCommunity(createCommunityRequest, true)
|
response, err := m.CreateCommunity(createCommunityRequest, true)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
@ -200,7 +201,6 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityInfo() {
|
|||||||
s.createOwner()
|
s.createOwner()
|
||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community := s.createCommunity(s.owner)
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
s.waitForAvailableStoreNode(s.bob)
|
s.waitForAvailableStoreNode(s.bob)
|
||||||
@ -211,7 +211,6 @@ func (s *MessengerStoreNodeRequestSuite) TestConsecutiveRequests() {
|
|||||||
s.createOwner()
|
s.createOwner()
|
||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community := s.createCommunity(s.owner)
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
// Test consecutive requests to check that requests in manager are finalized
|
// Test consecutive requests to check that requests in manager are finalized
|
||||||
@ -225,7 +224,6 @@ func (s *MessengerStoreNodeRequestSuite) TestSimultaneousCommunityInfoRequests()
|
|||||||
s.createOwner()
|
s.createOwner()
|
||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community := s.createCommunity(s.owner)
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
storeNodeRequestsCount := 0
|
storeNodeRequestsCount := 0
|
||||||
@ -274,7 +272,6 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityInfoWithStoreNodeDi
|
|||||||
s.createOwner()
|
s.createOwner()
|
||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community := s.createCommunity(s.owner)
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
// WaitForAvailableStoreNode is done internally
|
// WaitForAvailableStoreNode is done internally
|
||||||
@ -337,7 +334,6 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityPagingAlgorithm() {
|
|||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
// Create a community
|
// Create a community
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community := s.createCommunity(s.owner)
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
// Push spam to the same ContentTopic & PubsubTopic
|
// Push spam to the same ContentTopic & PubsubTopic
|
||||||
@ -369,8 +365,7 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestCommunityWithSameContentTopi
|
|||||||
s.createOwner()
|
s.createOwner()
|
||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
// Create a community
|
// Create 2 communities
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community1 := s.createCommunity(s.owner)
|
community1 := s.createCommunity(s.owner)
|
||||||
community2 := s.createCommunity(s.owner)
|
community2 := s.createCommunity(s.owner)
|
||||||
|
|
||||||
@ -398,7 +393,6 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestMultipleCommunities() {
|
|||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
// Create 2 communities
|
// Create 2 communities
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community1 := s.createCommunity(s.owner)
|
community1 := s.createCommunity(s.owner)
|
||||||
community2 := s.createCommunity(s.owner)
|
community2 := s.createCommunity(s.owner)
|
||||||
|
|
||||||
@ -430,7 +424,6 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestWithoutWaitingResponse() {
|
|||||||
s.createBob()
|
s.createBob()
|
||||||
|
|
||||||
// Create a community
|
// Create a community
|
||||||
s.waitForAvailableStoreNode(s.owner)
|
|
||||||
community := s.createCommunity(s.owner)
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
request := FetchCommunityRequest{
|
request := FetchCommunityRequest{
|
||||||
@ -513,3 +506,39 @@ func (s *MessengerStoreNodeRequestSuite) TestRequestShardAndCommunityInfo() {
|
|||||||
|
|
||||||
s.fetchCommunity(s.bob, communityShard, community)
|
s.fetchCommunity(s.bob, communityShard, community)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *MessengerStoreNodeRequestSuite) TestFiltersNotRemoved() {
|
||||||
|
s.createOwner()
|
||||||
|
s.createBob()
|
||||||
|
|
||||||
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
|
// The owner is a member of the community, so he has a filter for community description content topic.
|
||||||
|
// We want to check that filter is not removed by `FetchCommunity` call.
|
||||||
|
filterBefore := s.owner.transport.FilterByChatID(community.IDString())
|
||||||
|
s.Require().NotNil(filterBefore)
|
||||||
|
|
||||||
|
s.fetchCommunity(s.owner, community.CommunityShard(), community)
|
||||||
|
|
||||||
|
filterAfter := s.owner.transport.FilterByChatID(community.IDString())
|
||||||
|
s.Require().NotNil(filterAfter)
|
||||||
|
|
||||||
|
s.Require().Equal(filterBefore.FilterID, filterAfter.FilterID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MessengerStoreNodeRequestSuite) TestFiltersRemoved() {
|
||||||
|
s.createOwner()
|
||||||
|
s.createBob()
|
||||||
|
|
||||||
|
community := s.createCommunity(s.owner)
|
||||||
|
|
||||||
|
// The bob is a member of the community, so he has no filters for community description content topic.
|
||||||
|
// We want to check that filter created by `FetchCommunity` is removed on request finish.
|
||||||
|
filterBefore := s.bob.transport.FilterByChatID(community.IDString())
|
||||||
|
s.Require().Nil(filterBefore)
|
||||||
|
|
||||||
|
s.fetchCommunity(s.bob, community.CommunityShard(), community)
|
||||||
|
|
||||||
|
filterAfter := s.bob.transport.FilterByChatID(community.IDString())
|
||||||
|
s.Require().Nil(filterAfter)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user