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()]
|