2023-11-01 03:32:09 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2023 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2023-10-19 03:28:52 +00:00
|
|
|
import
|
2023-10-23 13:59:57 +00:00
|
|
|
std/strutils,
|
|
|
|
./step_desc,
|
|
|
|
../test_env
|
2023-10-19 03:28:52 +00:00
|
|
|
|
|
|
|
# A step that launches a new client
|
2023-10-23 13:59:57 +00:00
|
|
|
type
|
|
|
|
LaunchClients* = ref object of TestStep
|
|
|
|
clientCount* : int
|
|
|
|
skipConnectingToBootnode*: bool
|
|
|
|
skipAddingToCLMock* : bool
|
2023-10-19 03:28:52 +00:00
|
|
|
|
2023-10-23 13:59:57 +00:00
|
|
|
func getClientCount(step: LaunchClients): int =
|
|
|
|
var clientCount = step.clientCount
|
|
|
|
if clientCount == 0:
|
2023-10-19 03:28:52 +00:00
|
|
|
clientCount = 1
|
|
|
|
return clientCount
|
|
|
|
|
2023-10-23 13:59:57 +00:00
|
|
|
method execute*(step: LaunchClients, ctx: CancunTestContext): bool =
|
2023-10-19 03:28:52 +00:00
|
|
|
# Launch a new client
|
2023-10-23 13:59:57 +00:00
|
|
|
let clientCount = step.getClientCount()
|
|
|
|
for i in 0..<clientCount:
|
|
|
|
let connectBootNode = not step.skipConnectingToBootnode
|
|
|
|
let addToClMock = not step.skipAddingToCLMock
|
|
|
|
discard ctx.env.addEngine(addToClMock, connectBootNode)
|
2023-10-19 03:28:52 +00:00
|
|
|
|
2023-10-23 13:59:57 +00:00
|
|
|
return true
|
|
|
|
|
|
|
|
method description*(step: LaunchClients): string =
|
|
|
|
"Launch $1 new engine client(s)" % [$step.getClientCount()]
|