status-go/services/wakuext/api_test.go

65 lines
2.0 KiB
Go
Raw Permalink Normal View History

package wakuext
import (
"io/ioutil"
"testing"
"go.uber.org/zap"
"github.com/stretchr/testify/require"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/storage"
"github.com/ethereum/go-ethereum/event"
2020-07-22 07:41:40 +00:00
"github.com/status-im/status-go/appdatabase"
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
"github.com/status-im/status-go/eth-node/crypto"
2020-11-25 11:39:01 +00:00
"github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/services/ext"
"github.com/status-im/status-go/t/helpers"
"github.com/status-im/status-go/waku"
"github.com/status-im/status-go/walletdatabase"
)
func TestInitProtocol(t *testing.T) {
2022-01-12 16:02:01 +00:00
config := params.NodeConfig{
RootDataDir: t.TempDir(),
2022-01-12 16:02:01 +00:00
ShhextConfig: params.ShhextConfig{
InstallationID: "2",
PFSEnabled: true,
MailServerConfirmations: true,
ConnectionTarget: 10,
},
}
db, err := leveldb.Open(storage.NewMemStorage(), nil)
require.NoError(t, err)
waku := gethbridge.NewGethWakuWrapper(waku.New(nil, nil))
privateKey, err := crypto.GenerateKey()
require.NoError(t, err)
nodeWrapper := ext.NewTestNodeWrapper(nil, waku)
service := New(config, nodeWrapper, nil, nil, db)
appDB, cleanupDB, err := helpers.SetupTestSQLDB(appdatabase.DbInitializer{}, "db.sql")
defer func() { require.NoError(t, cleanupDB()) }()
require.NoError(t, err)
tmpfile, err := ioutil.TempFile("", "multi-accounts-tests-")
require.NoError(t, err)
multiAccounts, err := multiaccounts.InitializeDB(tmpfile.Name())
require.NoError(t, err)
2020-12-15 18:00:31 +00:00
acc := &multiaccounts.Account{KeyUID: "0xdeadbeef"}
walletDB, cleanupWalletDB, err := helpers.SetupTestSQLDB(walletdatabase.DbInitializer{}, "db-wallet.sql")
defer func() { require.NoError(t, cleanupWalletDB()) }()
require.NoError(t, err)
accountsFeed := &event.Feed{}
err = service.InitProtocol("Test", privateKey, appDB, walletDB, nil, multiAccounts, acc, nil, nil, nil, nil, nil, zap.NewNop(), accountsFeed)
require.NoError(t, err)
}