-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connect is able to force a new connection (#849)
- Loading branch information
1 parent
ca19f8f
commit 4ace70d
Showing
4 changed files
with
70 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Nim-LibP2P | ||
# Copyright (c) 2023 Status Research & Development GmbH | ||
# Licensed under either of | ||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) | ||
# * MIT license ([LICENSE-MIT](LICENSE-MIT)) | ||
# at your option. | ||
# This file may not be copied, modified, or distributed except according to | ||
# those terms. | ||
|
||
import std/options | ||
import chronos | ||
import unittest2 | ||
import ../libp2p/[builders, | ||
switch] | ||
import ./helpers | ||
|
||
suite "Dialer": | ||
teardown: | ||
checkTrackers() | ||
|
||
asyncTest "Connect forces a new connection": | ||
|
||
let | ||
src = newStandardSwitch() | ||
dst = newStandardSwitch() | ||
|
||
await dst.start() | ||
|
||
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs) | ||
check src.connManager.connCount(dst.peerInfo.peerId) == 1 | ||
|
||
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs) | ||
check src.connManager.connCount(dst.peerInfo.peerId) == 1 | ||
|
||
await src.connect(dst.peerInfo.peerId, dst.peerInfo.addrs, true, false) | ||
check src.connManager.connCount(dst.peerInfo.peerId) == 2 | ||
|
||
await allFutures(src.stop(), dst.stop()) |