Skip to content

Commit

Permalink
fix_: addressed review feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
  • Loading branch information
smohamedjavid committed Aug 30, 2024
1 parent 59fd739 commit 71bc099
Showing 3 changed files with 8 additions and 11 deletions.
6 changes: 4 additions & 2 deletions protocol/messenger_backup_test.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
v1protocol "github.com/status-im/status-go/protocol/v1"
"github.com/status-im/status-go/protocol/wakusync"
"github.com/status-im/status-go/services/accounts/accountsevent"
@@ -814,7 +815,8 @@ func (s *MessengerBackupSuite) TestBackupWatchOnlyAccounts() {
s.Require().True(haveSameElements(woAccounts, dbWoAccounts1, accounts.SameAccounts))

// Create bob2
bob2, err := newMessengerWithKey(s.shh, bob1.identity, s.logger, nil)
accountsFeed := &event.Feed{}
bob2, err := newMessengerWithKey(s.shh, bob1.identity, s.logger, []Option{WithAccountsFeed(accountsFeed)})
s.Require().NoError(err)
s.Require().NotNil(bob2.config.accountsFeed)
ch := make(chan accountsevent.Event, 20)
@@ -852,7 +854,7 @@ func (s *MessengerBackupSuite) TestBackupWatchOnlyAccounts() {
case event := <-ch:
switch event.Type {
case accountsevent.EventTypeAdded:
s.Require().Equal(1, len(event.Accounts))
s.Require().Len(event.Accounts, 1)
s.Require().Equal(common.Address(dbWoAccounts2[0].Address), event.Accounts[0])
}
}
5 changes: 0 additions & 5 deletions protocol/messenger_builder_test.go
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@ import (
"github.com/google/uuid"
"go.uber.org/zap"

"github.com/ethereum/go-ethereum/event"

"github.com/status-im/status-go/account/generator"
"github.com/status-im/status-go/appdatabase"
"github.com/status-im/status-go/common/dbsetup"
@@ -75,8 +73,6 @@ func newTestMessenger(waku types.Waku, config testMessengerConfig) (*Messenger,
return nil, err
}

accountsFeed := &event.Feed{}

options := []Option{
WithCustomLogger(config.logger),
WithDatabase(appDb),
@@ -87,7 +83,6 @@ func newTestMessenger(waku types.Waku, config testMessengerConfig) (*Messenger,
WithToplevelDatabaseMigrations(),
WithBrowserDatabase(nil),
WithCuratedCommunitiesUpdateLoop(false),
WithAccountsFeed(accountsFeed),
}
options = append(options, config.extraOptions...)

8 changes: 4 additions & 4 deletions protocol/messenger_handler.go
Original file line number Diff line number Diff line change
@@ -3699,10 +3699,6 @@ func (m *Messenger) handleSyncKeypair(message *protobuf.SyncKeypair, fromLocalPa
for _, acc := range dbKeypair.Accounts {
removedAddresses = append(removedAddresses, gethcommon.Address(acc.Address))
}
m.config.accountsFeed.Send(accountsevent.Event{
Type: accountsevent.EventTypeRemoved,
Accounts: removedAddresses,
})
} else {
for _, acc := range dbKeypair.Accounts {
if acc.Chat {
@@ -3714,10 +3710,14 @@ func (m *Messenger) handleSyncKeypair(message *protobuf.SyncKeypair, fromLocalPa
addedAddresses = append(addedAddresses, gethcommon.Address(acc.Address))
}
}
}
if len(addedAddresses) > 0 {
m.config.accountsFeed.Send(accountsevent.Event{
Type: accountsevent.EventTypeAdded,
Accounts: addedAddresses,
})
}
if len(removedAddresses) > 0 {
m.config.accountsFeed.Send(accountsevent.Event{
Type: accountsevent.EventTypeRemoved,
Accounts: removedAddresses,

0 comments on commit 71bc099

Please sign in to comment.