Skip to content

Commit

Permalink
Finalised e2e test for send/receive ii
Browse files Browse the repository at this point in the history
  • Loading branch information
Samyoul committed Sep 21, 2021
1 parent 0b6a7a4 commit ed4b5ab
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 43 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.87.3
0.88.0
50 changes: 25 additions & 25 deletions appdatabase/migrations/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions protocol/common/message_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ func (s *MessageSender) SendPublic(
chatName string,
rawMessage RawMessage,
) ([]byte, error) {
s.logger.Debug("SendPublic fired")
// Set sender
if rawMessage.Sender == nil {
rawMessage.Sender = s.identity
Expand Down Expand Up @@ -444,12 +443,10 @@ func (s *MessageSender) SendPublic(
// notify before dispatching
s.notifyOnScheduledMessage(&rawMessage)

s.logger.Debug("before s.transport.SendPublic")
hash, err := s.transport.SendPublic(ctx, newMessage, chatName)
if err != nil {
return nil, err
}
s.logger.Debug("after s.transport.SendPublic")

sentMessage := &SentMessage{
Spec: messageSpec,
Expand Down
11 changes: 5 additions & 6 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,24 +652,23 @@ func (m *Messenger) publishContactCode() error {
func (m *Messenger) attachChatIdentity(cca *protobuf.ContactCodeAdvertisement) error {
contactCodeTopic := transport.ContactCodeTopic(&m.identity.PublicKey)

m.logger.Debug("before shouldPublishChatIdentity")
shouldPublish, err := m.shouldPublishChatIdentity(contactCodeTopic)
m.logger.Debug("shouldPublishChatIdentity result",
zap.Bool("shouldPublish", shouldPublish),
zap.Error(err))

if err != nil {
return err
}
m.logger.Debug("after shouldPublishChatIdentity",
zap.Bool("shouldPublish", shouldPublish))

if !shouldPublish {
return nil
}

m.logger.Debug("before createChatIdentity")
cca.ChatIdentity, err = m.createChatIdentity(privateChat)
if err != nil {
return err
}
m.logger.Debug("after createChatIdentity")

img, err := m.multiAccounts.GetIdentityImage(m.account.KeyUID, userimage.SmallDimName)
if err != nil {
Expand Down Expand Up @@ -767,7 +766,7 @@ func (m *Messenger) shouldPublishChatIdentity(chatID string) (bool, error) {
return true, nil
}

// TODO if Alice does not add bob as a contact she will not update her contact code with images
// Note: If Alice does not add bob as a contact she will not update her contact code with images
return lp == 0 || time.Now().Unix()-lp > 24*60*60, nil
}

Expand Down
33 changes: 25 additions & 8 deletions protocol/messenger_identity_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,7 @@ func (s *MessengerProfilePictureHandlerSuite) TestE2eSendingReceivingProfilePict
privateChat,
}

// TODO Set option for testing between private and public chat types
// private types need to send and received Contact Code message with attached chat identity
// private types send large and thumbnail image payloads

// TODO see if possible to push each test scenario into a go routine

for _, cc := range chatContexts {
for sn, ss := range profilePicShowSettings {
for vn, vs := range profilePicViewSettings {
Expand Down Expand Up @@ -440,19 +435,41 @@ func (s *MessengerProfilePictureHandlerSuite) TestE2eSendingReceivingProfilePict

s.logger.Debug("checked alice's contact info all good")

// Check Alice's profile picture(s)
// Check that Bob now has Alice's profile picture(s)
switch cc {
case publicChat:
s.Require().Len(contact.Images, 1)
// In public chat context we only need the images.SmallDimName, but also may have the large
s.Require().GreaterOrEqual(len(contact.Images), 1)

// Check if the result matches expectation
smImg, ok := contact.Images[images.SmallDimName]
s.Require().True(ok, "contact images must contain the images.SmallDimName")

for _, ii := range iis {
if ii.Name == images.SmallDimName {
s.Require().Equal(ii.Payload, contact.Images[images.SmallDimName].Payload)
s.Require().Equal(ii.Payload, smImg.Payload)
}
}
case privateChat:
s.Require().Equal(len(contact.Images), 2)
s.logger.Info("private chat chat images", zap.Any("iis", iis))

// Check if the result matches expectation
smImg, ok := contact.Images[images.SmallDimName]
s.Require().True(ok, "contact images must contain the images.SmallDimName")

lgImg, ok := contact.Images[images.LargeDimName]
s.Require().True(ok, "contact images must contain the images.LargeDimName")

for _, ii := range iis {
switch ii.Name{
case images.SmallDimName:
s.Require().Equal(ii.Payload, smImg.Payload)
case images.LargeDimName:
s.Require().Equal(ii.Payload, lgImg.Payload)
}
}

}

s.logger.Info("Completed testing with criteria:",
Expand Down

0 comments on commit ed4b5ab

Please sign in to comment.