config: fixes bug networkid parser

previously it mistakenly parse into the `result`
now it correctly parse networkId into res.
This commit is contained in:
jangko 2021-08-05 16:40:53 +07:00
parent c69e57e5d4
commit 1da4346295
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 18 additions and 3 deletions

View File

@ -546,7 +546,7 @@ proc processNetArguments(key, value: string): ConfigStatus =
var res = 0
result = processInteger(value, res)
if result == Success:
config.net.setNetwork(NetworkId(result))
config.net.setNetwork(NetworkId(res))
config.net.flags.incl NetworkIdSet
elif skey == "nodiscover":
config.net.flags.incl(NoDiscover)

View File

@ -1,11 +1,14 @@
import
std/[os, parseopt],
unittest2, stew/byteutils,
eth/common/eth_types,
../nimbus/vm_internals
eth/p2p,
../nimbus/vm_internals,
../nimbus/config
func toAddress(n: int): EthAddress =
result[19] = n.byte
func toAddress(a, b: int): EthAddress =
result[18] = a.byte
result[19] = b.byte
@ -22,5 +25,17 @@ proc miscMain*() =
check toAddress(0x10, 0x0).toInt == 0x1000
check toAddress(0x10, 0x0, 0x0).toInt == 0x100000
test "networkid cli":
var msg: string
const genesisFile = "tests" / "customgenesis" / "calaveras.json"
var opt = initOptParser("--customnetwork:" & genesisFile & " --networkid:123")
let res = processArguments(msg, opt)
if res != Success:
echo msg
quit(QuitFailure)
let conf = getConfiguration()
check conf.net.networkId == 123.NetworkId
when isMainModule:
miscMain()