2021-09-10 18:08:22 +00:00
|
|
|
package wallet
|
|
|
|
|
|
|
|
import (
|
2022-09-14 10:46:11 +00:00
|
|
|
"strconv"
|
2021-09-10 18:08:22 +00:00
|
|
|
"testing"
|
2023-03-06 13:26:46 +00:00
|
|
|
"time"
|
2021-09-10 18:08:22 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2023-12-27 14:59:06 +00:00
|
|
|
multiAccCommon "github.com/status-im/status-go/multiaccounts/common"
|
2023-08-11 11:28:45 +00:00
|
|
|
"github.com/status-im/status-go/t/helpers"
|
|
|
|
"github.com/status-im/status-go/walletdatabase"
|
2021-09-10 18:08:22 +00:00
|
|
|
)
|
|
|
|
|
2023-03-06 13:26:46 +00:00
|
|
|
const (
|
|
|
|
ensMember int = iota
|
|
|
|
isTestMember
|
|
|
|
addressMember
|
|
|
|
)
|
|
|
|
|
2021-09-10 18:08:22 +00:00
|
|
|
func setupTestSavedAddressesDB(t *testing.T) (*SavedAddressesManager, func()) {
|
2023-08-11 11:28:45 +00:00
|
|
|
db, err := helpers.SetupTestMemorySQLDB(walletdatabase.DbInitializer{})
|
2021-09-10 18:08:22 +00:00
|
|
|
require.NoError(t, err)
|
2023-03-06 13:26:46 +00:00
|
|
|
|
2021-09-10 18:08:22 +00:00
|
|
|
return &SavedAddressesManager{db}, func() {
|
|
|
|
require.NoError(t, db.Close())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-06 13:26:46 +00:00
|
|
|
func TestSavedAddressesAdd(t *testing.T) {
|
2021-09-10 18:08:22 +00:00
|
|
|
manager, stop := setupTestSavedAddressesDB(t)
|
|
|
|
defer stop()
|
|
|
|
|
2023-03-06 13:26:46 +00:00
|
|
|
rst, err := manager.GetRawSavedAddresses()
|
2021-09-10 18:08:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Nil(t, rst)
|
|
|
|
|
|
|
|
sa := SavedAddress{
|
2023-03-06 13:26:46 +00:00
|
|
|
Address: common.Address{1},
|
|
|
|
Name: "Zilliqa",
|
2024-05-16 14:01:30 +00:00
|
|
|
ChainShortNames: "eth:arb1:",
|
2023-03-06 13:26:46 +00:00
|
|
|
ENSName: "test.stateofus.eth",
|
2023-12-27 14:59:06 +00:00
|
|
|
ColorID: multiAccCommon.CustomizationColorGreen,
|
2023-03-06 13:26:46 +00:00
|
|
|
IsTest: false,
|
2021-09-10 18:08:22 +00:00
|
|
|
}
|
|
|
|
|
2024-02-16 09:45:10 +00:00
|
|
|
err = manager.UpdateMetadataAndUpsertSavedAddress(sa)
|
2021-09-10 18:08:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-03-06 13:26:46 +00:00
|
|
|
rst, err = manager.GetRawSavedAddresses()
|
2021-09-10 18:08:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(rst))
|
2022-09-14 10:46:11 +00:00
|
|
|
require.Equal(t, sa.Address, rst[0].Address)
|
|
|
|
require.Equal(t, sa.Name, rst[0].Name)
|
2023-03-06 13:26:46 +00:00
|
|
|
require.Equal(t, sa.ChainShortNames, rst[0].ChainShortNames)
|
|
|
|
require.Equal(t, sa.ENSName, rst[0].ENSName)
|
2023-12-27 14:59:06 +00:00
|
|
|
require.Equal(t, sa.ColorID, rst[0].ColorID)
|
2023-03-06 13:26:46 +00:00
|
|
|
require.Equal(t, sa.IsTest, rst[0].IsTest)
|
2021-09-10 18:08:22 +00:00
|
|
|
}
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
func contains[T comparable](container []T, element T, isEqual func(T, T) bool) bool {
|
|
|
|
for _, e := range container {
|
|
|
|
if isEqual(e, element) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func haveSameElements[T comparable](a []T, b []T, isEqual func(T, T) bool) bool {
|
|
|
|
for _, v := range a {
|
|
|
|
if !contains(b, v, isEqual) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-02-16 09:45:10 +00:00
|
|
|
func savedAddressDataIsEqual(a, b *SavedAddress) bool {
|
2024-01-09 14:59:54 +00:00
|
|
|
return a.Address == b.Address && a.Name == b.Name && a.ChainShortNames == b.ChainShortNames &&
|
|
|
|
a.ENSName == b.ENSName && a.IsTest == b.IsTest && a.ColorID == b.ColorID
|
2022-09-14 10:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSavedAddressesMetadata(t *testing.T) {
|
|
|
|
manager, stop := setupTestSavedAddressesDB(t)
|
|
|
|
defer stop()
|
|
|
|
|
|
|
|
savedAddresses, err := manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Nil(t, savedAddresses)
|
|
|
|
|
|
|
|
// Add raw saved addresses
|
|
|
|
sa1 := SavedAddress{
|
2024-01-09 14:59:54 +00:00
|
|
|
Address: common.Address{1},
|
|
|
|
Name: "Raw",
|
2022-09-14 10:46:11 +00:00
|
|
|
savedAddressMeta: savedAddressMeta{
|
|
|
|
UpdateClock: 234,
|
|
|
|
},
|
2024-05-16 14:01:30 +00:00
|
|
|
ChainShortNames: "eth:arb1:",
|
2023-03-06 13:26:46 +00:00
|
|
|
ENSName: "test.stateofus.eth",
|
2023-12-27 14:59:06 +00:00
|
|
|
ColorID: multiAccCommon.CustomizationColorGreen,
|
2023-03-06 13:26:46 +00:00
|
|
|
IsTest: false,
|
2022-09-14 10:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = manager.upsertSavedAddress(sa1, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
dbSavedAddresses, err := manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(dbSavedAddresses))
|
2023-03-08 13:43:46 +00:00
|
|
|
require.Equal(t, sa1.Address, dbSavedAddresses[0].Address)
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
// Add simple saved address without sync metadata
|
|
|
|
sa2 := SavedAddress{
|
2024-01-09 14:59:54 +00:00
|
|
|
Address: common.Address{2},
|
|
|
|
Name: "Simple",
|
|
|
|
ColorID: multiAccCommon.CustomizationColorBlue,
|
|
|
|
IsTest: false,
|
2024-02-16 09:45:10 +00:00
|
|
|
savedAddressMeta: savedAddressMeta{
|
|
|
|
UpdateClock: 42,
|
|
|
|
},
|
2022-09-14 10:46:11 +00:00
|
|
|
}
|
|
|
|
|
2024-02-16 09:45:10 +00:00
|
|
|
err = manager.UpdateMetadataAndUpsertSavedAddress(sa2)
|
2022-09-14 10:46:11 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
dbSavedAddresses, err = manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 2, len(dbSavedAddresses))
|
|
|
|
// The order is not guaranteed check raw entry to decide
|
|
|
|
rawIndex := 0
|
|
|
|
simpleIndex := 1
|
2024-02-16 09:45:10 +00:00
|
|
|
if dbSavedAddresses[0].Address == sa1.Address {
|
2022-09-14 10:46:11 +00:00
|
|
|
rawIndex = 1
|
|
|
|
simpleIndex = 0
|
|
|
|
}
|
2023-03-08 13:43:46 +00:00
|
|
|
require.Equal(t, sa1.Address, dbSavedAddresses[simpleIndex].Address)
|
|
|
|
require.Equal(t, sa2.Address, dbSavedAddresses[rawIndex].Address)
|
|
|
|
require.Equal(t, sa2.Name, dbSavedAddresses[rawIndex].Name)
|
2023-12-27 14:59:06 +00:00
|
|
|
require.Equal(t, sa2.ColorID, dbSavedAddresses[rawIndex].ColorID)
|
2023-03-08 13:43:46 +00:00
|
|
|
require.Equal(t, sa2.IsTest, dbSavedAddresses[rawIndex].IsTest)
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
// Check the default values
|
2023-03-08 13:43:46 +00:00
|
|
|
require.False(t, dbSavedAddresses[rawIndex].Removed)
|
2024-02-16 09:45:10 +00:00
|
|
|
require.Equal(t, dbSavedAddresses[rawIndex].UpdateClock, sa2.UpdateClock)
|
2023-03-08 13:43:46 +00:00
|
|
|
require.Greater(t, dbSavedAddresses[rawIndex].UpdateClock, uint64(0))
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
sa2Older := sa2
|
2023-03-06 13:26:46 +00:00
|
|
|
sa2Older.IsTest = false
|
2024-02-16 09:45:10 +00:00
|
|
|
sa2Older.UpdateClock = dbSavedAddresses[rawIndex].UpdateClock - 1
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
sa2Newer := sa2
|
2023-03-06 13:26:46 +00:00
|
|
|
sa2Newer.IsTest = false
|
2024-02-16 09:45:10 +00:00
|
|
|
sa2Newer.UpdateClock = dbSavedAddresses[rawIndex].UpdateClock + 1
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
// Try to add an older entry
|
|
|
|
updated := false
|
2024-02-16 09:45:10 +00:00
|
|
|
updated, err = manager.AddSavedAddressIfNewerUpdate(sa2Older)
|
2022-09-14 10:46:11 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, updated)
|
|
|
|
|
|
|
|
dbSavedAddresses, err = manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
rawIndex = 0
|
|
|
|
simpleIndex = 1
|
2024-02-16 09:45:10 +00:00
|
|
|
if dbSavedAddresses[0].Address == sa1.Address {
|
2022-09-14 10:46:11 +00:00
|
|
|
rawIndex = 1
|
|
|
|
simpleIndex = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
require.Equal(t, 2, len(dbSavedAddresses))
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, haveSameElements([]*SavedAddress{&sa1, &sa2}, dbSavedAddresses, savedAddressDataIsEqual))
|
2023-03-08 13:43:46 +00:00
|
|
|
require.Equal(t, sa1.savedAddressMeta, dbSavedAddresses[simpleIndex].savedAddressMeta)
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
// Try to update sa2 with a newer entry
|
2023-03-08 13:43:46 +00:00
|
|
|
updatedClock := dbSavedAddresses[rawIndex].UpdateClock + 1
|
2024-02-16 09:45:10 +00:00
|
|
|
updated, err = manager.AddSavedAddressIfNewerUpdate(sa2Newer)
|
2022-09-14 10:46:11 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, updated)
|
|
|
|
|
|
|
|
dbSavedAddresses, err = manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.Equal(t, 2, len(dbSavedAddresses))
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, haveSameElements([]*SavedAddress{&sa1, &sa2Newer}, dbSavedAddresses, savedAddressDataIsEqual))
|
2023-03-08 13:43:46 +00:00
|
|
|
require.Equal(t, updatedClock, dbSavedAddresses[rawIndex].UpdateClock)
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
// Try to delete the sa2 newer entry
|
|
|
|
updatedDeleteClock := updatedClock + 1
|
2024-01-09 14:59:54 +00:00
|
|
|
updated, err = manager.DeleteSavedAddress(sa2Newer.Address, sa2Newer.IsTest, updatedDeleteClock)
|
2022-09-14 10:46:11 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, updated)
|
|
|
|
|
|
|
|
dbSavedAddresses, err = manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.Equal(t, 2, len(dbSavedAddresses))
|
2023-03-08 13:43:46 +00:00
|
|
|
require.True(t, dbSavedAddresses[rawIndex].Removed)
|
2022-09-14 10:46:11 +00:00
|
|
|
|
|
|
|
// Check that deleted entry is not returned with the regular API (non-raw)
|
|
|
|
dbSavedAddresses, err = manager.GetSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(dbSavedAddresses))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSavedAddressesCleanSoftDeletes(t *testing.T) {
|
|
|
|
manager, stop := setupTestSavedAddressesDB(t)
|
|
|
|
defer stop()
|
|
|
|
|
|
|
|
firstTimestamp := 10
|
|
|
|
for i := 0; i < 5; i++ {
|
|
|
|
sa := SavedAddress{
|
2024-01-09 14:59:54 +00:00
|
|
|
Address: common.Address{byte(i)},
|
|
|
|
Name: "Test" + strconv.Itoa(i),
|
|
|
|
ColorID: multiAccCommon.CustomizationColorGreen,
|
2024-02-12 15:51:56 +00:00
|
|
|
Removed: true,
|
2022-09-14 10:46:11 +00:00
|
|
|
savedAddressMeta: savedAddressMeta{
|
|
|
|
UpdateClock: uint64(firstTimestamp + i),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
err := manager.upsertSavedAddress(sa, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := manager.DeleteSoftRemovedSavedAddresses(uint64(firstTimestamp + 3))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
dbSavedAddresses, err := manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 2, len(dbSavedAddresses))
|
|
|
|
require.True(t, haveSameElements([]uint64{dbSavedAddresses[0].UpdateClock,
|
|
|
|
dbSavedAddresses[1].UpdateClock}, []uint64{uint64(firstTimestamp + 3), uint64(firstTimestamp + 4)},
|
|
|
|
func(a, b uint64) bool {
|
|
|
|
return a == b
|
|
|
|
},
|
|
|
|
))
|
|
|
|
}
|
2023-03-06 13:26:46 +00:00
|
|
|
|
|
|
|
func TestSavedAddressesGet(t *testing.T) {
|
|
|
|
manager, stop := setupTestSavedAddressesDB(t)
|
|
|
|
defer stop()
|
|
|
|
|
|
|
|
sa := SavedAddress{
|
|
|
|
Address: common.Address{1},
|
|
|
|
ENSName: "test.ens.eth",
|
2023-12-27 14:59:06 +00:00
|
|
|
ColorID: multiAccCommon.CustomizationColorGreen,
|
2023-03-06 13:26:46 +00:00
|
|
|
IsTest: false,
|
2024-02-12 15:51:56 +00:00
|
|
|
Removed: true,
|
2023-03-06 13:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err := manager.upsertSavedAddress(sa, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
dbSavedAddresses, err := manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(dbSavedAddresses))
|
|
|
|
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, savedAddressDataIsEqual(&sa, dbSavedAddresses[0]))
|
2023-03-06 13:26:46 +00:00
|
|
|
|
|
|
|
dbSavedAddresses, err = manager.GetSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 0, len(dbSavedAddresses))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSavedAddressesDelete(t *testing.T) {
|
|
|
|
manager, stop := setupTestSavedAddressesDB(t)
|
|
|
|
defer stop()
|
|
|
|
|
|
|
|
sa0 := SavedAddress{
|
|
|
|
Address: common.Address{1},
|
|
|
|
IsTest: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := manager.upsertSavedAddress(sa0, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
rst, err := manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(rst))
|
|
|
|
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, savedAddressDataIsEqual(&sa0, rst[0]))
|
2023-03-06 13:26:46 +00:00
|
|
|
|
|
|
|
// Modify IsTest flag, insert
|
|
|
|
sa1 := sa0
|
|
|
|
sa1.IsTest = !sa1.IsTest
|
|
|
|
|
|
|
|
err = manager.upsertSavedAddress(sa1, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Delete s0, test that only s1 is left
|
|
|
|
updateClock := uint64(time.Now().Unix())
|
2024-01-09 14:59:54 +00:00
|
|
|
_, err = manager.DeleteSavedAddress(sa0.Address, sa0.IsTest, updateClock)
|
2023-03-06 13:26:46 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
rst, err = manager.GetSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(rst))
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, savedAddressDataIsEqual(&sa1, rst[0]))
|
2023-03-06 13:26:46 +00:00
|
|
|
|
|
|
|
// Test that we still have both addresses
|
|
|
|
rst, err = manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 2, len(rst))
|
|
|
|
|
|
|
|
// Delete s0 one more time with the same timestamp
|
2024-01-09 14:59:54 +00:00
|
|
|
deleted, err := manager.DeleteSavedAddress(sa0.Address, sa0.IsTest, updateClock)
|
2023-03-06 13:26:46 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, deleted)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testInsertSameAddressWithOneChange(t *testing.T, member int) {
|
|
|
|
manager, stop := setupTestSavedAddressesDB(t)
|
|
|
|
defer stop()
|
|
|
|
|
|
|
|
// Insert one address
|
|
|
|
sa := SavedAddress{
|
|
|
|
Address: common.Address{1},
|
|
|
|
ENSName: "test.ens.eth",
|
|
|
|
IsTest: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := manager.upsertSavedAddress(sa, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
rst, err := manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(rst))
|
|
|
|
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, savedAddressDataIsEqual(&sa, rst[0]))
|
2023-03-06 13:26:46 +00:00
|
|
|
|
|
|
|
sa2 := sa
|
|
|
|
|
|
|
|
if member == isTestMember {
|
|
|
|
sa2.IsTest = !sa2.IsTest
|
|
|
|
} else if member == addressMember {
|
|
|
|
sa2.Address = common.Address{7}
|
|
|
|
} else if member == ensMember {
|
|
|
|
sa2.ENSName += "_"
|
|
|
|
} else {
|
|
|
|
t.Error("Unsupported member change. Please add it to the list")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = manager.upsertSavedAddress(sa2, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
rst, err = manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 2, len(rst))
|
|
|
|
|
|
|
|
// The order of records returned by GetRawSavedAddresses is not
|
|
|
|
// guaranteed to be the same as insertions, so swap indices if first record does not match
|
|
|
|
firstIndex := 0
|
|
|
|
secondIndex := 1
|
2024-02-16 09:45:10 +00:00
|
|
|
if rst[firstIndex].Address == sa.Address {
|
2023-03-06 13:26:46 +00:00
|
|
|
firstIndex = 1
|
|
|
|
secondIndex = 0
|
|
|
|
}
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, savedAddressDataIsEqual(&sa, rst[firstIndex]))
|
|
|
|
require.True(t, savedAddressDataIsEqual(&sa2, rst[secondIndex]))
|
2023-03-06 13:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSavedAddressesAddDifferentIsTest(t *testing.T) {
|
|
|
|
testInsertSameAddressWithOneChange(t, isTestMember)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSavedAddressesAddSame(t *testing.T) {
|
|
|
|
manager, stop := setupTestSavedAddressesDB(t)
|
|
|
|
defer stop()
|
|
|
|
|
|
|
|
// Insert one address
|
|
|
|
sa := SavedAddress{
|
|
|
|
Address: common.Address{1},
|
|
|
|
ENSName: "test.ens.eth",
|
|
|
|
IsTest: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := manager.upsertSavedAddress(sa, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
rst, err := manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(rst))
|
|
|
|
|
2024-02-16 09:45:10 +00:00
|
|
|
require.True(t, savedAddressDataIsEqual(&sa, rst[0]))
|
2023-03-06 13:26:46 +00:00
|
|
|
|
|
|
|
sa2 := sa
|
|
|
|
err = manager.upsertSavedAddress(sa2, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
rst, err = manager.GetRawSavedAddresses()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 1, len(rst))
|
|
|
|
}
|