mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-26 10:55:41 +00:00
config: copy chainId to networkid if networkid not set in cli
although they are technically different, but in reality, many networks are using the same id for ChainId dan NetworkId. in this commit, we set networkid from config file's chainId.
This commit is contained in:
parent
4459fc3519
commit
5e87624315
@ -847,6 +847,13 @@ when declared(os.paramCount): # not available with `--app:lib`
|
||||
if config.net.discPort == 0:
|
||||
config.net.discPort = config.net.bindPort
|
||||
|
||||
if NetworkIdSet notin config.net.flags and config.net.networkId == CustomNet:
|
||||
# WARNING: networkId and chainId are two distinct things
|
||||
# they usage should not be mixed in other places
|
||||
# we only set networkId to chainId if networkId not set in cli and
|
||||
# we are using custom genesis/custom chain config via json file.
|
||||
config.net.networkId = NetworkId(config.customGenesis.config.chainId)
|
||||
|
||||
proc processArguments*(msg: var string): ConfigStatus =
|
||||
var opt = initOptParser()
|
||||
processArguments(msg, opt)
|
||||
|
@ -28,24 +28,36 @@ proc miscMain*() =
|
||||
const genesisFile = "tests" / "customgenesis" / "calaveras.json"
|
||||
test "networkid cli":
|
||||
var msg: string
|
||||
var opt = initOptParser("--customnetwork:" & genesisFile & " --networkid:123")
|
||||
var opt = initOptParser("--customnetwork:" & genesisFile & " --networkid:345")
|
||||
let res = processArguments(msg, opt)
|
||||
if res != Success:
|
||||
echo msg
|
||||
quit(QuitFailure)
|
||||
|
||||
let conf = getConfiguration()
|
||||
check conf.net.networkId == 123.NetworkId
|
||||
check conf.net.networkId == 345.NetworkId
|
||||
|
||||
test "networkid first, customnetwork next":
|
||||
var msg: string
|
||||
var opt = initOptParser(" --networkid:123 --customnetwork:" & genesisFile)
|
||||
var opt = initOptParser("--networkid:678 --customnetwork:" & genesisFile)
|
||||
let res = processArguments(msg, opt)
|
||||
if res != Success:
|
||||
echo msg
|
||||
quit(QuitFailure)
|
||||
|
||||
let conf = getConfiguration()
|
||||
check conf.net.networkId == 678.NetworkId
|
||||
|
||||
test "networkid not set, copy from chainId of customnetwork":
|
||||
let conf = getConfiguration()
|
||||
conf.net.flags.excl NetworkIdSet
|
||||
var msg: string
|
||||
var opt = initOptParser("--customnetwork:" & genesisFile)
|
||||
let res = processArguments(msg, opt)
|
||||
if res != Success:
|
||||
echo msg
|
||||
quit(QuitFailure)
|
||||
|
||||
check conf.net.networkId == 123.NetworkId
|
||||
|
||||
when isMainModule:
|
||||
|
Loading…
x
Reference in New Issue
Block a user