mirror of
https://github.com/status-im/status-go.git
synced 2025-01-10 06:36:32 +00:00
3f19972c8e
* enable custom community store nodes * fix * fix * fix * fix * cleanup * fix * migration * fix * cleanup * fix * cleanup * fix * fix * cleanup * message to update the community storenodes * rename * fix test * wait for availability only if global storenode * fix test * fix typo * sync community storenodes * remove unused * add tests * fix imports * fix todo * unused * pr comments * pr feedback * revert merge deleted * fix lint * fix db and perform ms request * typo * fix log * fix go imports * refactor handle message * cleanup public message * add tests * fix test * cleanup test * fix test * avoid making one file to big to keep codeclimate from complaining * fix lint * revert * Update protocol/storenodes/database.go Co-authored-by: richΛrd <info@richardramos.me> * Update protocol/messenger_mailserver_cycle.go Co-authored-by: richΛrd <info@richardramos.me> * PR comment * fix tx * proto files * pr comment --------- Co-authored-by: richΛrd <info@richardramos.me>
75 lines
1.4 KiB
Go
75 lines
1.4 KiB
Go
package storenodes
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
)
|
|
|
|
var (
|
|
communityID1 = types.HexBytes("community001")
|
|
communityID2 = types.HexBytes("community002")
|
|
)
|
|
|
|
func TestSyncSave(t *testing.T) {
|
|
db, close := setupTestDB(t, communityID1)
|
|
defer close()
|
|
snodes := []Storenode{
|
|
{
|
|
CommunityID: communityID1,
|
|
StorenodeID: "storenode001",
|
|
Name: "My Mailserver",
|
|
Address: "enode://...",
|
|
Fleet: "prod",
|
|
Version: 2,
|
|
},
|
|
}
|
|
|
|
// ========
|
|
// Save
|
|
|
|
err := db.syncSave(communityID1, snodes, 0)
|
|
require.NoError(t, err)
|
|
|
|
dbNodes, err := db.getByCommunityID(communityID1)
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, dbNodes, 1)
|
|
require.ElementsMatch(t, dbNodes, snodes)
|
|
|
|
// ========
|
|
// Update
|
|
|
|
updated := []Storenode{
|
|
{
|
|
CommunityID: communityID1,
|
|
StorenodeID: "storenode001",
|
|
Name: "My Mailserver 2",
|
|
Address: "enode://...",
|
|
Fleet: "prod",
|
|
Version: 2,
|
|
},
|
|
}
|
|
err = db.syncSave(communityID1, updated, 0)
|
|
require.NoError(t, err)
|
|
|
|
dbNodes, err = db.getByCommunityID(communityID1)
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, dbNodes, 1)
|
|
require.ElementsMatch(t, dbNodes, updated)
|
|
|
|
// ========
|
|
// Remove
|
|
|
|
err = db.syncSave(communityID1, []Storenode{}, 0)
|
|
require.NoError(t, err)
|
|
|
|
dbNodes, err = db.getByCommunityID(communityID1)
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, dbNodes, 0)
|
|
}
|