mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 14:16:21 +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>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package storenodes
|
|
|
|
import (
|
|
"database/sql"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/status-im/status-go/appdatabase"
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
"github.com/status-im/status-go/protocol/sqlite"
|
|
"github.com/status-im/status-go/t/helpers"
|
|
)
|
|
|
|
func setupTestDB(t *testing.T, communityIDs ...types.HexBytes) (*Database, func()) {
|
|
db, cleanup, err := helpers.SetupTestSQLDB(appdatabase.DbInitializer{}, "storenodes-tests-")
|
|
require.NoError(t, err)
|
|
|
|
err = sqlite.Migrate(db)
|
|
require.NoError(t, err)
|
|
|
|
for _, communityID := range communityIDs {
|
|
err = saveTestCommunity(db, communityID)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
return NewDB(db), func() { require.NoError(t, cleanup()) }
|
|
}
|
|
|
|
func saveTestCommunity(db *sql.DB, communityID types.HexBytes) error {
|
|
_, err := db.Exec(
|
|
`INSERT INTO communities_communities ("id", "private_key", "description", "joined", "verified", "synced_at", "muted") VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
communityID,
|
|
[]byte("private_key"),
|
|
[]byte("description"),
|
|
true,
|
|
true,
|
|
0,
|
|
false,
|
|
)
|
|
return err
|
|
}
|