Move the code from rlpx.nim in the base module as it now represents

a wider set of APIs.
This commit is contained in:
Zahary Karadjov 2018-07-12 14:14:22 +03:00
parent cf6b4d3084
commit 4335052e9f
5 changed files with 1446 additions and 1442 deletions

File diff suppressed because it is too large Load Diff

2
eth_p2p.nim.cfg Normal file
View File

@ -0,0 +1,2 @@
--out:"eth_p2p_test"

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
import sequtils, logging import sequtils, logging
import eth_keys, asyncdispatch2, byteutils import eth_keys, asyncdispatch2, byteutils
import eth_p2p/[discovery, kademlia, rlpx, enode] import eth_p2p/[discovery, kademlia, enode]
const clientId = "nim-eth-p2p/0.0.1" const clientId = "nim-eth-p2p/0.0.1"

View File

@ -9,7 +9,7 @@
import sequtils import sequtils
import eth_keys, asyncdispatch2 import eth_keys, asyncdispatch2
import eth_p2p/[discovery, kademlia, enode, rlpx] import eth_p2p
const clientId = "nim-eth-p2p/0.0.1" const clientId = "nim-eth-p2p/0.0.1"
@ -18,13 +18,16 @@ proc localAddress(port: int): Address =
result = Address(udpPort: port, tcpPort: port, ip: parseIpAddress("127.0.0.1")) result = Address(udpPort: port, tcpPort: port, ip: parseIpAddress("127.0.0.1"))
proc test() {.async.} = proc test() {.async.} =
let kp = newKeyPair() let node1Keys = newKeyPair()
let address = localAddress(20301) let node1Address = localAddress(30303)
var node1 = newEthereumNode(node1Keys, node1Address, 1, nil)
node1.startListening()
let s = connectToNetwork(kp, address, nil, [], clientId, 1) let node2Keys = newKeyPair()
var node2 = newEthereumNode(node2Keys, localAddress(30304), 1, nil)
let n = newNode(initENode(kp.pubKey, address)) let node1AsRemote = newNode(initENode(node1Keys.pubKey, node1Address))
let peer = await rlpxConnect(n, newKeyPair(), Port(1234), clientId) let peer = await node2.rlpxConnect(node1AsRemote)
doAssert(not peer.isNil) doAssert(not peer.isNil)