fix: a proper clock set when dispatching saved addresses

This commit is contained in:
Sale Djenic 2024-02-12 16:51:56 +01:00 committed by saledjenic
parent e9ff0fbefe
commit 598d58f0d6
4 changed files with 5 additions and 9 deletions

View File

@ -72,7 +72,7 @@ func (m *Messenger) syncNewSavedAddress(ctx context.Context, savedAddress *walle
Address: savedAddress.Address.Bytes(),
Name: savedAddress.Name,
Removed: savedAddress.Removed,
UpdateClock: savedAddress.UpdateClock,
UpdateClock: updateClock,
ChainShortNames: savedAddress.ChainShortNames,
Ens: savedAddress.ENSName,
IsTest: savedAddress.IsTest,
@ -110,7 +110,7 @@ func (m *Messenger) HandleSyncSavedAddress(state *ReceivedMessageState, syncMess
if err != nil {
return err
}
state.Response.AddSavedAddress(&wallet.SavedAddress{Address: address, ENSName: syncMessage.Ens, IsTest: syncMessage.IsTest})
state.Response.AddSavedAddress(&wallet.SavedAddress{Address: address, ENSName: syncMessage.Ens, IsTest: syncMessage.IsTest, Removed: true})
} else {
sa := wallet.SavedAddress{
Address: address,

View File

@ -280,7 +280,6 @@ func (s *MessengerSyncSavedAddressesSuite) testSyncDeletesOfSavedAddressesWithTe
savedAddresses, err = s.other.savedAddressesManager.GetSavedAddresses()
s.Require().NoError(err)
s.Require().Equal(1, len(savedAddresses))
s.Require().True(haveSameElements([]wallet.SavedAddress{sa2}, savedAddresses, savedAddressDataIsEqual))
// Delete saved addresses with test mode = false and sync with the other device

View File

@ -10,7 +10,6 @@ import (
)
type savedAddressMeta struct {
Removed bool
UpdateClock uint64 // wall clock used to deconflict concurrent updates
}
@ -24,6 +23,7 @@ type SavedAddress struct {
ColorID multiAccCommon.CustomizationColor `json:"colorId"`
IsTest bool `json:"isTest"`
CreatedAt int64 `json:"createdAt"`
Removed bool `json:"removed"`
savedAddressMeta
}

View File

@ -95,7 +95,6 @@ func TestSavedAddressesMetadata(t *testing.T) {
Address: common.Address{1},
Name: "Raw",
savedAddressMeta: savedAddressMeta{
Removed: false,
UpdateClock: 234,
},
ChainShortNames: "eth:arb:",
@ -212,8 +211,8 @@ func TestSavedAddressesCleanSoftDeletes(t *testing.T) {
Address: common.Address{byte(i)},
Name: "Test" + strconv.Itoa(i),
ColorID: multiAccCommon.CustomizationColorGreen,
Removed: true,
savedAddressMeta: savedAddressMeta{
Removed: true,
UpdateClock: uint64(firstTimestamp + i),
},
}
@ -245,9 +244,7 @@ func TestSavedAddressesGet(t *testing.T) {
ENSName: "test.ens.eth",
ColorID: multiAccCommon.CustomizationColorGreen,
IsTest: false,
savedAddressMeta: savedAddressMeta{
Removed: true,
},
Removed: true,
}
err := manager.upsertSavedAddress(sa, nil)