-
Notifications
You must be signed in to change notification settings - Fork 249
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
feat(onboarding)_: add a notification when importing old account #6255
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,160 @@ func (s *MessengerBackupSuite) TestBackupProfileWithInvalidDisplayName() { | |
s.Require().Equal("", storedBob1DisplayName) | ||
} | ||
|
||
func (s *MessengerBackupSuite) TestFetchingDuringBackup() { | ||
bob1 := s.m | ||
bob1.config.messengerSignalsHandler = &MessengerSignalsHandlerMock{} | ||
|
||
state := ReceivedMessageState{ | ||
Response: &MessengerResponse{}, | ||
} | ||
|
||
backup := &protobuf.Backup{ | ||
Clock: 1, | ||
ContactsDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
CommunitiesDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
ProfileDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
} | ||
|
||
err := bob1.HandleBackup( | ||
&state, | ||
backup, | ||
&v1protocol.StatusMessage{}, | ||
) | ||
s.Require().NoError(err) | ||
// The backup is not done, so no signal should be sent | ||
s.Require().Len(state.Response.ActivityCenterNotifications(), 0) | ||
s.Require().Len(bob1.backedUpFetchingStatus.dataProgress, 3) | ||
s.Require().Equal(uint32(1), bob1.backedUpFetchingStatus.dataProgress[SyncWakuSectionKeyContacts].TotalNumber) | ||
|
||
// Parse a backup with a higher clock so reset the fetching | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering what will happen if the previous backup has completed before the next one kicks in? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. I think in theory, it would mark the whole fetching as completed, so a false positive. The old Nim logic had a minimum of 30 seconds before letting the user go to the next page, even if it said it received all data. Maybe I should add that sort of timer too? Or maybe it doesn't matter, because the data will still get processed when the new backup comes in. Though the user would have a false sense of it being completed, so they could close the app too early. |
||
backup = &protobuf.Backup{ | ||
Clock: 2, | ||
ContactsDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(2), | ||
}, | ||
CommunitiesDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
ProfileDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
SettingsDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
KeypairDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
WatchOnlyAccountDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
} | ||
err = bob1.HandleBackup( | ||
&state, | ||
backup, | ||
&v1protocol.StatusMessage{}, | ||
) | ||
s.Require().NoError(err) | ||
// The backup is not done, so no signal should be sent | ||
s.Require().Len(state.Response.ActivityCenterNotifications(), 0) | ||
s.Require().Len(bob1.backedUpFetchingStatus.dataProgress, 6) | ||
s.Require().Equal(uint32(2), bob1.backedUpFetchingStatus.dataProgress[SyncWakuSectionKeyContacts].TotalNumber) | ||
|
||
// Backup with a smaller clock is ignored | ||
backup = &protobuf.Backup{ | ||
Clock: 2, | ||
ContactsDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(5), | ||
}, | ||
CommunitiesDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(0), | ||
TotalNumber: uint32(1), | ||
}, | ||
} | ||
err = bob1.HandleBackup( | ||
&state, | ||
backup, | ||
&v1protocol.StatusMessage{}, | ||
) | ||
s.Require().NoError(err) | ||
// The backup is not done, so no signal should be sent | ||
s.Require().Len(state.Response.ActivityCenterNotifications(), 0) | ||
// The values are gonna be the same as before as the backup was ignored | ||
s.Require().Len(bob1.backedUpFetchingStatus.dataProgress, 6) | ||
s.Require().Equal(uint32(2), bob1.backedUpFetchingStatus.dataProgress[SyncWakuSectionKeyContacts].TotalNumber) | ||
|
||
// Parse the backup with almost all the correct data numbers | ||
backup = &protobuf.Backup{ | ||
Clock: 2, | ||
ContactsDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(1), | ||
TotalNumber: uint32(2), | ||
}, | ||
CommunitiesDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(1), | ||
TotalNumber: uint32(1), | ||
}, | ||
ProfileDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(1), | ||
TotalNumber: uint32(1), | ||
}, | ||
SettingsDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(1), | ||
TotalNumber: uint32(1), | ||
}, | ||
KeypairDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(1), | ||
TotalNumber: uint32(1), | ||
}, | ||
WatchOnlyAccountDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(1), | ||
TotalNumber: uint32(1), | ||
}, | ||
} | ||
err = bob1.HandleBackup( | ||
&state, | ||
backup, | ||
&v1protocol.StatusMessage{}, | ||
) | ||
s.Require().NoError(err) | ||
// The backup is not done, so no signal should be sent | ||
s.Require().Len(state.Response.ActivityCenterNotifications(), 0) | ||
|
||
// Parse the remaining backup so the notification should be sent now | ||
backup = &protobuf.Backup{ | ||
Clock: 2, | ||
ContactsDetails: &protobuf.FetchingBackedUpDataDetails{ | ||
DataNumber: uint32(2), | ||
TotalNumber: uint32(2), | ||
}, | ||
} | ||
err = bob1.HandleBackup( | ||
&state, | ||
backup, | ||
&v1protocol.StatusMessage{}, | ||
) | ||
s.Require().NoError(err) | ||
// The backup is done, so the signal should be sent | ||
s.Require().Len(state.Response.ActivityCenterNotifications(), 1) | ||
jrainville marked this conversation as resolved.
Show resolved
Hide resolved
|
||
s.Require().Equal(ActivityCenterNotificationTypeBackupSyncingSuccess, state.Response.ActivityCenterNotifications()[0].Type) | ||
} | ||
|
||
func (s *MessengerBackupSuite) TestBackupSettings() { | ||
s.T().Skip("flaky test") | ||
const ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, there should be no timeout.
Backup fetching is done with a store node request(s). We know if any data was found, and we know if there was a timeout fetching, which id defined on the store node request level.
Do you think we can take that out here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good idea. I'm not sure how to hook to that though. I don't think we specifically call "fetchAllBackups". We seem to only set
processBackedupMessages
which tells the Messenger to handle those backup messages.I'm not sure where we do the call to fetch all those backup messages. In theory, we should call that only on restore, but I don't see it using the
fetchBackup
flag, so maybe we have a small issue?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah now when I think of this, there's probably no simple way to do it in current architecture...