mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-05 11:34:45 +00:00
c3f57c79f5
* started working on historic api * very rough code * moved * also publishing * todos * added tests * added * fix
33 lines
841 B
Nim
33 lines
841 B
Nim
import
|
|
unittest, chronos,
|
|
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()
|