geth/params: stop transforming passed DataDir
This commit is contained in:
parent
ec1440231a
commit
8a96fc18c4
|
@ -11,8 +11,8 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/status-im/status-go/geth"
|
"github.com/status-im/status-go/geth"
|
||||||
"github.com/status-im/status-go/geth/params"
|
|
||||||
"github.com/status-im/status-go/geth/jail"
|
"github.com/status-im/status-go/geth/jail"
|
||||||
|
"github.com/status-im/status-go/geth/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -2,12 +2,12 @@ package params
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"math/big"
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
@ -195,9 +195,6 @@ func (c *NodeConfig) populateChainConfig() {
|
||||||
c.ChainConfig.EIP158Block = params.TestnetChainConfig.EIP158Block
|
c.ChainConfig.EIP158Block = params.TestnetChainConfig.EIP158Block
|
||||||
c.ChainConfig.ChainId = params.TestnetChainConfig.ChainId
|
c.ChainConfig.ChainId = params.TestnetChainConfig.ChainId
|
||||||
|
|
||||||
if len(c.DataDir) > 0 {
|
|
||||||
c.DataDir = filepath.Join(c.DataDir, "testnet")
|
|
||||||
}
|
|
||||||
c.Genesis = core.DefaultTestnetGenesisBlock()
|
c.Genesis = core.DefaultTestnetGenesisBlock()
|
||||||
} else {
|
} else {
|
||||||
// Homestead fork
|
// Homestead fork
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
gethparams "github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/status-im/status-go/geth"
|
"github.com/status-im/status-go/geth"
|
||||||
"github.com/status-im/status-go/geth/params"
|
"github.com/status-im/status-go/geth/params"
|
||||||
gethparams "github.com/ethereum/go-ethereum/params"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var loadConfigTestCases = []struct {
|
var loadConfigTestCases = []struct {
|
||||||
|
@ -60,40 +60,18 @@ var loadConfigTestCases = []struct {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
`testnet subdirectory not used (while we are on Network = 3)`,
|
`check static DataDir passing`,
|
||||||
`{
|
`{
|
||||||
"NetworkId": 3,
|
"NetworkId": 3,
|
||||||
"DataDir": "$TMPDIR"
|
"DataDir": "/storage/emulated/0/ethereum/"
|
||||||
}`,
|
}`,
|
||||||
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
|
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
if nodeConfig.DataDir != filepath.Join(dataDir, "testnet") {
|
expectedDataDir := "/storage/emulated/0/ethereum/"
|
||||||
t.Fatal("'testnet' subdirectory not used")
|
if nodeConfig.DataDir != expectedDataDir {
|
||||||
}
|
t.Fatalf("incorrect DataDir used, expected: %v, got: %v", expectedDataDir, nodeConfig.DataDir)
|
||||||
|
|
||||||
if !strings.Contains(nodeConfig.LightEthConfig.Genesis, "\"chainId\": 3") {
|
|
||||||
t.Fatal("wrong genesis")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`testnet subdirectory used (while we are on Network != 3)`,
|
|
||||||
`{
|
|
||||||
"NetworkId": 1,
|
|
||||||
"DataDir": "$TMPDIR"
|
|
||||||
}`,
|
|
||||||
func(t *testing.T, dataDir string, nodeConfig *params.NodeConfig, err error) {
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if nodeConfig.DataDir != dataDir {
|
|
||||||
t.Fatal("'testnet' subdirectory used")
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.Contains(nodeConfig.LightEthConfig.Genesis, "\"chainId\": 3") {
|
|
||||||
t.Fatal("wrong genesis")
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"TestNet": true,
|
"TestNet": true,
|
||||||
"NetworkId": 3,
|
"NetworkId": 3,
|
||||||
"DataDir": "$TMPDIR",
|
"DataDir": "$TMPDIR",
|
||||||
"Name": "status",
|
"Name": "StatusIM",
|
||||||
"Version": "$VERSION",
|
"Version": "$VERSION",
|
||||||
"APIModules": "db,eth,net,web3,shh,personal,admin",
|
"APIModules": "db,eth,net,web3,shh,personal,admin",
|
||||||
"HTTPHost": "localhost",
|
"HTTPHost": "localhost",
|
||||||
|
|
|
@ -157,18 +157,18 @@ func PrepareTestNode() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
syncRequired := false
|
syncRequired := false
|
||||||
if _, err := os.Stat(filepath.Join(TestDataDir, "testnet")); os.IsNotExist(err) {
|
if _, err := os.Stat(TestDataDir); os.IsNotExist(err) {
|
||||||
syncRequired = true
|
syncRequired = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare node directory
|
// prepare node directory
|
||||||
if err := os.MkdirAll(filepath.Join(TestDataDir, "testnet", "keystore"), os.ModePerm); err != nil {
|
if err := os.MkdirAll(filepath.Join(TestDataDir, "keystore"), os.ModePerm); err != nil {
|
||||||
glog.V(logger.Warn).Infoln("make node failed:", err)
|
glog.V(logger.Warn).Infoln("make node failed:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// import test account (with test ether on it)
|
// import test account (with test ether on it)
|
||||||
dst := filepath.Join(TestDataDir, "testnet", "keystore", "test-account.pk")
|
dst := filepath.Join(TestDataDir, "keystore", "test-account.pk")
|
||||||
if _, err := os.Stat(dst); os.IsNotExist(err) {
|
if _, err := os.Stat(dst); os.IsNotExist(err) {
|
||||||
err = CopyFile(dst, filepath.Join(RootDir, "data", "test-account.pk"))
|
err = CopyFile(dst, filepath.Join(RootDir, "data", "test-account.pk"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue