mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2025-01-11 17:24:09 +00:00
switch tests cleanup
This commit is contained in:
parent
579cb8765a
commit
ed372b5fab
@ -1,20 +1,21 @@
|
|||||||
import unittest, tables, options
|
import unittest, tables, options
|
||||||
import chronos, chronicles
|
import chronos, chronicles
|
||||||
import ../libp2p/switch,
|
import ../libp2p/[switch,
|
||||||
../libp2p/multistream,
|
multistream,
|
||||||
../libp2p/protocols/identify,
|
protocols/identify,
|
||||||
../libp2p/connection,
|
connection,
|
||||||
../libp2p/transports/[transport, tcptransport],
|
transports/transport,
|
||||||
../libp2p/multiaddress,
|
transports/tcptransport,
|
||||||
../libp2p/peerinfo,
|
multiaddress,
|
||||||
../libp2p/crypto/crypto,
|
peerinfo,
|
||||||
../libp2p/peer,
|
crypto/crypto,
|
||||||
../libp2p/protocols/protocol,
|
peer,
|
||||||
../libp2p/muxers/muxer,
|
protocols/protocol,
|
||||||
../libp2p/muxers/mplex/mplex,
|
muxers/muxer,
|
||||||
../libp2p/muxers/mplex/types,
|
muxers/mplex/mplex,
|
||||||
../libp2p/protocols/secure/secio,
|
muxers/mplex/types,
|
||||||
../libp2p/protocols/secure/secure
|
protocols/secure/secio,
|
||||||
|
protocols/secure/secure]
|
||||||
|
|
||||||
const TestCodec = "/test/proto/1.0.0"
|
const TestCodec = "/test/proto/1.0.0"
|
||||||
|
|
||||||
@ -51,8 +52,8 @@ suite "Switch":
|
|||||||
result = (switch, peerInfo)
|
result = (switch, peerInfo)
|
||||||
|
|
||||||
proc testSwitch(): Future[bool] {.async, gcsafe.} =
|
proc testSwitch(): Future[bool] {.async, gcsafe.} =
|
||||||
let ma1: MultiAddress = Multiaddress.init("/ip4/127.0.0.1/tcp/53370")
|
let ma1: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0")
|
||||||
let ma2: MultiAddress = Multiaddress.init("/ip4/127.0.0.1/tcp/53371")
|
let ma2: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0")
|
||||||
|
|
||||||
var peerInfo1, peerInfo2: PeerInfo
|
var peerInfo1, peerInfo2: PeerInfo
|
||||||
var switch1, switch2: Switch
|
var switch1, switch2: Switch
|
||||||
@ -66,7 +67,7 @@ suite "Switch":
|
|||||||
|
|
||||||
(switch2, peerInfo2) = createSwitch(ma2)
|
(switch2, peerInfo2) = createSwitch(ma2)
|
||||||
var switch2Fut = await switch2.start()
|
var switch2Fut = await switch2.start()
|
||||||
let conn = await switch2.dial(peerInfo1, TestCodec)
|
let conn = await switch2.dial(switch1.peerInfo, TestCodec)
|
||||||
await conn.writeLp("Hello!")
|
await conn.writeLp("Hello!")
|
||||||
let msg = cast[string](await conn.readLp())
|
let msg = cast[string](await conn.readLp())
|
||||||
check "Hello!" == msg
|
check "Hello!" == msg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user