mirror of
https://github.com/status-im/nim-eth.git
synced 2025-02-17 16:37:15 +00:00
Make connection setup in protocol_handlers test more deterministic
This commit is contained in:
parent
0a5d6118c2
commit
d1eb1070fc
@ -56,17 +56,14 @@ suite "Testing protocol handlers":
|
|||||||
let bootENode = await setupBootNode()
|
let bootENode = await setupBootNode()
|
||||||
var node1 = setupTestNode(abc, xyz)
|
var node1 = setupTestNode(abc, xyz)
|
||||||
var node2 = setupTestNode(abc, xyz)
|
var node2 = setupTestNode(abc, xyz)
|
||||||
# node2 listening and node1 not, to avoid many incoming vs outgoing
|
|
||||||
var node1Connected = node1.connectToNetwork(@[bootENode], false, true)
|
|
||||||
var node2Connected = node2.connectToNetwork(@[bootENode], true, true)
|
|
||||||
await node1Connected
|
|
||||||
await node2Connected
|
|
||||||
check:
|
|
||||||
node1.peerPool.connectedNodes.len() == 1
|
|
||||||
node2.peerPool.connectedNodes.len() == 1
|
|
||||||
|
|
||||||
for peer in node1.peers():
|
node2.startListening()
|
||||||
await peer.disconnect(SubprotocolReason, true)
|
let peer = await node1.rlpxConnect(newNode(initENode(node2.keys.pubKey,
|
||||||
|
node2.address)))
|
||||||
|
check:
|
||||||
|
peer.isNil == false
|
||||||
|
|
||||||
|
await peer.disconnect(SubprotocolReason, true)
|
||||||
check:
|
check:
|
||||||
# we want to check that even though the exceptions in the disconnect
|
# we want to check that even though the exceptions in the disconnect
|
||||||
# handlers, each handler still ran
|
# handlers, each handler still ran
|
||||||
@ -78,7 +75,7 @@ suite "Testing protocol handlers":
|
|||||||
var node2 = setupTestNode(hah)
|
var node2 = setupTestNode(hah)
|
||||||
node2.startListening()
|
node2.startListening()
|
||||||
let peer = await node1.rlpxConnect(newNode(initENode(node2.keys.pubKey,
|
let peer = await node1.rlpxConnect(newNode(initENode(node2.keys.pubKey,
|
||||||
node2.address)))
|
node2.address)))
|
||||||
check:
|
check:
|
||||||
peer.isNil == true
|
peer.isNil == true
|
||||||
# To check if the disconnection handler did not run
|
# To check if the disconnection handler did not run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user