fix: a proper clock set when dispatching saved addresses
This commit is contained in:
parent
e9ff0fbefe
commit
598d58f0d6
|
@ -72,7 +72,7 @@ func (m *Messenger) syncNewSavedAddress(ctx context.Context, savedAddress *walle
|
||||||
Address: savedAddress.Address.Bytes(),
|
Address: savedAddress.Address.Bytes(),
|
||||||
Name: savedAddress.Name,
|
Name: savedAddress.Name,
|
||||||
Removed: savedAddress.Removed,
|
Removed: savedAddress.Removed,
|
||||||
UpdateClock: savedAddress.UpdateClock,
|
UpdateClock: updateClock,
|
||||||
ChainShortNames: savedAddress.ChainShortNames,
|
ChainShortNames: savedAddress.ChainShortNames,
|
||||||
Ens: savedAddress.ENSName,
|
Ens: savedAddress.ENSName,
|
||||||
IsTest: savedAddress.IsTest,
|
IsTest: savedAddress.IsTest,
|
||||||
|
@ -110,7 +110,7 @@ func (m *Messenger) HandleSyncSavedAddress(state *ReceivedMessageState, syncMess
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
} else {
|
||||||
sa := wallet.SavedAddress{
|
sa := wallet.SavedAddress{
|
||||||
Address: address,
|
Address: address,
|
||||||
|
|
|
@ -280,7 +280,6 @@ func (s *MessengerSyncSavedAddressesSuite) testSyncDeletesOfSavedAddressesWithTe
|
||||||
|
|
||||||
savedAddresses, err = s.other.savedAddressesManager.GetSavedAddresses()
|
savedAddresses, err = s.other.savedAddressesManager.GetSavedAddresses()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Equal(1, len(savedAddresses))
|
|
||||||
s.Require().True(haveSameElements([]wallet.SavedAddress{sa2}, savedAddresses, savedAddressDataIsEqual))
|
s.Require().True(haveSameElements([]wallet.SavedAddress{sa2}, savedAddresses, savedAddressDataIsEqual))
|
||||||
|
|
||||||
// Delete saved addresses with test mode = false and sync with the other device
|
// Delete saved addresses with test mode = false and sync with the other device
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type savedAddressMeta struct {
|
type savedAddressMeta struct {
|
||||||
Removed bool
|
|
||||||
UpdateClock uint64 // wall clock used to deconflict concurrent updates
|
UpdateClock uint64 // wall clock used to deconflict concurrent updates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ type SavedAddress struct {
|
||||||
ColorID multiAccCommon.CustomizationColor `json:"colorId"`
|
ColorID multiAccCommon.CustomizationColor `json:"colorId"`
|
||||||
IsTest bool `json:"isTest"`
|
IsTest bool `json:"isTest"`
|
||||||
CreatedAt int64 `json:"createdAt"`
|
CreatedAt int64 `json:"createdAt"`
|
||||||
|
Removed bool `json:"removed"`
|
||||||
savedAddressMeta
|
savedAddressMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@ func TestSavedAddressesMetadata(t *testing.T) {
|
||||||
Address: common.Address{1},
|
Address: common.Address{1},
|
||||||
Name: "Raw",
|
Name: "Raw",
|
||||||
savedAddressMeta: savedAddressMeta{
|
savedAddressMeta: savedAddressMeta{
|
||||||
Removed: false,
|
|
||||||
UpdateClock: 234,
|
UpdateClock: 234,
|
||||||
},
|
},
|
||||||
ChainShortNames: "eth:arb:",
|
ChainShortNames: "eth:arb:",
|
||||||
|
@ -212,8 +211,8 @@ func TestSavedAddressesCleanSoftDeletes(t *testing.T) {
|
||||||
Address: common.Address{byte(i)},
|
Address: common.Address{byte(i)},
|
||||||
Name: "Test" + strconv.Itoa(i),
|
Name: "Test" + strconv.Itoa(i),
|
||||||
ColorID: multiAccCommon.CustomizationColorGreen,
|
ColorID: multiAccCommon.CustomizationColorGreen,
|
||||||
savedAddressMeta: savedAddressMeta{
|
|
||||||
Removed: true,
|
Removed: true,
|
||||||
|
savedAddressMeta: savedAddressMeta{
|
||||||
UpdateClock: uint64(firstTimestamp + i),
|
UpdateClock: uint64(firstTimestamp + i),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -245,9 +244,7 @@ func TestSavedAddressesGet(t *testing.T) {
|
||||||
ENSName: "test.ens.eth",
|
ENSName: "test.ens.eth",
|
||||||
ColorID: multiAccCommon.CustomizationColorGreen,
|
ColorID: multiAccCommon.CustomizationColorGreen,
|
||||||
IsTest: false,
|
IsTest: false,
|
||||||
savedAddressMeta: savedAddressMeta{
|
|
||||||
Removed: true,
|
Removed: true,
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := manager.upsertSavedAddress(sa, nil)
|
err := manager.upsertSavedAddress(sa, nil)
|
||||||
|
|
Loading…
Reference in New Issue