mirror of https://github.com/vacp2p/nim-libp2p.git
wip
This commit is contained in:
parent
0f691cbafd
commit
46daed9a38
|
@ -77,7 +77,6 @@ proc newChannel*(id: uint64,
|
|||
result.msgCode = if initiator: MessageType.MsgOut else: MessageType.MsgIn
|
||||
result.closeCode = if initiator: MessageType.CloseOut else: MessageType.CloseIn
|
||||
result.resetCode = if initiator: MessageType.ResetOut else: MessageType.ResetIn
|
||||
result.writeLock = newAsyncLock()
|
||||
result.isLazy = lazy
|
||||
|
||||
let chan = result
|
||||
|
@ -178,6 +177,7 @@ method close*(s: LPChannel) {.async, gcsafe.} =
|
|||
s.closedLocal = true
|
||||
if s.atEof: # already closed by remote close parent buffer imediately
|
||||
await procCall BufferStream(s).close()
|
||||
|
||||
trace "lpchannel closed local", id = s.id,
|
||||
initiator = s.initiator,
|
||||
name = s.name,
|
||||
|
|
|
@ -276,11 +276,12 @@ suite "Mplex":
|
|||
let mplexDial = newMplex(conn)
|
||||
let stream = await mplexDial.newStream(lazy = true)
|
||||
let mplexDialFut = mplexDial.handle()
|
||||
check not LPChannel(stream.stream).isOpen # assert lazy
|
||||
let openState = cast[LPChannel](stream).isOpen
|
||||
await stream.writeLp("HELLO")
|
||||
check LPChannel(stream.stream).isOpen # assert lazy
|
||||
await stream.close()
|
||||
|
||||
check not openState # assert lazy
|
||||
|
||||
await done.wait(1.seconds)
|
||||
await conn.close()
|
||||
await mplexDialFut
|
||||
|
@ -387,6 +388,7 @@ suite "Mplex":
|
|||
check string.fromBytes(msg) == &"stream {count}!"
|
||||
count.inc
|
||||
await stream.close()
|
||||
count.inc
|
||||
if count == 10:
|
||||
done.complete()
|
||||
|
||||
|
|
Loading…
Reference in New Issue