fix_:failed test relate to old status community
This commit is contained in:
parent
6eb40bf781
commit
eb6ebade8e
|
@ -296,12 +296,11 @@ func (s *ManagerSuite) TestCreateCommunity() {
|
||||||
|
|
||||||
communities, err := s.manager.All()
|
communities, err := s.manager.All()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// Consider status default community
|
s.Require().Len(communities, 1)
|
||||||
s.Require().Len(communities, 2)
|
|
||||||
|
|
||||||
actualCommunity := communities[0]
|
actualCommunity := communities[0]
|
||||||
if bytes.Equal(community.ID(), communities[1].ID()) {
|
if bytes.Equal(community.ID(), communities[0].ID()) {
|
||||||
actualCommunity = communities[1]
|
actualCommunity = communities[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Require().Equal(community.ID(), actualCommunity.ID())
|
s.Require().Equal(community.ID(), actualCommunity.ID())
|
||||||
|
@ -341,8 +340,7 @@ func (s *ManagerSuite) TestCreateCommunity_WithBanner() {
|
||||||
|
|
||||||
communities, err := s.manager.All()
|
communities, err := s.manager.All()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// Consider status default community
|
s.Require().Len(communities, 1)
|
||||||
s.Require().Len(communities, 2)
|
|
||||||
s.Require().Equal(len(community.config.CommunityDescription.Identity.Images), 1)
|
s.Require().Equal(len(community.config.CommunityDescription.Identity.Images), 1)
|
||||||
testIdentityImage, isMapContainsKey := community.config.CommunityDescription.Identity.Images[userimages.BannerIdentityName]
|
testIdentityImage, isMapContainsKey := community.config.CommunityDescription.Identity.Images[userimages.BannerIdentityName]
|
||||||
s.Require().True(isMapContainsKey)
|
s.Require().True(isMapContainsKey)
|
||||||
|
@ -376,12 +374,11 @@ func (s *ManagerSuite) TestEditCommunity() {
|
||||||
//ensure updated community successfully stored
|
//ensure updated community successfully stored
|
||||||
communities, err := s.manager.All()
|
communities, err := s.manager.All()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// Consider status default community
|
s.Require().Len(communities, 1)
|
||||||
s.Require().Len(communities, 2)
|
|
||||||
|
|
||||||
storedCommunity := communities[0]
|
storedCommunity := communities[0]
|
||||||
if bytes.Equal(community.ID(), communities[1].ID()) {
|
if bytes.Equal(community.ID(), communities[0].ID()) {
|
||||||
storedCommunity = communities[1]
|
storedCommunity = communities[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Require().Equal(storedCommunity.ID(), updatedCommunity.ID())
|
s.Require().Equal(storedCommunity.ID(), updatedCommunity.ID())
|
||||||
|
|
|
@ -53,10 +53,9 @@ func (s *PersistenceSuite) SetupTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PersistenceSuite) TestSaveCommunity() {
|
func (s *PersistenceSuite) TestSaveCommunity() {
|
||||||
// there is one community inserted by default
|
|
||||||
communities, err := s.db.AllCommunities(&s.identity.PublicKey)
|
communities, err := s.db.AllCommunities(&s.identity.PublicKey)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(communities, 1)
|
s.Require().Len(communities, 0)
|
||||||
|
|
||||||
community := Community{
|
community := Community{
|
||||||
config: &Config{
|
config: &Config{
|
||||||
|
@ -76,13 +75,13 @@ func (s *PersistenceSuite) TestSaveCommunity() {
|
||||||
|
|
||||||
communities, err = s.db.AllCommunities(&s.identity.PublicKey)
|
communities, err = s.db.AllCommunities(&s.identity.PublicKey)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(communities, 2)
|
s.Require().Len(communities, 1)
|
||||||
s.Equal(types.HexBytes(crypto.CompressPubkey(&s.identity.PublicKey)), communities[1].ID())
|
s.Equal(types.HexBytes(crypto.CompressPubkey(&s.identity.PublicKey)), communities[0].ID())
|
||||||
s.Equal(true, communities[1].Joined())
|
s.Equal(true, communities[0].Joined())
|
||||||
s.Equal(true, communities[1].Spectated())
|
s.Equal(true, communities[0].Spectated())
|
||||||
s.Equal(true, communities[1].Verified())
|
s.Equal(true, communities[0].Verified())
|
||||||
s.Equal(true, communities[1].Muted())
|
s.Equal(true, communities[0].Muted())
|
||||||
s.Equal(time.Time{}, communities[1].MuteTill())
|
s.Equal(time.Time{}, communities[0].MuteTill())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *PersistenceSuite) TestShouldHandleSyncCommunity() {
|
func (s *PersistenceSuite) TestShouldHandleSyncCommunity() {
|
||||||
|
@ -105,7 +104,7 @@ func (s *PersistenceSuite) TestShouldHandleSyncCommunity() {
|
||||||
|
|
||||||
rcrs, err := s.db.getAllCommunitiesRaw()
|
rcrs, err := s.db.getAllCommunitiesRaw()
|
||||||
s.Require().NoError(err, "should have no error from getAllCommunitiesRaw")
|
s.Require().NoError(err, "should have no error from getAllCommunitiesRaw")
|
||||||
s.Len(rcrs, 2, "length of all communities raw should be 2")
|
s.Len(rcrs, 1, "length of all communities raw should be 1")
|
||||||
|
|
||||||
// check again to see is the community should be synced
|
// check again to see is the community should be synced
|
||||||
sc.Clock--
|
sc.Clock--
|
||||||
|
|
|
@ -115,7 +115,7 @@ func setUpCommunityAndRoles(base CommunityEventsTestsInterface, role protobuf.Co
|
||||||
tcs2, err := base.GetControlNode().communitiesManager.All()
|
tcs2, err := base.GetControlNode().communitiesManager.All()
|
||||||
suite := base.GetSuite()
|
suite := base.GetSuite()
|
||||||
suite.Require().NoError(err, "eventSender.communitiesManager.All")
|
suite.Require().NoError(err, "eventSender.communitiesManager.All")
|
||||||
suite.Len(tcs2, 1, "Must have 1 community")
|
suite.Len(tcs2, 0, "Must have 0 community")
|
||||||
|
|
||||||
// ControlNode creates a community and chat
|
// ControlNode creates a community and chat
|
||||||
community := createTestCommunity(base, protobuf.CommunityPermissions_AUTO_ACCEPT)
|
community := createTestCommunity(base, protobuf.CommunityPermissions_AUTO_ACCEPT)
|
||||||
|
@ -419,7 +419,7 @@ func setUpOnRequestCommunityAndRoles(base CommunityEventsTestsInterface, role pr
|
||||||
tcs2, err := base.GetControlNode().communitiesManager.All()
|
tcs2, err := base.GetControlNode().communitiesManager.All()
|
||||||
s := base.GetSuite()
|
s := base.GetSuite()
|
||||||
s.Require().NoError(err, "eventSender.communitiesManager.All")
|
s.Require().NoError(err, "eventSender.communitiesManager.All")
|
||||||
s.Len(tcs2, 1, "Must have 1 community")
|
s.Len(tcs2, 0, "Must have 0 community")
|
||||||
|
|
||||||
// control node creates a community and chat
|
// control node creates a community and chat
|
||||||
community := createTestCommunity(base, protobuf.CommunityPermissions_MANUAL_ACCEPT)
|
community := createTestCommunity(base, protobuf.CommunityPermissions_MANUAL_ACCEPT)
|
||||||
|
@ -2140,7 +2140,7 @@ func testMemberReceiveRequestsToJoinAfterGettingNewRole(base CommunityEventsTest
|
||||||
tcs2, err := base.GetControlNode().communitiesManager.All()
|
tcs2, err := base.GetControlNode().communitiesManager.All()
|
||||||
s := base.GetSuite()
|
s := base.GetSuite()
|
||||||
s.Require().NoError(err, "eventSender.communitiesManager.All")
|
s.Require().NoError(err, "eventSender.communitiesManager.All")
|
||||||
s.Len(tcs2, 1, "Must have 1 community")
|
s.Len(tcs2, 0, "Must have 0 community")
|
||||||
|
|
||||||
// control node creates a community and chat
|
// control node creates a community and chat
|
||||||
community := createTestCommunity(base, protobuf.CommunityPermissions_MANUAL_ACCEPT)
|
community := createTestCommunity(base, protobuf.CommunityPermissions_MANUAL_ACCEPT)
|
||||||
|
|
|
@ -202,7 +202,7 @@ func (s *MessengerCommunitiesSuite) TestRetrieveCommunity() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
communities, err := s.alice.Communities()
|
communities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(communities, 2)
|
s.Require().Len(communities, 1)
|
||||||
s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
s.Require().Len(response.Messages(), 1)
|
s.Require().Len(response.Messages(), 1)
|
||||||
s.Require().Equal(community.IDString(), response.Messages()[0].CommunityID)
|
s.Require().Equal(community.IDString(), response.Messages()[0].CommunityID)
|
||||||
|
@ -401,7 +401,7 @@ func (s *MessengerCommunitiesSuite) TestJoinCommunity() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
communities, err := s.alice.Communities()
|
communities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(communities, 2)
|
s.Require().Len(communities, 1)
|
||||||
s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
s.Require().Len(response.Messages(), 1)
|
s.Require().Len(response.Messages(), 1)
|
||||||
s.Require().Equal(community.IDString(), response.Messages()[0].CommunityID)
|
s.Require().Equal(community.IDString(), response.Messages()[0].CommunityID)
|
||||||
|
@ -486,7 +486,7 @@ func (s *MessengerCommunitiesSuite) TestJoinCommunity() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
communities, err = s.alice.Communities()
|
communities, err = s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(communities, 2)
|
s.Require().Len(communities, 1)
|
||||||
s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
s.Require().NotNil(actualChat)
|
s.Require().NotNil(actualChat)
|
||||||
s.Require().Equal(community.IDString(), actualChat.CommunityID)
|
s.Require().Equal(community.IDString(), actualChat.CommunityID)
|
||||||
|
@ -895,13 +895,9 @@ func (s *MessengerCommunitiesSuite) TestRequestAccess() {
|
||||||
|
|
||||||
allCommunities, err := s.alice.Communities()
|
allCommunities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(allCommunities, 2)
|
s.Require().Len(allCommunities, 1)
|
||||||
|
s.Require().Equal(allCommunities[0].ID(), community.ID())
|
||||||
if bytes.Equal(allCommunities[0].ID(), community.ID()) {
|
|
||||||
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
||||||
} else {
|
|
||||||
s.Require().Equal(allCommunities[1].RequestedToJoinAt(), requestToJoin1.Clock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// pull to make sure it has been saved
|
// pull to make sure it has been saved
|
||||||
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
||||||
|
@ -1537,13 +1533,9 @@ func (s *MessengerCommunitiesSuite) TestCancelRequestAccess() {
|
||||||
|
|
||||||
allCommunities, err := s.alice.Communities()
|
allCommunities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(allCommunities, 2)
|
s.Require().Len(allCommunities, 1)
|
||||||
|
s.Require().Equal(allCommunities[0].ID(), community.ID())
|
||||||
if bytes.Equal(allCommunities[0].ID(), community.ID()) {
|
|
||||||
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
||||||
} else {
|
|
||||||
s.Require().Equal(allCommunities[1].RequestedToJoinAt(), requestToJoin1.Clock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// pull to make sure it has been saved
|
// pull to make sure it has been saved
|
||||||
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
||||||
|
@ -1699,13 +1691,9 @@ func (s *MessengerCommunitiesSuite) TestRequestAccessAgain() {
|
||||||
|
|
||||||
allCommunities, err := s.alice.Communities()
|
allCommunities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(allCommunities, 2)
|
s.Require().Len(allCommunities, 1)
|
||||||
|
s.Require().Equal(allCommunities[0].ID(), community.ID())
|
||||||
if bytes.Equal(allCommunities[0].ID(), community.ID()) {
|
|
||||||
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
||||||
} else {
|
|
||||||
s.Require().Equal(allCommunities[1].RequestedToJoinAt(), requestToJoin1.Clock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// pull to make sure it has been saved
|
// pull to make sure it has been saved
|
||||||
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
||||||
|
@ -1995,13 +1983,9 @@ func (s *MessengerCommunitiesSuite) TestDeclineAccess() {
|
||||||
|
|
||||||
allCommunities, err := s.alice.Communities()
|
allCommunities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(allCommunities, 2)
|
s.Require().Len(allCommunities, 1)
|
||||||
|
s.Require().Equal(allCommunities[0].ID(), community.ID())
|
||||||
if bytes.Equal(allCommunities[0].ID(), community.ID()) {
|
|
||||||
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
||||||
} else {
|
|
||||||
s.Require().Equal(allCommunities[1].RequestedToJoinAt(), requestToJoin1.Clock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve request to join
|
// Retrieve request to join
|
||||||
err = tt.RetryWithBackOff(func() error {
|
err = tt.RetryWithBackOff(func() error {
|
||||||
|
@ -2436,7 +2420,7 @@ func (s *MessengerCommunitiesSuite) createOtherDevice(m1 *Messenger) *Messenger
|
||||||
|
|
||||||
tcs, err := m2.communitiesManager.All()
|
tcs, err := m2.communitiesManager.All()
|
||||||
s.Require().NoError(err, "m2.communitiesManager.All")
|
s.Require().NoError(err, "m2.communitiesManager.All")
|
||||||
s.Len(tcs, 1, "Must have 1 communities")
|
s.Len(tcs, 0, "Must have 0 communities")
|
||||||
|
|
||||||
// Pair devices
|
// Pair devices
|
||||||
metadata := &multidevice.InstallationMetadata{
|
metadata := &multidevice.InstallationMetadata{
|
||||||
|
@ -2616,10 +2600,10 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity() {
|
||||||
}
|
}
|
||||||
s.Require().NotNil(newCommunity)
|
s.Require().NotNil(newCommunity)
|
||||||
|
|
||||||
// Check that Alice has 2 communities
|
// Check that Alice has 1 community
|
||||||
cs, err := s.alice.communitiesManager.All()
|
cs, err := s.alice.communitiesManager.All()
|
||||||
s.Require().NoError(err, "communitiesManager.All")
|
s.Require().NoError(err, "communitiesManager.All")
|
||||||
s.Len(cs, 2, "Must have 2 communities")
|
s.Len(cs, 1, "Must have 1 community")
|
||||||
|
|
||||||
// Wait for the message to reach its destination
|
// Wait for the message to reach its destination
|
||||||
err = tt.RetryWithBackOff(func() error {
|
err = tt.RetryWithBackOff(func() error {
|
||||||
|
@ -2641,7 +2625,7 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity() {
|
||||||
// Count the number of communities in their device
|
// Count the number of communities in their device
|
||||||
tcs, err := alicesOtherDevice.communitiesManager.All()
|
tcs, err := alicesOtherDevice.communitiesManager.All()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Len(tcs, 2, "There must be 2 communities")
|
s.Len(tcs, 1, "There must be 1 community")
|
||||||
|
|
||||||
s.logger.Debug("", zap.Any("tcs", tcs))
|
s.logger.Debug("", zap.Any("tcs", tcs))
|
||||||
|
|
||||||
|
@ -2767,10 +2751,10 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_RequestToJoin() {
|
||||||
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
||||||
PairDevices(&s.Suite, s.alice, alicesOtherDevice)
|
PairDevices(&s.Suite, s.alice, alicesOtherDevice)
|
||||||
|
|
||||||
// Check bob the admin has only one community
|
// Check bob the admin has 0 community
|
||||||
tcs2, err := s.bob.communitiesManager.All()
|
tcs2, err := s.bob.communitiesManager.All()
|
||||||
s.Require().NoError(err, "admin.communitiesManager.All")
|
s.Require().NoError(err, "admin.communitiesManager.All")
|
||||||
s.Len(tcs2, 1, "Must have 1 communities")
|
s.Len(tcs2, 0, "Must have 0 communities")
|
||||||
|
|
||||||
// Bob the admin creates a community
|
// Bob the admin creates a community
|
||||||
createCommunityReq := &requests.CreateCommunity{
|
createCommunityReq := &requests.CreateCommunity{
|
||||||
|
@ -2786,19 +2770,19 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_RequestToJoin() {
|
||||||
|
|
||||||
community := mr.Communities()[0]
|
community := mr.Communities()[0]
|
||||||
|
|
||||||
// Check that admin has 2 communities
|
// Check that admin has 1 community
|
||||||
acs, err := s.bob.communitiesManager.All()
|
acs, err := s.bob.communitiesManager.All()
|
||||||
s.Require().NoError(err, "communitiesManager.All")
|
s.Require().NoError(err, "communitiesManager.All")
|
||||||
s.Len(acs, 2, "Must have 2 communities")
|
s.Len(acs, 1, "Must have 1 communities")
|
||||||
|
|
||||||
// Check that Alice has only 1 community on either device
|
// Check that Alice has 0 communities on either device
|
||||||
cs, err := s.alice.communitiesManager.All()
|
cs, err := s.alice.communitiesManager.All()
|
||||||
s.Require().NoError(err, "communitiesManager.All")
|
s.Require().NoError(err, "communitiesManager.All")
|
||||||
s.Len(cs, 1, "Must have 1 communities")
|
s.Len(cs, 0, "Must have 0 communities")
|
||||||
|
|
||||||
tcs1, err := alicesOtherDevice.communitiesManager.All()
|
tcs1, err := alicesOtherDevice.communitiesManager.All()
|
||||||
s.Require().NoError(err, "alicesOtherDevice.communitiesManager.All")
|
s.Require().NoError(err, "alicesOtherDevice.communitiesManager.All")
|
||||||
s.Len(tcs1, 1, "Must have 1 communities")
|
s.Len(tcs1, 0, "Must have 0 communities")
|
||||||
|
|
||||||
// Bob the admin opens up a 1-1 chat with alice
|
// Bob the admin opens up a 1-1 chat with alice
|
||||||
chat := CreateOneToOneChat(common.PubkeyToHex(&s.alice.identity.PublicKey), &s.alice.identity.PublicKey, s.alice.transport)
|
chat := CreateOneToOneChat(common.PubkeyToHex(&s.alice.identity.PublicKey), &s.alice.identity.PublicKey, s.alice.transport)
|
||||||
|
@ -2824,10 +2808,10 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_RequestToJoin() {
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Check that alice now has 2 communities
|
// Check that alice now has 1 community
|
||||||
cs, err = s.alice.communitiesManager.All()
|
cs, err = s.alice.communitiesManager.All()
|
||||||
s.Require().NoError(err, "communitiesManager.All")
|
s.Require().NoError(err, "communitiesManager.All")
|
||||||
s.Len(cs, 2, "Must have 2 communities")
|
s.Len(cs, 1, "Must have 1 community")
|
||||||
for _, c := range cs {
|
for _, c := range cs {
|
||||||
s.False(c.Joined(), "Must not have joined the community")
|
s.False(c.Joined(), "Must not have joined the community")
|
||||||
}
|
}
|
||||||
|
@ -2864,13 +2848,9 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_RequestToJoin() {
|
||||||
// pull all communities to make sure we set RequestedToJoinAt
|
// pull all communities to make sure we set RequestedToJoinAt
|
||||||
allCommunities, err := s.alice.Communities()
|
allCommunities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Len(allCommunities, 2)
|
s.Len(allCommunities, 1)
|
||||||
|
s.Require().Equal(allCommunities[0].ID(), community.ID())
|
||||||
if bytes.Equal(allCommunities[0].ID(), community.ID()) {
|
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), aRtj.Clock)
|
||||||
s.Equal(allCommunities[0].RequestedToJoinAt(), aRtj.Clock)
|
|
||||||
} else {
|
|
||||||
s.Equal(allCommunities[1].RequestedToJoinAt(), aRtj.Clock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// pull to make sure it has been saved
|
// pull to make sure it has been saved
|
||||||
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
||||||
|
@ -2976,10 +2956,10 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_Leave() {
|
||||||
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
||||||
PairDevices(&s.Suite, s.alice, alicesOtherDevice)
|
PairDevices(&s.Suite, s.alice, alicesOtherDevice)
|
||||||
|
|
||||||
// Check bob the admin has only one community
|
// Check bob the admin has only zero community
|
||||||
tcs2, err := s.bob.communitiesManager.All()
|
tcs2, err := s.bob.communitiesManager.All()
|
||||||
s.Require().NoError(err, "admin.communitiesManager.All")
|
s.Require().NoError(err, "admin.communitiesManager.All")
|
||||||
s.Len(tcs2, 1, "Must have 1 communities")
|
s.Len(tcs2, 0, "Must have 0 communities")
|
||||||
|
|
||||||
// Bob the admin creates a community
|
// Bob the admin creates a community
|
||||||
createCommunityReq := &requests.CreateCommunity{
|
createCommunityReq := &requests.CreateCommunity{
|
||||||
|
@ -2995,19 +2975,19 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_Leave() {
|
||||||
|
|
||||||
community := mr.Communities()[0]
|
community := mr.Communities()[0]
|
||||||
|
|
||||||
// Check that admin has 2 communities
|
// Check that admin has 1 community
|
||||||
acs, err := s.bob.communitiesManager.All()
|
acs, err := s.bob.communitiesManager.All()
|
||||||
s.Require().NoError(err, "communitiesManager.All")
|
s.Require().NoError(err, "communitiesManager.All")
|
||||||
s.Len(acs, 2, "Must have 2 communities")
|
s.Len(acs, 1, "Must have 1 community")
|
||||||
|
|
||||||
// Check that Alice has only 1 community on either device
|
// Check that Alice has 0 community on either device
|
||||||
cs, err := s.alice.communitiesManager.All()
|
cs, err := s.alice.communitiesManager.All()
|
||||||
s.Require().NoError(err, "communitiesManager.All")
|
s.Require().NoError(err, "communitiesManager.All")
|
||||||
s.Len(cs, 1, "Must have 1 communities")
|
s.Len(cs, 0, "Must have 0 communities")
|
||||||
|
|
||||||
tcs1, err := alicesOtherDevice.communitiesManager.All()
|
tcs1, err := alicesOtherDevice.communitiesManager.All()
|
||||||
s.Require().NoError(err, "alicesOtherDevice.communitiesManager.All")
|
s.Require().NoError(err, "alicesOtherDevice.communitiesManager.All")
|
||||||
s.Len(tcs1, 1, "Must have 1 communities")
|
s.Len(tcs1, 0, "Must have 0 communities")
|
||||||
|
|
||||||
// Bob the admin opens up a 1-1 chat with alice
|
// Bob the admin opens up a 1-1 chat with alice
|
||||||
chat := CreateOneToOneChat(common.PubkeyToHex(&s.alice.identity.PublicKey), &s.alice.identity.PublicKey, s.alice.transport)
|
chat := CreateOneToOneChat(common.PubkeyToHex(&s.alice.identity.PublicKey), &s.alice.identity.PublicKey, s.alice.transport)
|
||||||
|
@ -3033,10 +3013,10 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_Leave() {
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Check that alice now has 2 communities
|
// Check that alice now has 1 community
|
||||||
cs, err = s.alice.communitiesManager.All()
|
cs, err = s.alice.communitiesManager.All()
|
||||||
s.Require().NoError(err, "communitiesManager.All")
|
s.Require().NoError(err, "communitiesManager.All")
|
||||||
s.Len(cs, 2, "Must have 2 communities")
|
s.Len(cs, 1, "Must have 1 community")
|
||||||
for _, c := range cs {
|
for _, c := range cs {
|
||||||
s.False(c.Joined(), "Must not have joined the community")
|
s.False(c.Joined(), "Must not have joined the community")
|
||||||
}
|
}
|
||||||
|
@ -3980,13 +3960,9 @@ func (s *MessengerCommunitiesSuite) TestRequestAndCancelCommunityAdminOffline()
|
||||||
|
|
||||||
allCommunities, err := s.alice.Communities()
|
allCommunities, err := s.alice.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(allCommunities, 2)
|
s.Require().Len(allCommunities, 1)
|
||||||
|
s.Require().Equal(allCommunities[0].ID(), community.ID())
|
||||||
if bytes.Equal(allCommunities[0].ID(), community.ID()) {
|
|
||||||
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
s.Require().Equal(allCommunities[0].RequestedToJoinAt(), requestToJoin1.Clock)
|
||||||
} else {
|
|
||||||
s.Require().Equal(allCommunities[1].RequestedToJoinAt(), requestToJoin1.Clock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// pull to make sure it has been saved
|
// pull to make sure it has been saved
|
||||||
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
requestsToJoin, err := s.alice.MyPendingRequestsToJoin()
|
||||||
|
|
|
@ -671,7 +671,7 @@ func (s *MessengerBackupSuite) TestBackupCommunities() {
|
||||||
// Safety check
|
// Safety check
|
||||||
communities, err := bob2.Communities()
|
communities, err := bob2.Communities()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Len(communities, 1)
|
s.Require().Len(communities, 0)
|
||||||
|
|
||||||
// Wait for the message to reach its destination
|
// Wait for the message to reach its destination
|
||||||
_, err = WaitOnMessengerResponse(
|
_, err = WaitOnMessengerResponse(
|
||||||
|
|
Loading…
Reference in New Issue