mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 22:26:30 +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>
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package storenodes
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/status-im/status-go/services/mailservers"
|
|
)
|
|
|
|
func TestUpdateStorenodesInDB(t *testing.T) {
|
|
db, close := setupTestDB(t, communityID1, communityID2)
|
|
defer close()
|
|
csn := NewCommunityStorenodes(db, nil)
|
|
snodes1 := []Storenode{
|
|
{
|
|
CommunityID: communityID1,
|
|
StorenodeID: "storenode001",
|
|
Name: "My Mailserver",
|
|
Address: "enode://...",
|
|
Fleet: "prod",
|
|
Version: 2,
|
|
},
|
|
}
|
|
snodes2 := []Storenode{
|
|
{
|
|
CommunityID: communityID2,
|
|
StorenodeID: "storenode002",
|
|
Name: "My Mailserver",
|
|
Address: "enode://...",
|
|
Fleet: "prod",
|
|
Version: 2,
|
|
},
|
|
}
|
|
// populate db
|
|
err := csn.UpdateStorenodesInDB(communityID1, snodes1, 0)
|
|
require.NoError(t, err)
|
|
err = csn.UpdateStorenodesInDB(communityID2, snodes2, 0)
|
|
require.NoError(t, err)
|
|
|
|
// check if storenodes are loaded
|
|
ms1, err := csn.GetStorenodeByCommunnityID(communityID1.String())
|
|
require.NoError(t, err)
|
|
matchStoreNode(t, snodes1[0], ms1)
|
|
|
|
ms2, err := csn.GetStorenodeByCommunnityID(communityID2.String())
|
|
require.NoError(t, err)
|
|
matchStoreNode(t, snodes2[0], ms2)
|
|
}
|
|
|
|
func matchStoreNode(t *testing.T, sn Storenode, ms mailservers.Mailserver) {
|
|
require.Equal(t, sn.StorenodeID, ms.ID)
|
|
require.Equal(t, sn.Name, ms.Name)
|
|
require.Equal(t, sn.Address, ms.Address)
|
|
require.Equal(t, sn.Fleet, ms.Fleet)
|
|
require.Equal(t, sn.Version, ms.Version)
|
|
}
|