2019-06-10 23:20:18 +00:00
|
|
|
import
|
|
|
|
unittest, os,
|
|
|
|
chronos, confutils,
|
|
|
|
../beacon_chain/[conf, eth2_network]
|
|
|
|
|
|
|
|
template asyncTest*(name, body: untyped) =
|
2019-12-06 16:07:58 +00:00
|
|
|
timedTest name:
|
2019-06-10 23:20:18 +00:00
|
|
|
proc scenario {.async.} = body
|
|
|
|
waitFor scenario()
|
|
|
|
|
|
|
|
asyncTest "connect two nodes":
|
|
|
|
let tempDir = getTempDir() / "peers_test"
|
|
|
|
|
|
|
|
var c1 = BeaconNodeConf.defaults
|
|
|
|
c1.dataDir = OutDir(tempDir / "node-1")
|
2019-06-12 18:22:05 +00:00
|
|
|
c1.tcpPort = 50000
|
|
|
|
c1.nat = "none"
|
2019-06-12 12:23:05 +00:00
|
|
|
|
|
|
|
var n1PersistentAddress = c1.getPersistenBootstrapAddr(
|
2019-06-12 18:22:05 +00:00
|
|
|
parseIpAddress("127.0.0.1"), Port c1.tcpPort)
|
2019-06-12 12:23:05 +00:00
|
|
|
|
2019-06-10 23:20:18 +00:00
|
|
|
var n1 = await createEth2Node(c1)
|
2019-06-12 12:23:05 +00:00
|
|
|
|
2019-06-12 18:22:05 +00:00
|
|
|
echo "Node 1 persistent address: ", n1PersistentAddress
|
|
|
|
|
2020-01-24 08:32:52 +00:00
|
|
|
var n1ActualAddress = await n1.daemon.identity()
|
|
|
|
echo "Node 1 actual address:", n1ActualAddress
|
2019-06-12 12:23:05 +00:00
|
|
|
|
|
|
|
echo "Press any key to continue"
|
|
|
|
discard stdin.readLine()
|
2019-06-10 23:20:18 +00:00
|
|
|
|
|
|
|
var c2 = BeaconNodeConf.defaults
|
|
|
|
c2.dataDir = OutDir(tempDir / "node-2")
|
2019-06-12 18:22:05 +00:00
|
|
|
c2.tcpPort = 50001
|
|
|
|
c2.nat = "none"
|
2019-06-10 23:20:18 +00:00
|
|
|
var n2 = await createEth2Node(c2)
|
|
|
|
|
2020-03-22 23:23:21 +00:00
|
|
|
await n2.connectToNetwork(@[n1PersistentAddress])
|
2019-06-10 23:20:18 +00:00
|
|
|
|