logos-messaging-nim/tests/v1/test_helpers.nim
Kim De Mey 95438b9389
Bump vendor, fix builds and add v2 to CI (#45)
* Fix v2 builds, break v1 builds

* Fix build after nim-eth bump

* Add waku v2 build and tests to CI

* Fix parallel build issues by renaming
2020-07-13 12:08:03 +02:00

35 lines
921 B
Nim

import
unittest, chronos, strutils,
eth/[keys, p2p]
var nextPort = 30303
proc localAddress*(port: int): Address =
let port = Port(port)
result = Address(udpPort: port, tcpPort: port,
ip: parseIpAddress("127.0.0.1"))
proc setupTestNode*(
rng: ref BrHmacDrbgContext,
capabilities: varargs[ProtocolInfo, `protocolInfo`]): EthereumNode =
let keys1 = KeyPair.random(rng[])
result = newEthereumNode(keys1, localAddress(nextPort), 1, nil,
addAllCapabilities = false, rng = rng)
nextPort.inc
for capability in capabilities:
result.addCapability capability
template asyncTest*(name, body: untyped) =
test name:
proc scenario {.async.} = body
waitFor scenario()
template procSuite*(name, body: untyped) =
proc suitePayload =
suite name:
body
suitePayload()
template sourceDir*: string = currentSourcePath.rsplit(DirSep, 1)[0]