Skip to content

Commit

Permalink
fix(NodeConfig)_: Added Waku nodes are lost after a restart
Browse files Browse the repository at this point in the history
  • Loading branch information
friofry committed Jul 16, 2024
1 parent 9403475 commit 50bd5d6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions api/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/multiaccounts/settings"
"github.com/status-im/status-go/node"
"github.com/status-im/status-go/nodecfg"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/rpc"
Expand Down Expand Up @@ -1505,6 +1506,55 @@ func TestSetFleet(t *testing.T) {
require.NoError(t, b.Logout())
}

func TestAddWakuNode(t *testing.T) {
// GIVEN - add custom waku node
utils.Init()
password := "some-password"
tmpdir := t.TempDir()

b := NewGethStatusBackend()
defer func() {
require.NoError(t, b.StopNode())
}()

createAccountRequest := &requests.CreateAccount{
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Password: password,
RootDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
}
newAccount, err := b.CreateAccountAndLogin(createAccountRequest)
require.NoError(t, err)

dbNodeConfig, err := nodecfg.GetNodeConfigFromDB(b.appDB)
require.NoError(t, err)
wakuNodesBeforeChanges := dbNodeConfig.ClusterConfig.WakuNodes

// WHEN - adding custom waku node
testWakuNodeEnrtree := "enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im"
err = nodecfg.SaveNewWakuNode(b.appDB, testWakuNodeEnrtree)
require.NoError(t, err)

dbNodeConfig, err = nodecfg.GetNodeConfigFromDB(b.appDB)
require.NoError(t, err)
require.Contains(t, dbNodeConfig.ClusterConfig.WakuNodes, testWakuNodeEnrtree)

require.NoError(t, b.Logout())

// THEN - after relogin node is still there
loginAccountRequest := &requests.Login{
KeyUID: newAccount.KeyUID,
Password: password,
}
require.NoError(t, b.LoginAccount(loginAccountRequest))

dbNodeConfig, err = nodecfg.GetNodeConfigFromDB(b.appDB)
require.NoError(t, err)
require.Len(t, dbNodeConfig.ClusterConfig.WakuNodes, len(wakuNodesBeforeChanges)+1)
require.Contains(t, dbNodeConfig.ClusterConfig.WakuNodes, testWakuNodeEnrtree)
}

func TestWalletConfigOnLoginAccount(t *testing.T) {
utils.Init()
password := "some-password2" // nolint: goconst
Expand Down
2 changes: 1 addition & 1 deletion api/geth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ func (b *GethStatusBackend) loadNodeConfig(inputNodeCfg *params.NodeConfig) erro
inputNodeCfg.ShhextConfig.InstallationID = conf.ShhextConfig.InstallationID
}

conf, err = b.OverwriteNodeConfigValues(conf, inputNodeCfg)
conf, err = b.OverwriteNodeConfigValues(inputNodeCfg, conf)
if err != nil {
return err
}
Expand Down

0 comments on commit 50bd5d6

Please sign in to comment.