mirror of
https://github.com/vacp2p/nim-libp2p-experimental.git
synced 2025-02-23 07:18:25 +00:00
fix first interop test (#398)
This commit is contained in:
parent
556213abf4
commit
bd70515087
@ -220,13 +220,10 @@ suite "Interop":
|
|||||||
var testFuture = newFuture[void]("test.future")
|
var testFuture = newFuture[void]("test.future")
|
||||||
proc daemonHandler(api: DaemonAPI, stream: P2PStream) {.async.} =
|
proc daemonHandler(api: DaemonAPI, stream: P2PStream) {.async.} =
|
||||||
check string.fromBytes(await stream.transp.readLp()) == "test 1"
|
check string.fromBytes(await stream.transp.readLp()) == "test 1"
|
||||||
asyncDiscard stream.transp.writeLp("test 2")
|
discard await stream.transp.writeLp("test 2")
|
||||||
|
|
||||||
await sleepAsync(10.millis)
|
|
||||||
check string.fromBytes(await stream.transp.readLp()) == "test 3"
|
check string.fromBytes(await stream.transp.readLp()) == "test 3"
|
||||||
asyncDiscard stream.transp.writeLp("test 4")
|
discard await stream.transp.writeLp("test 4")
|
||||||
testFuture.complete()
|
testFuture.complete()
|
||||||
await stream.close()
|
|
||||||
|
|
||||||
await daemonNode.addHandler(protos, daemonHandler)
|
await daemonNode.addHandler(protos, daemonHandler)
|
||||||
let conn = await nativeNode.dial(NativePeerInfo.init(daemonPeer.peer,
|
let conn = await nativeNode.dial(NativePeerInfo.init(daemonPeer.peer,
|
||||||
@ -234,27 +231,21 @@ suite "Interop":
|
|||||||
protos[0])
|
protos[0])
|
||||||
await conn.writeLp("test 1")
|
await conn.writeLp("test 1")
|
||||||
check "test 2" == string.fromBytes((await conn.readLp(1024)))
|
check "test 2" == string.fromBytes((await conn.readLp(1024)))
|
||||||
await sleepAsync(10.millis)
|
|
||||||
|
|
||||||
await conn.writeLp("test 3")
|
await conn.writeLp("test 3")
|
||||||
check "test 4" == string.fromBytes((await conn.readLp(1024)))
|
check "test 4" == string.fromBytes((await conn.readLp(1024)))
|
||||||
|
|
||||||
await wait(testFuture, 10.secs)
|
await wait(testFuture, 10.secs)
|
||||||
await conn.close()
|
|
||||||
|
|
||||||
await daemonNode.close()
|
|
||||||
await nativeNode.stop()
|
await nativeNode.stop()
|
||||||
|
await daemonNode.close()
|
||||||
await allFutures(awaiters)
|
await allFutures(awaiters)
|
||||||
|
|
||||||
await sleepAsync(1.seconds)
|
await sleepAsync(1.seconds)
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
when defined(windows):
|
check:
|
||||||
# TODO Repair this test on windows
|
waitFor(runTests()) == true
|
||||||
skip()
|
|
||||||
else:
|
|
||||||
check:
|
|
||||||
waitFor(runTests()) == true
|
|
||||||
|
|
||||||
test "native -> daemon connection":
|
test "native -> daemon connection":
|
||||||
proc runTests(): Future[bool] {.async.} =
|
proc runTests(): Future[bool] {.async.} =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user