Skip to content

Commit

Permalink
internal/cli: set default value for keystore (#1051)
Browse files Browse the repository at this point in the history
* internal/cli: set default valuee for keystore

* internal/cli: add tests

* internal/cli: fix tests
  • Loading branch information
manav2401 authored Oct 18, 2023
1 parent cefca4f commit adfd428
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions internal/cli/server/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestFlagsWithoutConfig(t *testing.T) {

require.Equal(t, c.config.Identity, "")
require.Equal(t, c.config.DataDir, "./data")
require.Equal(t, c.config.KeyStoreDir, "")
require.Equal(t, c.config.Verbosity, 3)
require.Equal(t, c.config.RPCBatchLimit, uint64(0))
require.Equal(t, c.config.Snapshot, true)
Expand Down Expand Up @@ -74,6 +75,7 @@ func TestFlagsWithConfig(t *testing.T) {

require.Equal(t, c.config.Identity, "")
require.Equal(t, c.config.DataDir, "./data")
require.Equal(t, c.config.KeyStoreDir, "./keystore")
require.Equal(t, c.config.Verbosity, 3)
require.Equal(t, c.config.RPCBatchLimit, uint64(0))
require.Equal(t, c.config.Snapshot, true)
Expand Down Expand Up @@ -105,6 +107,7 @@ func TestFlagsWithConfigAndFlags(t *testing.T) {
"--config", "./testdata/test.toml",
"--identity", "Anon",
"--datadir", "",
"--keystore", "",
"--verbosity", "0",
"--rpc.batchlimit", "5",
"--snapshot=false",
Expand All @@ -128,6 +131,7 @@ func TestFlagsWithConfigAndFlags(t *testing.T) {

require.Equal(t, c.config.Identity, "Anon")
require.Equal(t, c.config.DataDir, "")
require.Equal(t, c.config.KeyStoreDir, "")
require.Equal(t, c.config.Verbosity, 0)
require.Equal(t, c.config.RPCBatchLimit, uint64(5))
require.Equal(t, c.config.Snapshot, false)
Expand Down
1 change: 1 addition & 0 deletions internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ func DefaultConfig() *Config {
DataDir: DefaultDataDir(),
Ancient: "",
DBEngine: "leveldb",
KeyStoreDir: "",
Logging: &LoggingConfig{
Vmodule: "",
Json: false,
Expand Down
1 change: 1 addition & 0 deletions internal/cli/server/config_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestConfigLegacy(t *testing.T) {

testConfig.Identity = ""
testConfig.DataDir = "./data"
testConfig.KeyStoreDir = "./keystore"
testConfig.Verbosity = 3
testConfig.RPCBatchLimit = 0
testConfig.Snapshot = true
Expand Down
7 changes: 4 additions & 3 deletions internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {
Default: c.cliConfig.DBEngine,
})
f.StringFlag(&flagset.StringFlag{
Name: "keystore",
Usage: "Path of the directory where keystores are located",
Value: &c.cliConfig.KeyStoreDir,
Name: "keystore",
Usage: "Path of the directory where keystores are located",
Value: &c.cliConfig.KeyStoreDir,
Default: c.cliConfig.KeyStoreDir,
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "rpc.batchlimit",
Expand Down
1 change: 1 addition & 0 deletions internal/cli/server/testdata/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
identity = ""
datadir = "./data"
keystore = "./keystore"
verbosity = 3
"rpc.batchlimit" = 0
snapshot = true
Expand Down

0 comments on commit adfd428

Please sign in to comment.