chore: Common `createOtherDevice` for community_messenger_test (#3874)
This commit is contained in:
parent
1d2b508c20
commit
f0ab8f0be9
|
@ -146,7 +146,7 @@ func (s *MessengerCommunitiesSuite) TestRetrieveCommunity() {
|
||||||
s.Require().Equal(communitySettings.CommunityID, community.IDString())
|
s.Require().Equal(communitySettings.CommunityID, community.IDString())
|
||||||
s.Require().Equal(communitySettings.HistoryArchiveSupportEnabled, false)
|
s.Require().Equal(communitySettings.HistoryArchiveSupportEnabled, false)
|
||||||
|
|
||||||
// Send an community message
|
// Send a community message
|
||||||
chat := CreateOneToOneChat(common.PubkeyToHex(&alice.identity.PublicKey), &alice.identity.PublicKey, s.alice.transport)
|
chat := CreateOneToOneChat(common.PubkeyToHex(&alice.identity.PublicKey), &alice.identity.PublicKey, s.alice.transport)
|
||||||
|
|
||||||
inputMessage := &common.Message{}
|
inputMessage := &common.Message{}
|
||||||
|
@ -253,7 +253,7 @@ func (s *MessengerCommunitiesSuite) TestJoinCommunity() {
|
||||||
chats := community.Chats()
|
chats := community.Chats()
|
||||||
s.Require().Len(chats, 2)
|
s.Require().Len(chats, 2)
|
||||||
|
|
||||||
// Send an community message
|
// Send a community message
|
||||||
chat := CreateOneToOneChat(common.PubkeyToHex(&s.alice.identity.PublicKey), &s.alice.identity.PublicKey, s.bob.transport)
|
chat := CreateOneToOneChat(common.PubkeyToHex(&s.alice.identity.PublicKey), &s.alice.identity.PublicKey, s.bob.transport)
|
||||||
|
|
||||||
inputMessage := &common.Message{}
|
inputMessage := &common.Message{}
|
||||||
|
@ -2103,17 +2103,30 @@ func (s *MessengerCommunitiesSuite) TestBanUser() {
|
||||||
s.Require().False(community.IsBanned(&s.alice.identity.PublicKey))
|
s.Require().False(community.IsBanned(&s.alice.identity.PublicKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MessengerCommunitiesSuite) TestSyncCommunitySettings() {
|
func (s *MessengerCommunitiesSuite) createOtherDevice(m1 *Messenger) *Messenger {
|
||||||
// Create new device
|
m2 := s.newMessengerWithKey(m1.identity)
|
||||||
alicesOtherDevice := s.newMessengerWithKey(s.alice.identity)
|
|
||||||
|
tcs, err := m2.communitiesManager.All()
|
||||||
|
s.Require().NoError(err, "m2.communitiesManager.All")
|
||||||
|
s.Len(tcs, 1, "Must have 1 communities")
|
||||||
|
|
||||||
// Pair devices
|
// Pair devices
|
||||||
err := alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, &multidevice.InstallationMetadata{
|
metadata := &multidevice.InstallationMetadata{
|
||||||
Name: "their-name",
|
Name: "other-device",
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "other-device-type",
|
||||||
})
|
}
|
||||||
|
err = m2.SetInstallationMetadata(m2.installationID, metadata)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
_, err = m2.Start()
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
return m2
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MessengerCommunitiesSuite) TestSyncCommunitySettings() {
|
||||||
|
// Create new device
|
||||||
|
alicesOtherDevice := s.createOtherDevice(s.alice)
|
||||||
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
||||||
|
|
||||||
// Create a community
|
// Create a community
|
||||||
|
@ -2165,15 +2178,7 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunitySettings() {
|
||||||
|
|
||||||
func (s *MessengerCommunitiesSuite) TestSyncCommunitySettings_EditCommunity() {
|
func (s *MessengerCommunitiesSuite) TestSyncCommunitySettings_EditCommunity() {
|
||||||
// Create new device
|
// Create new device
|
||||||
alicesOtherDevice := s.newMessengerWithKey(s.alice.identity)
|
alicesOtherDevice := s.createOtherDevice(s.alice)
|
||||||
|
|
||||||
// Pair devices
|
|
||||||
err := alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, &multidevice.InstallationMetadata{
|
|
||||||
Name: "their-name",
|
|
||||||
DeviceType: "their-device-type",
|
|
||||||
})
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
||||||
|
|
||||||
// Create a community
|
// Create a community
|
||||||
|
@ -2260,20 +2265,9 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunitySettings_EditCommunity() {
|
||||||
|
|
||||||
// TestSyncCommunity tests basic sync functionality between 2 Messengers
|
// TestSyncCommunity tests basic sync functionality between 2 Messengers
|
||||||
func (s *MessengerCommunitiesSuite) TestSyncCommunity() {
|
func (s *MessengerCommunitiesSuite) TestSyncCommunity() {
|
||||||
|
|
||||||
// Create new device
|
// Create new device
|
||||||
alicesOtherDevice := s.newMessengerWithKey(s.alice.identity)
|
alicesOtherDevice := s.createOtherDevice(s.alice)
|
||||||
|
|
||||||
tcs, err := alicesOtherDevice.communitiesManager.All()
|
|
||||||
s.Require().NoError(err, "alicesOtherDevice.communitiesManager.All")
|
|
||||||
s.Len(tcs, 1, "Must have 1 communities")
|
|
||||||
|
|
||||||
// Pair devices
|
|
||||||
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, &multidevice.InstallationMetadata{
|
|
||||||
Name: "their-name",
|
|
||||||
DeviceType: "their-device-type",
|
|
||||||
})
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
||||||
|
|
||||||
// Create a community
|
// Create a community
|
||||||
|
@ -2317,7 +2311,7 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// 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, 2, "There must be 2 communities")
|
||||||
|
|
||||||
|
@ -2362,14 +2356,7 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_RequestToJoin() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Create Alice's other device
|
// Create Alice's other device
|
||||||
alicesOtherDevice := s.newMessengerWithKey(s.alice.identity)
|
alicesOtherDevice := s.createOtherDevice(s.alice)
|
||||||
|
|
||||||
im1 := &multidevice.InstallationMetadata{
|
|
||||||
Name: "alice's-other-device",
|
|
||||||
DeviceType: "alice's-other-device-type",
|
|
||||||
}
|
|
||||||
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Pair alice's two devices
|
// Pair alice's two devices
|
||||||
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
||||||
|
@ -2574,14 +2561,7 @@ func (s *MessengerCommunitiesSuite) TestSyncCommunity_Leave() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Create Alice's other device
|
// Create Alice's other device
|
||||||
alicesOtherDevice := s.newMessengerWithKey(s.alice.identity)
|
alicesOtherDevice := s.createOtherDevice(s.alice)
|
||||||
|
|
||||||
im1 := &multidevice.InstallationMetadata{
|
|
||||||
Name: "alice's-other-device",
|
|
||||||
DeviceType: "alice's-other-device-type",
|
|
||||||
}
|
|
||||||
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Pair alice's two devices
|
// Pair alice's two devices
|
||||||
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
PairDevices(&s.Suite, alicesOtherDevice, s.alice)
|
||||||
|
|
|
@ -915,7 +915,7 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationCommunityReq
|
||||||
s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
community := response.Communities()[0]
|
community := response.Communities()[0]
|
||||||
|
|
||||||
// Send an community message
|
// Send a community message
|
||||||
chat := CreateOneToOneChat(common.PubkeyToHex(&alice.identity.PublicKey), &alice.identity.PublicKey, alice.transport)
|
chat := CreateOneToOneChat(common.PubkeyToHex(&alice.identity.PublicKey), &alice.identity.PublicKey, alice.transport)
|
||||||
|
|
||||||
inputMessage := &common.Message{}
|
inputMessage := &common.Message{}
|
||||||
|
|
Loading…
Reference in New Issue