fix default --key-store location if --data-dir is custom

This commit is contained in:
jangko 2022-12-22 11:17:04 +07:00
parent d98b3bb32d
commit e36d2f432a
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 25 additions and 1 deletions

View File

@ -23,7 +23,7 @@ import
],
stew/shims/net as stewNet,
eth/[common, net/nat, p2p/bootnodes, p2p/enode],
"."/[db/select_backend,
"."/[db/select_backend,
constants, vm_compile_info, version
],
common/chain_config
@ -733,6 +733,11 @@ proc makeConfig*(cmdLine = commandLineParams()): NimbusConf =
result.rpcEnabled = result.rpcEnabled or rpcMustEnabled
result.wsEnabled = result.wsEnabled or wsMustEnabled
# see issue #1346
if result.keyStore.string == defaultKeystoreDir() and
result.dataDir.string != defaultDataDir():
result.keyStore = OutDir(result.dataDir.string / "keystore")
when isMainModule:
# for testing purpose
discard makeConfig()

View File

@ -257,5 +257,24 @@ proc configurationMain*() =
let pkhex2 = rc2.get.seckey.toRaw.to0xHex
check pkhex1 == pkhex2
test "default key-store and default data-dir":
let conf = makeTestConfig()
check conf.keyStore.string == conf.dataDir.string / "keystore"
test "custom key-store and custom data-dir":
let conf = makeConfig(@["--key-store:banana", "--data-dir:apple"])
check conf.keyStore.string == "banana"
check conf.dataDir.string == "apple"
test "default key-store and custom data-dir":
let conf = makeConfig(@["--data-dir:apple"])
check conf.dataDir.string == "apple"
check conf.keyStore.string == "apple" / "keystore"
test "custom key-store and default data-dir":
let conf = makeConfig(@["--key-store:banana"])
check conf.dataDir.string == defaultDataDir()
check conf.keyStore.string == "banana"
when isMainModule:
configurationMain()