fix enable rpc logic in makeConfig

This commit is contained in:
jangko 2022-06-16 13:58:10 +07:00
parent c123e1eb93
commit 00a43234d7
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 33 additions and 2 deletions

View File

@ -679,8 +679,11 @@ proc makeConfig*(cmdLine = commandLineParams()): NimbusConf =
result.udpPort = result.tcpPort
# enable rpc server or ws server if they share common port with engine api
result.rpcEnabled = result.engineApiEnabled and (result.engineApiPort == result.rpcPort)
result.wsEnabled = result.engineApiWsEnabled and (result.engineApiWsPort == result.wsPort)
let rpcMustEnabled = result.engineApiEnabled and (result.engineApiPort == result.rpcPort)
let wsMustEnabled = result.engineApiWsEnabled and (result.engineApiWsPort == result.wsPort)
result.rpcEnabled = result.rpcEnabled or rpcMustEnabled
result.wsEnabled = result.wsEnabled or wsMustEnabled
when isMainModule:
# for testing purpose

View File

@ -179,5 +179,33 @@ proc configurationMain*() =
check conf.networkParams.config.londonBlock == 1337
check conf.getBootnodes().len == 0
test "json-rpc enabled when json-engine api enabled and share same port":
let conf = makeConfig(@["--engine-api", "--engine-api-port:8545", "--rpc-port:8545"])
check conf.engineApiEnabled
check conf.rpcEnabled
check conf.wsEnabled == false
check conf.engineApiWsEnabled == false
test "ws-rpc enabled when ws-engine api enabled and share same port":
let conf = makeConfig(@["--engine-api-ws", "--engine-api-ws-port:8546", "--ws-port:8546"])
check conf.engineApiWsEnabled
check conf.wsEnabled
check conf.engineApiEnabled == false
check conf.rpcEnabled == false
test "json-rpc stay enabled when json-engine api enabled and using different port":
let conf = makeConfig(@["--rpc", "--engine-api", "--engine-api-port:8550", "--rpc-port:8545"])
check conf.engineApiEnabled
check conf.rpcEnabled
check conf.engineApiWsEnabled == false
check conf.wsEnabled == false
test "ws-rpc stay enabled when ws-engine api enabled and using different port":
let conf = makeConfig(@["--ws", "--engine-api-ws", "--engine-api-ws-port:8551", "--ws-port:8546"])
check conf.engineApiWsEnabled
check conf.wsEnabled
check conf.engineApiEnabled == false
check conf.rpcEnabled == false
when isMainModule:
configurationMain()