Compare commits
2 Commits
50c813cda3
...
f676cf0c86
Author | SHA1 | Date |
---|---|---|
Ludovic Chenut | f676cf0c86 | |
Ludovic Chenut | 69d8ffaefb |
|
@ -258,9 +258,9 @@ suite "Circuit Relay V2":
|
||||||
await allFutures(src.stop(), dst.stop(), rel.stop())
|
await allFutures(src.stop(), dst.stop(), rel.stop())
|
||||||
|
|
||||||
asyncTest "Connection data exceeded":
|
asyncTest "Connection data exceeded":
|
||||||
ldata = 1000
|
ldata = 1500
|
||||||
proto.handler = proc(conn: Connection, proto: string) {.async.} =
|
proto.handler = proc(conn: Connection, proto: string) {.async.} =
|
||||||
check "count me the better story you know" ==
|
check "count me the best story you know" ==
|
||||||
string.fromBytes(await conn.readLp(1024))
|
string.fromBytes(await conn.readLp(1024))
|
||||||
await conn.writeLp("do you expect a lorem ipsum or...?")
|
await conn.writeLp("do you expect a lorem ipsum or...?")
|
||||||
check "surprise me!" == string.fromBytes(await conn.readLp(1024))
|
check "surprise me!" == string.fromBytes(await conn.readLp(1024))
|
||||||
|
@ -281,6 +281,7 @@ suite "Circuit Relay V2":
|
||||||
philosophical flourish Cato throws himself upon his sword; I quietly
|
philosophical flourish Cato throws himself upon his sword; I quietly
|
||||||
take to the ship."""
|
take to the ship."""
|
||||||
)
|
)
|
||||||
|
await conn.close()
|
||||||
rv2 = Relay.new(
|
rv2 = Relay.new(
|
||||||
reservationTTL = initDuration(seconds = ttl),
|
reservationTTL = initDuration(seconds = ttl),
|
||||||
limitDuration = ldur,
|
limitDuration = ldur,
|
||||||
|
@ -305,7 +306,7 @@ suite "Circuit Relay V2":
|
||||||
|
|
||||||
rsvp = await dstCl.reserve(rel.peerInfo.peerId, rel.peerInfo.addrs)
|
rsvp = await dstCl.reserve(rel.peerInfo.peerId, rel.peerInfo.addrs)
|
||||||
conn = await src.dial(dst.peerInfo.peerId, @[addrs], customProtoCodec)
|
conn = await src.dial(dst.peerInfo.peerId, @[addrs], customProtoCodec)
|
||||||
await conn.writeLp("count me the better story you know")
|
await conn.writeLp("count me the best story you know")
|
||||||
check:
|
check:
|
||||||
"do you expect a lorem ipsum or...?" ==
|
"do you expect a lorem ipsum or...?" ==
|
||||||
string.fromBytes(await conn.readLp(1024))
|
string.fromBytes(await conn.readLp(1024))
|
||||||
|
|
|
@ -39,6 +39,7 @@ suite "Yamux":
|
||||||
conna.close(), connb.close(), yamuxa.close(), yamuxb.close(), handlera, handlerb
|
conna.close(), connb.close(), yamuxa.close(), yamuxb.close(), handlera, handlerb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
suite "Simple Reading/Writing yamux messages":
|
suite "Simple Reading/Writing yamux messages":
|
||||||
asyncTest "Roundtrip of small messages":
|
asyncTest "Roundtrip of small messages":
|
||||||
mSetup()
|
mSetup()
|
||||||
|
@ -197,13 +198,14 @@ suite "Yamux":
|
||||||
await writerBlocker
|
await writerBlocker
|
||||||
try:
|
try:
|
||||||
var buffer: array[256, byte]
|
var buffer: array[256, byte]
|
||||||
check:
|
while true:
|
||||||
(await conn.readOnce(addr buffer[0], 256)) == 0
|
# will crash when reset is received
|
||||||
|
discard await conn.readOnce(addr buffer[0], 256)
|
||||||
except CancelledError, LPStreamError:
|
except CancelledError, LPStreamError:
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
readerBlocker.complete()
|
|
||||||
await conn.close()
|
await conn.close()
|
||||||
|
readerBlocker.complete()
|
||||||
|
|
||||||
let streamA = await yamuxa.newStream()
|
let streamA = await yamuxa.newStream()
|
||||||
check streamA == yamuxa.getStreams()[0]
|
check streamA == yamuxa.getStreams()[0]
|
||||||
|
@ -215,7 +217,6 @@ suite "Yamux":
|
||||||
for i in 0 .. 3:
|
for i in 0 .. 3:
|
||||||
expect(LPStreamEOFError):
|
expect(LPStreamEOFError):
|
||||||
await wrFut[i]
|
await wrFut[i]
|
||||||
await sleepAsync(50.millis) # waiting for reset to be send
|
|
||||||
writerBlocker.complete()
|
writerBlocker.complete()
|
||||||
await readerBlocker
|
await readerBlocker
|
||||||
await streamA.close()
|
await streamA.close()
|
||||||
|
|
Loading…
Reference in New Issue