add missing test

This commit is contained in:
Dmitriy Ryajov 2019-09-04 00:51:16 -06:00
parent 9b20dbc7ae
commit 6ce2782e5c
2 changed files with 12 additions and 3 deletions

View File

@ -68,12 +68,12 @@ proc reset*(s: Channel) {.async.} =
await allFutures(s.resetMessage(), s.remoteReset()) await allFutures(s.resetMessage(), s.remoteReset())
proc isReadEof(s: Channel): bool = proc isReadEof(s: Channel): bool =
bool((s.closedRemote or s.closedLocal) and s.len() <= 0) bool((s.closedRemote or s.closedLocal) and s.len() < 1)
method pushTo*(s: Channel, data: seq[byte]): Future[void] {.gcsafe.} = proc pushTo*(s: Channel, data: seq[byte]): Future[void] {.gcsafe.} =
if s.closedRemote: if s.closedRemote:
raise newLPStreamClosedError() raise newLPStreamClosedError()
result = procCall pushTo(BufferStream(s), data) result = procCall pushTo(BufferStream(s), data)
method read*(s: Channel, n = -1): Future[seq[byte]] {.gcsafe.} = method read*(s: Channel, n = -1): Future[seq[byte]] {.gcsafe.} =
if s.isReadEof(): if s.isReadEof():

View File

@ -178,3 +178,12 @@ suite "Mplex":
expect LPStreamClosedError: expect LPStreamClosedError:
waitFor(testResetWrite()) waitFor(testResetWrite())
test "should not allow pushing data to channel when remote end closed":
proc testResetWrite(): Future[void] {.async.} =
let chann = newChannel(1, newConnection(new LPStream), true)
await chann.closeRemote()
await chann.pushTo(@[byte(1)])
expect LPStreamClosedError:
waitFor(testResetWrite())