nim-eth-p2p/tests/tserver.nim
cheatfate 24d762da34 Moved eth_p2p to asyncdispatch2.
Fix some warnings at rlpx.nim.
Commented debug echo in rlpx.nim.
2018-06-18 12:05:38 +03:00

31 lines
805 B
Nim

#
# Ethereum P2P
# (c) Copyright 2018
# Status Research & Development GmbH
#
# Licensed under either of
# Apache License, version 2.0, (LICENSE-APACHEv2)
# MIT license (LICENSE-MIT)
import sequtils
import eth_keys, asyncdispatch2
import eth_p2p/[discovery, kademlia, peer_pool, enode, server, rlpx]
proc localAddress(port: int): Address =
let port = Port(port)
result = Address(udpPort: port, tcpPort: port, ip: parseIpAddress("127.0.0.1"))
proc test() {.async.} =
let kp = newKeyPair()
let address = localAddress(20301)
let s = newP2PServer(kp, address, nil, [], 1)
s.start()
let n = newNode(initENode(kp.pubKey, address))
let peer = await rlpxConnect(n, newKeyPair(), Port(1234))
doAssert(not peer.isNil)
waitFor test()