Compare commits

...

2 Commits

Author SHA1 Message Date
Ludovic Chenut f676cf0c86
fix: relay with yamux connection data exceeded 2024-06-27 17:00:29 +02:00
Ludovic Chenut 69d8ffaefb
chore: remove sleep 2024-06-27 16:37:37 +02:00
2 changed files with 9 additions and 7 deletions

View File

@ -258,9 +258,9 @@ suite "Circuit Relay V2":
await allFutures(src.stop(), dst.stop(), rel.stop())
asyncTest "Connection data exceeded":
ldata = 1000
ldata = 1500
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))
await conn.writeLp("do you expect a lorem ipsum or...?")
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
take to the ship."""
)
await conn.close()
rv2 = Relay.new(
reservationTTL = initDuration(seconds = ttl),
limitDuration = ldur,
@ -305,7 +306,7 @@ suite "Circuit Relay V2":
rsvp = await dstCl.reserve(rel.peerInfo.peerId, rel.peerInfo.addrs)
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:
"do you expect a lorem ipsum or...?" ==
string.fromBytes(await conn.readLp(1024))

View File

@ -39,6 +39,7 @@ suite "Yamux":
conna.close(), connb.close(), yamuxa.close(), yamuxb.close(), handlera, handlerb
)
suite "Simple Reading/Writing yamux messages":
asyncTest "Roundtrip of small messages":
mSetup()
@ -197,13 +198,14 @@ suite "Yamux":
await writerBlocker
try:
var buffer: array[256, byte]
check:
(await conn.readOnce(addr buffer[0], 256)) == 0
while true:
# will crash when reset is received
discard await conn.readOnce(addr buffer[0], 256)
except CancelledError, LPStreamError:
return
finally:
readerBlocker.complete()
await conn.close()
readerBlocker.complete()
let streamA = await yamuxa.newStream()
check streamA == yamuxa.getStreams()[0]
@ -215,7 +217,6 @@ suite "Yamux":
for i in 0 .. 3:
expect(LPStreamEOFError):
await wrFut[i]
await sleepAsync(50.millis) # waiting for reset to be send
writerBlocker.complete()
await readerBlocker
await streamA.close()