Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix_: sync fallback notification #5888

Merged
merged 4 commits into from
Oct 7, 2024
Merged

Conversation

qfrank
Copy link
Contributor

@qfrank qfrank commented Sep 30, 2024

This PR already contains the changes made in PR 5869, because these two PRs have some intersections. To make things simple, let's just use this PR instead.

This PR mainly focuses on solving mobile issue 21260
We should not create/delete the notification if the target is not equal current installation id.

Relate mobile PR 21315

status: ready.

@status-im-auto
Copy link
Member

status-im-auto commented Sep 30, 2024

Jenkins Builds

Click to see older builds (55)
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ 27c8b1c #1 2024-09-30 01:32:59 ~1 min tests 📄log
✔️ 27c8b1c #1 2024-09-30 01:34:39 ~2 min tests-rpc 📄log
✔️ 27c8b1c #1 2024-09-30 01:35:56 ~4 min linux 📦zip
✔️ 27c8b1c #1 2024-09-30 01:36:09 ~4 min ios 📦zip
✔️ 27c8b1c #1 2024-09-30 01:36:31 ~4 min android 📦aar
✔️ 824410e #2 2024-09-30 01:40:33 ~1 min android 📦aar
✔️ 824410e #2 2024-09-30 01:40:49 ~1 min tests-rpc 📄log
✔️ 824410e #2 2024-09-30 01:41:06 ~1 min linux 📦zip
✔️ 824410e #2 2024-09-30 01:41:55 ~2 min ios 📦zip
✔️ 824410e #2 2024-09-30 02:11:23 ~32 min tests 📄log
✔️ 364eef7 #3 2024-09-30 23:53:10 ~2 min android 📦aar
✔️ 364eef7 #3 2024-09-30 23:53:55 ~2 min tests-rpc 📄log
✔️ 364eef7 #3 2024-09-30 23:54:21 ~3 min ios 📦zip
✔️ 364eef7 #3 2024-09-30 23:55:19 ~4 min linux 📦zip
✔️ 364eef7 #3 2024-10-01 00:22:42 ~31 min tests 📄log
✔️ 87494df #4 2024-10-01 01:01:35 ~2 min android 📦aar
✔️ 87494df #4 2024-10-01 01:01:54 ~2 min linux 📦zip
✔️ 87494df #4 2024-10-01 01:02:04 ~2 min tests-rpc 📄log
✔️ 87494df #4 2024-10-01 01:02:31 ~3 min ios 📦zip
✔️ 87494df #4 2024-10-01 01:31:50 ~32 min tests 📄log
✔️ bb2b1f9 #5 2024-10-02 04:14:52 ~2 min android 📦aar
✔️ bb2b1f9 #5 2024-10-02 04:15:27 ~2 min linux 📦zip
✔️ bb2b1f9 #5 2024-10-02 04:15:27 ~2 min tests-rpc 📄log
✔️ bb2b1f9 #5 2024-10-02 04:15:31 ~2 min ios 📦zip
✔️ bb2b1f9 #5 2024-10-02 04:44:15 ~31 min tests 📄log
✔️ 8ed0af0 #6 2024-10-02 09:44:10 ~1 min android 📦aar
✔️ 8ed0af0 #6 2024-10-02 09:44:33 ~2 min linux 📦zip
✔️ 8ed0af0 #6 2024-10-02 09:44:54 ~2 min ios 📦zip
✔️ 8ed0af0 #6 2024-10-02 09:45:12 ~2 min tests-rpc 📄log
✔️ 8ed0af0 #6 2024-10-02 10:13:43 ~31 min tests 📄log
✔️ 39e379d #7 2024-10-02 11:17:43 ~1 min android 📦aar
✔️ 39e379d #7 2024-10-02 11:18:17 ~1 min linux 📦zip
✔️ 39e379d #7 2024-10-02 11:19:23 ~3 min tests-rpc 📄log
✔️ 39e379d #7 2024-10-02 11:20:52 ~4 min ios 📦zip
✔️ 39e379d #7 2024-10-02 11:47:25 ~31 min tests 📄log
✔️ bad68b6 #8 2024-10-03 14:24:24 ~2 min android 📦aar
✔️ bad68b6 #8 2024-10-03 14:25:15 ~2 min tests-rpc 📄log
✔️ bad68b6 #8 2024-10-03 14:25:39 ~3 min ios 📦zip
✔️ bad68b6 #8 2024-10-03 14:26:34 ~4 min linux 📦zip
✔️ bad68b6 #8 2024-10-03 14:53:51 ~31 min tests 📄log
✔️ 0056e30 #9 2024-10-03 23:19:07 ~1 min android 📦aar
✔️ 0056e30 #9 2024-10-03 23:19:56 ~2 min linux 📦zip
✔️ 0056e30 #9 2024-10-03 23:20:34 ~2 min ios 📦zip
✔️ 0056e30 #9 2024-10-03 23:20:35 ~2 min tests-rpc 📄log
✔️ 0056e30 #9 2024-10-03 23:49:03 ~31 min tests 📄log
✖️ 0263fb7 #10 2024-10-05 01:21:58 ~1 min tests 📄log
✔️ 0263fb7 #10 2024-10-05 01:23:03 ~2 min android 📦aar
✔️ 0263fb7 #10 2024-10-05 01:23:20 ~2 min linux 📦zip
✔️ 0263fb7 #10 2024-10-05 01:24:05 ~3 min tests-rpc 📄log
✔️ 0263fb7 #10 2024-10-05 01:25:05 ~4 min ios 📦zip
✖️ 12691fd #11 2024-10-07 06:01:53 ~1 min tests 📄log
✔️ 12691fd #11 2024-10-07 06:02:21 ~1 min android 📦aar
✔️ 12691fd #11 2024-10-07 06:03:39 ~3 min ios 📦zip
✔️ 12691fd #11 2024-10-07 06:04:10 ~3 min tests-rpc 📄log
✔️ 12691fd #11 2024-10-07 06:04:46 ~4 min linux 📦zip
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ fcb02de #12 2024-10-07 06:07:46 ~1 min tests 📄log
✔️ fcb02de #12 2024-10-07 06:08:07 ~1 min android 📦aar
✔️ fcb02de #12 2024-10-07 06:08:13 ~1 min tests-rpc 📄log
✔️ fcb02de #12 2024-10-07 06:08:47 ~2 min linux 📦zip
✔️ fcb02de #12 2024-10-07 06:12:56 ~6 min ios 📦zip
✔️ 8d38952 #13 2024-10-07 13:24:03 ~2 min android 📦aar
✔️ 8d38952 #13 2024-10-07 13:24:26 ~2 min linux 📦zip
✔️ 8d38952 #13 2024-10-07 13:25:24 ~3 min tests-rpc 📄log
✔️ 8d38952 #13 2024-10-07 13:26:18 ~4 min ios 📦zip
✔️ 8d38952 #13 2024-10-07 13:54:17 ~32 min tests 📄log

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 73.33333% with 16 lines in your changes missing coverage. Please review.

Project coverage is 47.45%. Comparing base (ba37c32) to head (8d38952).
Report is 4 commits behind head on develop.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
protocol/messenger_pairing_and_syncing.go 77.77% 3 Missing and 3 partials ⚠️
protocol/messenger.go 75.00% 3 Missing and 2 partials ⚠️
services/ext/api.go 0.00% 3 Missing ⚠️
services/ext/service.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5888      +/-   ##
===========================================
- Coverage    47.79%   47.45%   -0.35%     
===========================================
  Files          834      833       -1     
  Lines       137749   137792      +43     
===========================================
- Hits         65843    65394     -449     
- Misses       64308    64624     +316     
- Partials      7598     7774     +176     
Flag Coverage Δ
functional 10.34% <1.66%> (+0.12%) ⬆️
unit 46.75% <73.33%> (-0.33%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
protocol/messenger_handler.go 59.31% <100.00%> (-0.22%) ⬇️
protocol/messenger_sync_raw_messages.go 30.50% <100.00%> (ø)
protocol/messenger_testing_utils.go 60.37% <100.00%> (-0.63%) ⬇️
protocol/requests/enable_installation_and_pair.go 66.66% <100.00%> (+16.66%) ⬆️
server/pairing/raw_message_handler.go 62.36% <100.00%> (ø)
services/ext/service.go 20.39% <0.00%> (-0.05%) ⬇️
services/ext/api.go 6.27% <0.00%> (-0.01%) ⬇️
protocol/messenger.go 62.16% <75.00%> (-1.33%) ⬇️
protocol/messenger_pairing_and_syncing.go 59.00% <77.77%> (-0.12%) ⬇️

... and 72 files with indirect coverage changes

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some small comments

cmd/statusd/server/endpoints.go Outdated Show resolved Hide resolved
protocol/messenger.go Outdated Show resolved Hide resolved
protocol/messenger_handler.go Outdated Show resolved Hide resolved
Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing my review because I just tested this branch and I no longer get any AC notification on both my apps.

Unless I need to modify my code in the Desktop app, but I doubt it since you just changed the way the AC notifs are triggered.

Here is an example, I synced the left app to the right one, so notifs of both:
image

@qfrank
Copy link
Contributor Author

qfrank commented Sep 30, 2024

because I just tested this branch and I no longer get any AC notification on both my apps.

thanks for reviewing! that's weird, you can see mobile QA test result, also the tests in messenger_pairing_and_syncing_test.go works, also I can receive the AC notifications(ActivityCenterNotificationTypeNewInstallationReceived/ActivityCenterNotificationTypeNewInstallationCreated) when testing on local mobile simulators, is there any chance that it's because your network issue or the message reliability issue? could you double check? 🤔 @jrainville

@qfrank qfrank force-pushed the fix/sync_fallback_notification2 branch from 364eef7 to 87494df Compare October 1, 2024 00:59
@status-im-auto
Copy link
Member

✔️ status-go/prs/android/PR-5888#4 🔹 ~2 min 40 sec 🔹 87494df 🔹 📦 android package

@igor-sirotin igor-sirotin changed the title Fix/sync fallback notification fix_: sync fallback notification Oct 1, 2024
@jrainville
Copy link
Member

because I just tested this branch and I no longer get any AC notification on both my apps.

thanks for reviewing! that's weird, you can see mobile QA test result, also the tests in messenger_pairing_and_syncing_test.go works, also I can receive the AC notifications(ActivityCenterNotificationTypeNewInstallationReceived/ActivityCenterNotificationTypeNewInstallationCreated) when testing on local mobile simulators, is there any chance that it's because your network issue or the message reliability issue? could you double check? 🤔 @jrainville

Ah! I know what happened. When I tested your branch, I still had an issue in my own branch.

I'll test your branch again now that I fixed my own issue.

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good. I retested with my fixed branch and your changes work fine.

I also tested by re-importing a new one just with the seed phrase and it didn't get the AC notification 👍

@@ -8,6 +8,9 @@ var ErrEnableInstallationAndPairInvalidID = errors.New("enable installation and

type EnableInstallationAndPair struct {
InstallationID string `json:"installationId"`

// used for testing
getInstallationID func() string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I like the simplicity, I don't think it's a good approach. Production code should not contain test things.

I think it should be feasible to unit-test saveDataAndPrepareResponse directly, by passing request with specific installationID, can you please try?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you find it not possible to unit-test, then we should go the proper mock way.

  1. Keep EnableInstallationAndPair as before, no custom callback properties
  2. Define EnableInstallationAndPairInterface interface with GetInstallationID method
  3. Implement func (r *EnableInstallationAndPair) GetInstallationID()
  4. Change EnableInstallationAndPair signature to take EnableInstallationAndPairInterface.
  5. Use gomock to generate a mock in tests
  6. Use the generated mocks in test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production code should not contain test things.

Make sense!

unit-test saveDataAndPrepareResponse directly

I don't think it's a good idea to write unit test for saveDataAndPrepareResponse, saveDataAndPrepareResponse is a bit complicated and composed, it's not that pure, unit test and integration test have different purpose and different usage scenarios

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you find it not possible to unit-test, then we should go the proper mock way.

  1. Keep EnableInstallationAndPair as before, no custom callback properties
  2. Define EnableInstallationAndPairInterface interface with GetInstallationID method
  3. Implement func (r *EnableInstallationAndPair) GetInstallationID()
  4. Change EnableInstallationAndPair signature to take EnableInstallationAndPairInterface.
  5. Use gomock to generate a mock in tests
  6. Use the generated mocks in test

created interface InstallationIDProvider

Copy link
Collaborator

@igor-sirotin igor-sirotin Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saveDataAndPrepareResponse is a bit complicated and composed

On the opposite, this is a very good reason for unit-testing 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's easier for writing integration test as there already exist some cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I didn't say it's gonna be easier 😄
But in the future we should try hard to write more unit tests than integration tests.

Copy link
Contributor Author

@qfrank qfrank Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in the future we should try hard to write more unit tests than integration tests.

is it because the long time we need to wait for test result? if yes, I feel a little sad 😭 Maybe we should try other solution

protocol/protobuf/pairing.proto Show resolved Hide resolved
protocol/messenger_pairing_and_syncing_test.go Outdated Show resolved Hide resolved
protocol/messenger_pairing_and_syncing_test.go Outdated Show resolved Hide resolved
@status-im-auto
Copy link
Member

✔️ status-go/prs/android/PR-5888#5 🔹 ~2 min 55 sec 🔹 bb2b1f9 🔹 📦 android package

Copy link
Collaborator

@igor-sirotin igor-sirotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addressed comments!

protocol/requests/enable_installation_and_pair.go Outdated Show resolved Hide resolved
protocol/messenger_pairing_and_syncing_test.go Outdated Show resolved Hide resolved
@status-im-auto
Copy link
Member

✔️ status-go/prs/android/PR-5888#9 🔹 ~2 min 0 sec 🔹 0056e30 🔹 📦 android package

@status-im-auto
Copy link
Member

✔️ status-go/prs/tests/PR-5888#9 🔹 ~31 min 🔹 0056e30 🔹 📦 tests package

@qfrank qfrank force-pushed the fix/sync_fallback_notification2 branch 3 times, most recently from 12691fd to fcb02de Compare October 7, 2024 06:06
…ionV2

- Refactor EnableInstallationAndSync for better error handling and response merging
- Add new EnableInstallationV2 method returning the installation
- Update tests to check for installation in response
- Deprecate old EnableInstallation method
…nID match

- Add targetInstallationID parameter to SendPairInstallation function
- Update protobuf SyncPairInstallation struct with TargetInstallationId field
- Modify method calls across multiple test files to include new parameter
- Update pairing.proto and pairing.pb.go with new field for local pairing
chore_: move InstallationIDProvider

chore_: revert endpoints.go

test_: check AC with resp

chore_: rename ModifiedInstallationsTargetedToThisDevice

test_: add InstallationIDProvider

chore_: revert endpoints.go

chore_: remove comment

test_: add TestNewInstallationCreatedIsNotDeleted
@qfrank qfrank force-pushed the fix/sync_fallback_notification2 branch from fcb02de to 8d38952 Compare October 7, 2024 13:21
@qfrank qfrank merged commit a08319f into develop Oct 7, 2024
20 of 24 checks passed
@qfrank qfrank deleted the fix/sync_fallback_notification2 branch October 7, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants