fix: proper usage of CreateAccount RootDataDir (#5284)

* fix_: introduce CreateAccount.RootDataDir
* fix_: deprecate and remove ShhextConfig.BackupDisabledDataDir
This commit is contained in:
Igor Sirotin 2024-06-05 14:03:34 +01:00 committed by GitHub
parent 11f83780d1
commit a01ffdbe8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 123 additions and 109 deletions

View File

@ -1,7 +1,7 @@
{
"NetworkId": 777,
"DataDir": "/data/ethereumtest/status",
"BackupDisabledDataDir": "/data/ethereumtest/status",
"RootDataDir": "/data/ethereumtest/status",
"KeyStoreDir": "/data/ethereumtest/keystore",
"NoDiscovery": false,
"Rendezvous": false,

View File

@ -826,13 +826,13 @@ func TestLoginAccount(t *testing.T) {
b := NewGethStatusBackend()
createAccountRequest := &requests.CreateAccount{
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Emoji: "some",
Password: password,
BackupDisabledDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
WakuV2Nameserver: &nameserver,
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Emoji: "some",
Password: password,
RootDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
WakuV2Nameserver: &nameserver,
}
c := make(chan interface{}, 10)
signal.SetMobileSignalHandler(func(data []byte) {
@ -1388,12 +1388,12 @@ func TestCreateWallet(t *testing.T) {
}()
createAccountRequest := &requests.CreateAccount{
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Emoji: "emoji",
Password: password,
BackupDisabledDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Emoji: "emoji",
Password: password,
RootDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
}
c := make(chan interface{}, 10)
signal.SetMobileSignalHandler(func(data []byte) {
@ -1447,12 +1447,12 @@ func TestSetFleet(t *testing.T) {
b := NewGethStatusBackend()
createAccountRequest := &requests.CreateAccount{
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Password: password,
BackupDisabledDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
Emoji: "some",
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Password: password,
RootDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
Emoji: "some",
}
c := make(chan interface{}, 10)
signal.SetMobileSignalHandler(func(data []byte) {
@ -1516,12 +1516,12 @@ func TestWalletConfigOnLoginAccount(t *testing.T) {
b := NewGethStatusBackend()
createAccountRequest := &requests.CreateAccount{
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Password: password,
BackupDisabledDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
Emoji: "some",
DisplayName: "some-display-name",
CustomizationColor: "#ffffff",
Password: password,
RootDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
Emoji: "some",
}
c := make(chan interface{}, 10)
signal.SetMobileSignalHandler(func(data []byte) {
@ -1583,13 +1583,13 @@ func TestTestnetEnabledSettingOnCreateAccount(t *testing.T) {
// Creating an account with test networks enabled
createAccountRequest1 := &requests.CreateAccount{
DisplayName: "User-1",
CustomizationColor: "#ffffff",
Emoji: "some",
Password: "password123",
BackupDisabledDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
TestNetworksEnabled: true,
DisplayName: "User-1",
CustomizationColor: "#ffffff",
Emoji: "some",
Password: "password123",
RootDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
TestNetworksEnabled: true,
}
_, err := b.CreateAccountAndLogin(createAccountRequest1)
require.NoError(t, err)
@ -1604,12 +1604,12 @@ func TestTestnetEnabledSettingOnCreateAccount(t *testing.T) {
// Creating an account with test networks disabled
createAccountRequest2 := &requests.CreateAccount{
DisplayName: "User-2",
CustomizationColor: "#ffffff",
Emoji: "some",
Password: "password",
BackupDisabledDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
DisplayName: "User-2",
CustomizationColor: "#ffffff",
Emoji: "some",
Password: "password",
RootDataDir: tmpdir,
LogFilePath: tmpdir + "/log",
}
_, err = b.CreateAccountAndLogin(createAccountRequest2)
require.NoError(t, err)
@ -1650,3 +1650,27 @@ func TestRestoreAccountAndLogin(t *testing.T) {
_, err = backend.RestoreAccountAndLogin(invalidRequest)
require.Error(t, err)
}
func TestCreateAccountPathsValidation(t *testing.T) {
tmpdir := t.TempDir()
validation := &requests.CreateAccountValidation{
AllowEmptyDisplayName: false,
}
request := &requests.CreateAccount{
DisplayName: "User-1",
Password: "password123",
CustomizationColor: "#ffffff",
RootDataDir: tmpdir,
}
err := request.Validate(validation)
require.NoError(t, err)
request.RootDataDir = ""
request.BackupDisabledDataDir = tmpdir
err = request.Validate(validation)
require.NoError(t, err)
require.Equal(t, tmpdir, request.RootDataDir)
}

View File

@ -22,7 +22,7 @@ func TestCreateAccountAndLogin(t *testing.T) {
"wakuV2Nameserver":"1.1.1.1",
"mnemonic":null,
"verifyENSContractAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"backupDisabledDataDir":"%s",
"rootDataDir":"%s",
"password":"0x20756cad9b728c8225fd8cedb6badaf8731e174506950219ea657cd54f35f46c",
"displayName":"%s",
"logEnabled":true,

View File

@ -292,7 +292,6 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount, o
}
nodeConfig.ShhextConfig = params.ShhextConfig{
BackupDisabledDataDir: request.BackupDisabledDataDir,
InstallationID: installationID,
MaxMessageDeliveryAttempts: DefaultMaxMessageDeliveryAttempts,
MailServerConfirmations: true,

View File

@ -13,6 +13,8 @@ import (
"sync"
"time"
"go.uber.org/zap"
"github.com/status-im/status-go/services/ens"
"github.com/status-im/status-go/sqlite"
@ -1321,7 +1323,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
return nil, nil, nil, nil, err
}
keyStoreDir, err := b.initKeyStoreDirWithAccount(request.BackupDisabledDataDir, info.KeyUID)
keyStoreDir, err := b.initKeyStoreDirWithAccount(request.RootDataDir, info.KeyUID)
if err != nil {
return nil, nil, nil, nil, err
}
@ -1355,8 +1357,8 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
return account, settings, nodeConfig, subAccounts, nil
}
func (b *GethStatusBackend) initKeyStoreDirWithAccount(backupDisabledDataDir, keyUID string) (string, error) {
b.UpdateRootDataDir(backupDisabledDataDir)
func (b *GethStatusBackend) initKeyStoreDirWithAccount(rootDataDir, keyUID string) (string, error) {
b.UpdateRootDataDir(rootDataDir)
keystoreDir := keystoreRelativePath
userKeyStoreDir := filepath.Join(keystoreDir, keyUID)
// Initialize keystore dir with account
@ -1830,13 +1832,20 @@ func (b *GethStatusBackend) loadNodeConfig(inputNodeCfg *params.NodeConfig) erro
conf.Version = params.Version
conf.RootDataDir = b.rootDataDir
conf.DataDir = filepath.Join(b.rootDataDir, conf.DataDir)
conf.ShhextConfig.BackupDisabledDataDir = filepath.Join(b.rootDataDir, conf.ShhextConfig.BackupDisabledDataDir)
conf.KeyStoreDir = filepath.Join(b.rootDataDir, conf.KeyStoreDir)
if _, err = os.Stat(conf.RootDataDir); os.IsNotExist(err) {
if err := os.MkdirAll(conf.RootDataDir, os.ModePerm); err != nil {
b.log.Warn("failed to create data directory", zap.Error(err))
return err
}
}
if len(conf.LogDir) == 0 {
conf.LogFile = filepath.Join(b.rootDataDir, conf.LogFile)
} else {
conf.LogFile = filepath.Join(conf.LogDir, conf.LogFile)
}
conf.KeyStoreDir = filepath.Join(b.rootDataDir, conf.KeyStoreDir)
b.config = conf

View File

@ -175,7 +175,7 @@ func (s *MessengerRawMessageResendTest) createBackendAndLogin(backend **GethStat
s.Require().NoError(err)
}
func (s *MessengerRawMessageResendTest) setCreateAccountRequest(displayName, backupDisabledDataDir, logFilePath string) *requests.CreateAccount {
func (s *MessengerRawMessageResendTest) setCreateAccountRequest(displayName, rootDataDir, logFilePath string) *requests.CreateAccount {
nameServer := "1.1.1.1"
verifyENSContractAddress := "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
verifyTransactionChainID := int64(1)
@ -187,7 +187,7 @@ func (s *MessengerRawMessageResendTest) setCreateAccountRequest(displayName, bac
UpstreamConfig: verifyURL,
WakuV2Nameserver: &nameServer,
VerifyENSContractAddress: &verifyENSContractAddress,
BackupDisabledDataDir: backupDisabledDataDir,
RootDataDir: rootDataDir,
Password: password,
DisplayName: displayName,
LogEnabled: true,

View File

@ -186,7 +186,6 @@ func randomNodeConfig() *params.NodeConfig {
},
ShhextConfig: params.ShhextConfig{
PFSEnabled: randomBool(),
BackupDisabledDataDir: randomString(),
InstallationID: randomString(),
MailServerConfirmations: randomBool(),
EnableConnectionManager: randomBool(),

View File

@ -369,7 +369,6 @@ func defaultNodeConfig(installationID string) (*params.NodeConfig, error) {
}
nodeConfig.ShhextConfig = params.ShhextConfig{
BackupDisabledDataDir: "",
InstallationID: installationID,
MaxMessageDeliveryAttempts: api.DefaultMaxMessageDeliveryAttempts,
MailServerConfirmations: true,

View File

@ -418,7 +418,6 @@ func defaultNodeConfig(installationID string) (*params.NodeConfig, error) {
}
nodeConfig.ShhextConfig = params.ShhextConfig{
BackupDisabledDataDir: "",
InstallationID: installationID,
MaxMessageDeliveryAttempts: api.DefaultMaxMessageDeliveryAttempts,
MailServerConfirmations: true,

View File

@ -331,7 +331,6 @@ func defaultNodeConfig(installationID string) (*params.NodeConfig, error) {
}
nodeConfig.ShhextConfig = params.ShhextConfig{
BackupDisabledDataDir: "",
InstallationID: installationID,
MaxMessageDeliveryAttempts: api.DefaultMaxMessageDeliveryAttempts,
MailServerConfirmations: true,

View File

@ -49,12 +49,12 @@ func start(cCtx *cli.Context, name string, port int, apiModules string, telemetr
backend := api.NewGethStatusBackend()
createAccountRequest := &requests.CreateAccount{
DisplayName: name,
CustomizationColor: "#ffffff",
Emoji: "some",
Password: "some-password",
BackupDisabledDataDir: fmt.Sprintf("./test-%s", strings.ToLower(name)),
LogFilePath: "log",
DisplayName: name,
CustomizationColor: "#ffffff",
Emoji: "some",
Password: "some-password",
RootDataDir: fmt.Sprintf("./test-%s", strings.ToLower(name)),
LogFilePath: "log",
APIConfig: &requests.APIConfig{
APIModules: apiModules,
HTTPHost: "127.0.0.1",

View File

@ -162,13 +162,13 @@ func insertLightETHConfig(tx *sql.Tx, c *params.NodeConfig) error {
func insertShhExtConfig(tx *sql.Tx, c *params.NodeConfig) error {
_, err := tx.Exec(`
INSERT OR REPLACE INTO shhext_config (
pfs_enabled, backup_disabled_data_dir, installation_id, mailserver_confirmations, enable_connection_manager,
pfs_enabled, installation_id, mailserver_confirmations, enable_connection_manager,
enable_last_used_monitor, connection_target, request_delay, max_server_failures, max_message_delivery_attempts,
whisper_cache_dir, disable_generic_discovery_topic, send_v1_messages, data_sync_enabled, verify_transaction_url,
verify_ens_url, verify_ens_contract_address, verify_transaction_chain_id, anon_metrics_server_enabled,
anon_metrics_send_id, anon_metrics_server_postgres_uri, bandwidth_stats_enabled, synthetic_id
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'id')`,
c.ShhextConfig.PFSEnabled, c.ShhextConfig.BackupDisabledDataDir, c.ShhextConfig.InstallationID, c.ShhextConfig.MailServerConfirmations, c.ShhextConfig.EnableConnectionManager,
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'id')`,
c.ShhextConfig.PFSEnabled, c.ShhextConfig.InstallationID, c.ShhextConfig.MailServerConfirmations, c.ShhextConfig.EnableConnectionManager,
c.ShhextConfig.EnableLastUsedMonitor, c.ShhextConfig.ConnectionTarget, c.ShhextConfig.RequestsDelay, c.ShhextConfig.MaxServerFailures, c.ShhextConfig.MaxMessageDeliveryAttempts,
c.ShhextConfig.WhisperCacheDir, c.ShhextConfig.DisableGenericDiscoveryTopic, c.ShhextConfig.SendV1Messages, c.ShhextConfig.DataSyncEnabled, c.ShhextConfig.VerifyTransactionURL,
c.ShhextConfig.VerifyENSURL, c.ShhextConfig.VerifyENSContractAddress, c.ShhextConfig.VerifyTransactionChainID, c.ShhextConfig.AnonMetricsServerEnabled,
@ -627,13 +627,13 @@ func loadNodeConfig(tx *sql.Tx) (*params.NodeConfig, error) {
}
err = tx.QueryRow(`
SELECT pfs_enabled, backup_disabled_data_dir, installation_id, mailserver_confirmations, enable_connection_manager,
SELECT pfs_enabled, installation_id, mailserver_confirmations, enable_connection_manager,
enable_last_used_monitor, connection_target, request_delay, max_server_failures, max_message_delivery_attempts,
whisper_cache_dir, disable_generic_discovery_topic, send_v1_messages, data_sync_enabled, verify_transaction_url,
verify_ens_url, verify_ens_contract_address, verify_transaction_chain_id, anon_metrics_server_enabled,
anon_metrics_send_id, anon_metrics_server_postgres_uri, bandwidth_stats_enabled FROM shhext_config WHERE synthetic_id = 'id'
`).Scan(
&nodecfg.ShhextConfig.PFSEnabled, &nodecfg.ShhextConfig.BackupDisabledDataDir, &nodecfg.ShhextConfig.InstallationID, &nodecfg.ShhextConfig.MailServerConfirmations, &nodecfg.ShhextConfig.EnableConnectionManager,
&nodecfg.ShhextConfig.PFSEnabled, &nodecfg.ShhextConfig.InstallationID, &nodecfg.ShhextConfig.MailServerConfirmations, &nodecfg.ShhextConfig.EnableConnectionManager,
&nodecfg.ShhextConfig.EnableLastUsedMonitor, &nodecfg.ShhextConfig.ConnectionTarget, &nodecfg.ShhextConfig.RequestsDelay, &nodecfg.ShhextConfig.MaxServerFailures, &nodecfg.ShhextConfig.MaxMessageDeliveryAttempts,
&nodecfg.ShhextConfig.WhisperCacheDir, &nodecfg.ShhextConfig.DisableGenericDiscoveryTopic, &nodecfg.ShhextConfig.SendV1Messages, &nodecfg.ShhextConfig.DataSyncEnabled, &nodecfg.ShhextConfig.VerifyTransactionURL,
&nodecfg.ShhextConfig.VerifyENSURL, &nodecfg.ShhextConfig.VerifyENSContractAddress, &nodecfg.ShhextConfig.VerifyTransactionChainID, &nodecfg.ShhextConfig.AnonMetricsServerEnabled,

View File

@ -4,7 +4,6 @@ import (
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/url"
@ -608,8 +607,6 @@ type PushNotificationServerConfig struct {
// ShhextConfig defines options used by shhext service.
type ShhextConfig struct {
PFSEnabled bool
// BackupDisabledDataDir is the file system folder the node should use for any data storage needs that it doesn't want backed up.
BackupDisabledDataDir string
// InstallationId id of the current installation
InstallationID string
// MailServerConfirmations should be true if client wants to receive confirmatons only from a selected mail servers.
@ -688,9 +685,6 @@ func (c *ShhextConfig) Validate(validate *validator.Validate) error {
if err := validate.Struct(c); err != nil {
return err
}
if c.PFSEnabled && len(c.BackupDisabledDataDir) == 0 {
return errors.New("field BackupDisabledDataDir is required if PFSEnabled is true")
}
return nil
}
@ -878,6 +872,7 @@ func NewNodeConfig(dataDir string, networkID uint64) (*NodeConfig, error) {
config := &NodeConfig{
NetworkID: networkID,
RootDataDir: dataDir,
DataDir: dataDir,
KeyStoreDir: keyStoreDir,
KeycardPairingDataFile: keycardPairingDataFile,
@ -912,10 +907,8 @@ func NewNodeConfig(dataDir string, networkID uint64) (*NodeConfig, error) {
DataDir: wakuV2Dir,
MaxMessageSize: wakuv2common.DefaultMaxMessageSize,
},
ShhextConfig: ShhextConfig{
BackupDisabledDataDir: dataDir,
},
SwarmConfig: SwarmConfig{},
ShhextConfig: ShhextConfig{},
SwarmConfig: SwarmConfig{},
TorrentConfig: TorrentConfig{
Enabled: false,
Port: 9025,

View File

@ -97,7 +97,6 @@ func TestConfigWriteRead(t *testing.T) {
loadedConfig := string(loadedConfigData)
require.Contains(t, loadedConfig, fmt.Sprintf(`"NetworkId": %d`, params.GoerliNetworkID))
require.Contains(t, loadedConfig, fmt.Sprintf(`"DataDir": "%s"`, tmpDir))
require.Contains(t, loadedConfig, fmt.Sprintf(`"BackupDisabledDataDir": "%s"`, tmpDir))
}
// TestNodeConfigValidate checks validation of individual fields.
@ -113,8 +112,8 @@ func TestNodeConfigValidate(t *testing.T) {
Name: "Valid JSON config",
Config: `{
"NetworkId": 1,
"RootDataDir": "/tmp/data",
"DataDir": "/tmp/data",
"BackupDisabledDataDir": "/tmp/data",
"KeyStoreDir": "/tmp/data",
"KeycardPairingDataFile": "/tmp/data/keycard/pairings.json",
"NoDiscovery": true
@ -244,7 +243,6 @@ func TestNodeConfigValidate(t *testing.T) {
"DataDir": "/foo"
},
"ShhextConfig": {
"BackupDisabledDataDir": "/some/dir",
"PFSEnabled": true
}
}`,
@ -287,19 +285,6 @@ func TestNodeConfigValidate(t *testing.T) {
"KeycardPairingDataFile": "/some/dir/keycard/pairings.json"
}`,
},
{
Name: "BackupDisabledDataDir must be set if PFSEnabled is true",
Config: `{
"NetworkId": 1,
"DataDir": "/some/dir",
"KeyStoreDir": "/some/dir",
"KeycardPairingDataFile": "/some/dir/keycard/pairings.json",
"ShhextConfig": {
"PFSEnabled": true
}
}`,
Error: "field BackupDisabledDataDir is required if PFSEnabled is true",
},
{
Name: "Missing APIModules",
Config: `{"NetworkId": 1, "DataDir": "/tmp/data", "KeyStoreDir": "/tmp/data", "KeycardPairingDataFile": "/tmp/data/keycard/pairings.json", "APIModules" :""}`,

View File

@ -11,7 +11,7 @@ var ErrCreateAccountInvalidDisplayName = errors.New("create-account: invalid dis
var ErrCreateAccountInvalidPassword = errors.New("create-account: invalid password")
var ErrCreateAccountInvalidCustomizationColor = errors.New("create-account: invalid customization color")
var ErrCreateAccountInvalidRootKeystoreDir = errors.New("create-account: invalid root keystore directory")
var ErrCreateAccountInvalidBackupDisabledDataDir = errors.New("create-account: invalid backup disabled data directory")
var ErrCreateAccountInvalidRootDataDir = errors.New("create-account: invalid root data directory")
type ImageCropRectangle struct {
Ax int `json:"ax"`
@ -27,10 +27,13 @@ type APIConfig struct {
}
type CreateAccount struct {
// BackupDisabledDataDir is the directory where backup is disabled
// WARNING: This is used as `RootDataDir`. Consider renaming?
// Deprecated: BackupDisabledDataDir is the directory where backup is disabled
// Use `RootDataDir` instead. Effective BackupDisabledDataDir value will default to RootDataDir + "./".
BackupDisabledDataDir string `json:"backupDisabledDataDir"`
KdfIterations int `json:"kdfIterations"`
// RootDataDir is an absolute path to the root directory where all data will be stored.
RootDataDir string `json:"rootDataDir"`
KdfIterations int `json:"kdfIterations"`
DeviceName string `json:"deviceName"`
DisplayName string `json:"displayName"`
@ -44,7 +47,7 @@ type CreateAccount struct {
WakuV2LightClient bool `json:"wakuV2LightClient"`
LogLevel *string `json:"logLevel"`
LogFilePath string `json:"logFilePath"`
LogFilePath string `json:"logFilePath"` // absolute path
LogEnabled bool `json:"logEnabled"`
PreviewPrivacy bool `json:"previewPrivacy"`
@ -113,8 +116,14 @@ func (c *CreateAccount) Validate(validation *CreateAccountValidation) error {
return ErrCreateAccountInvalidCustomizationColor
}
if len(c.BackupDisabledDataDir) == 0 {
return ErrCreateAccountInvalidBackupDisabledDataDir
if len(c.RootDataDir) == 0 {
if c.BackupDisabledDataDir == "" {
return ErrCreateAccountInvalidRootDataDir
}
// NOTE: Fallback to old BackupDisabledDataDir field.
// Remove this when both desktop and mobile use the new `RootDataDir` field.
// Return error if `RootDataDir` is empty.
c.RootDataDir = c.BackupDisabledDataDir
}
return nil

View File

@ -324,7 +324,6 @@ func setDefaultNodeConfig(c *params.NodeConfig) error {
}
c.ShhextConfig = params.ShhextConfig{
BackupDisabledDataDir: c.RootDataDir,
InstallationID: specifiedInstallationID,
MaxMessageDeliveryAttempts: api.DefaultMaxMessageDeliveryAttempts,
MailServerConfirmations: true,

View File

@ -1 +0,0 @@
{"ClusterConfig":{"Enabled":true,"Fleet":"eth.beta","BootNodes":["enode://7427dfe38bd4cf7c58bb96417806fab25782ec3e6046a8053370022cbaa281536e8d64ecd1b02e1f8f72768e295d06258ba43d88304db068e6f2417ae8bcb9a6@104.154.88.123:443","enode://e8a7c03b58911e98bbd66accb2a55d57683f35b23bf9dfca89e5e244eb5cc3f25018b4112db507faca34fb69ffb44b362f79eda97a669a8df29c72e654416784@47.91.224.35:443","enode://5395aab7833f1ecb671b59bf0521cf20224fe8162fc3d2675de4ee4d5636a75ec32d13268fc184df8d1ddfa803943906882da62a4df42d4fccf6d17808156a87@206.189.243.57:443","enode://43947863cfa5aad1178f482ac35a8ebb9116cded1c23f7f9af1a47badfc1ee7f0dd9ec0543417cc347225a6e47e46c6873f647559e43434596c54e17a4d3a1e4@47.52.74.140:443"],"TrustedMailServers":["enode://744098ab6d3308af5cd03920aea60c46d16b2cd3d33bf367cbaf1d01c2fcd066ff8878576d0967897cd7dbb0e63f873cc0b4f7e4b0f1d7222e6b3451a78d9bda@47.89.20.15:443","enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:443","enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:443","enode://da61e9eff86a56633b635f887d8b91e0ff5236bbc05b8169834292e92afb92929dcf6efdbf373a37903da8fe0384d5a0a8247e83f1ce211aa429200b6d28c548@47.91.156.93:443","enode://74957e361ab290e6af45a124536bc9adee39fbd2f995a77ace6ed7d05d9a1c7c98b78b2df5f8071c439b9c0afe4a69893ede4ad633473f96bc195ddf33f6ce00@47.52.255.195:443","enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:443"],"StaticNodes":["enode://887cbd92d95afc2c5f1e227356314a53d3d18855880ac0509e0c0870362aee03939d4074e6ad31365915af41d34320b5094bfcc12a67c381788cd7298d06c875@206.189.243.177:443","enode://a8bddfa24e1e92a82609b390766faa56cf7a5eef85b22a2b51e79b333c8aaeec84f7b4267e432edd1cf45b63a3ad0fc7d6c3a16f046aa6bc07ebe50e80b63b8c@206.189.243.172:443"],"RendezvousNodes":["/ip4/206.189.243.57/tcp/30703/ethv4/16Uiu2HAmLqTXuY4Sb6G28HNooaFUXUKzpzKXCcgyJxgaEE2i5vnf","/ip4/174.138.105.243/tcp/30703/ethv4/16Uiu2HAmRHPzF3rQg55PgYPcQkyvPVH9n2hWsYPhUJBZ6kVjJgdV"]},"DataDir":"/ethereum/mainnet_rpc_dev","LogLevel":"INFO","Rendezvous":true,"WhisperConfig":{"Enabled":true,"LightClient":true,"MinimumPoW":0.001,"EnableNTPSync":true},"LogEnabled":true,"BrowsersConfig":{"Enabled":true},"RequireTopics":{"whisper":{"Min":2,"Max":2}},"UpstreamConfig":{"Enabled":true,"URL":"https://mainnet.infura.io/v3/f315575765b14720b32382a61a89341a"},"ListenAddr":":30304","PermissionsConfig":{"Enabled":true},"NetworkId":1,"Name":"StatusIM","NoDiscovery":false,"ShhextConfig":{"BackupDisabledDataDir":"/data/user/0/im.status.ethereum.debug/files/../no_backup","InstallationID":"cf40e6c9-262f-5a76-9621-7b6fe0a91cd2","MaxMessageDeliveryAttempts":6,"MailServerConfirmations":true,"DataSyncEnabled":false,"DisableGenericDiscoveryTopic":false,"SendV1Messages":false,"PFSEnabled":true},"WalletConfig":{"Enabled":true},"StatusAccountsConfig":{"Enabled":true}}

View File

@ -140,7 +140,8 @@ func (s *Service) InitProtocol(nodeName string, identity *ecdsa.PrivateKey, appD
s.identity = identity
dataDir := filepath.Clean(s.config.ShhextConfig.BackupDisabledDataDir)
// This directory should have already been created in loadNodeConfig, keeping this to ensure.
dataDir := filepath.Clean(s.config.RootDataDir)
if err := os.MkdirAll(dataDir, os.ModePerm); err != nil {
return err

View File

@ -55,10 +55,10 @@ func TestRequestMessagesErrors(t *testing.T) {
handler := ext.NewHandlerMock(1)
config := params.NodeConfig{
RootDataDir: os.TempDir(),
ShhextConfig: params.ShhextConfig{
InstallationID: "1",
BackupDisabledDataDir: os.TempDir(),
PFSEnabled: true,
InstallationID: "1",
PFSEnabled: true,
},
}
nodeWrapper := ext.NewTestNodeWrapper(nil, waku)
@ -103,9 +103,9 @@ func TestRequestMessagesErrors(t *testing.T) {
func TestInitProtocol(t *testing.T) {
config := params.NodeConfig{
RootDataDir: t.TempDir(),
ShhextConfig: params.ShhextConfig{
InstallationID: "2",
BackupDisabledDataDir: t.TempDir(),
PFSEnabled: true,
MailServerConfirmations: true,
ConnectionTarget: 10,
@ -176,9 +176,9 @@ func (s *ShhExtSuite) createAndAddNode() {
// set up protocol
config := params.NodeConfig{
RootDataDir: s.dir,
ShhextConfig: params.ShhextConfig{
InstallationID: "1",
BackupDisabledDataDir: s.dir,
PFSEnabled: true,
MailServerConfirmations: true,
ConnectionTarget: 10,

View File

@ -8,9 +8,10 @@ import (
big "math/big"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
common "github.com/ethereum/go-ethereum/common"
types "github.com/ethereum/go-ethereum/core/types"
gomock "github.com/golang/mock/gomock"
account "github.com/status-im/status-go/account"
types0 "github.com/status-im/status-go/eth-node/types"
bridge "github.com/status-im/status-go/services/wallet/bridge"

View File

@ -237,6 +237,7 @@ func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
configJSON := `{
"Name": "test",
"NetworkId": ` + strconv.Itoa(networkID) + `,
"RootDataDir": "` + testDir + `",
"DataDir": "` + testDir + `",
"KeyStoreDir": "` + path.Join(testDir, "keystore") + `",
"KeycardPairingDataFile": "` + path.Join(testDir, "keycard/pairings.json") + `",
@ -246,9 +247,6 @@ func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error) {
"NoDiscovery": true,
"LightEthConfig": {
"Enabled": true
},
"ShhextConfig": {
"BackupDisabledDataDir": "` + testDir + `"
}
}`

View File

@ -8,9 +8,10 @@ import (
big "math/big"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
common "github.com/ethereum/go-ethereum/common"
types "github.com/ethereum/go-ethereum/core/types"
gomock "github.com/golang/mock/gomock"
account "github.com/status-im/status-go/account"
types0 "github.com/status-im/status-go/eth-node/types"
params "github.com/status-im/status-go/params"