diff --git a/libp2p/connection.nim b/libp2p/connection.nim index aaa281544..ae47d0439 100644 --- a/libp2p/connection.nim +++ b/libp2p/connection.nim @@ -15,7 +15,7 @@ import peerinfo, varint, vbuffer -const DefaultReadSize*: uint = 64 * 1024 +const DefaultReadSize*: uint = 1 shl 20 # 1mb, in order to fit mplex spec type Connection* = ref object of LPStream diff --git a/libp2p/muxers/mplex/mplex.nim b/libp2p/muxers/mplex/mplex.nim index 2d4c7ac77..b2b610593 100644 --- a/libp2p/muxers/mplex/mplex.nim +++ b/libp2p/muxers/mplex/mplex.nim @@ -113,7 +113,7 @@ method handle*(m: Mplex) {.async, gcsafe.} = size = data.len if data.len > MaxMsgSize: - raise newLPStreamLimitError(); + raise newLPStreamLimitError(); await channel.pushTo(data) of MessageType.CloseIn, MessageType.CloseOut: trace "closing channel", id = id, diff --git a/tests/testmplex.nim b/tests/testmplex.nim index f88e6f916..49b1001d6 100644 --- a/tests/testmplex.nim +++ b/tests/testmplex.nim @@ -187,9 +187,11 @@ suite "Mplex": proc connHandler(conn: Connection) {.async, gcsafe.} = proc handleMplexListen(stream: Connection) {.async, gcsafe.} = + defer: + await stream.close() let msg = await stream.readLp() - check cast[string](msg) == "Hello from stream!" - await stream.close() + # we should not reach this anyway!! + check false listenJob.complete() let mplexListen = newMplex(conn) @@ -198,9 +200,13 @@ suite "Mplex": let transport1: TcpTransport = newTransport(TcpTransport) discard await transport1.listen(ma, connHandler) + defer: + await transport1.close() let transport2: TcpTransport = newTransport(TcpTransport) let conn = await transport2.dial(transport1.ma) + defer: + await conn.close() let mplexDial = newMplex(conn) let stream = await mplexDial.newStream() @@ -208,8 +214,11 @@ suite "Mplex": for _ in 0..