fix tests
This commit is contained in:
parent
a35ecc6227
commit
6bb4e91a39
|
@ -165,9 +165,7 @@ suite "Mplex":
|
||||||
discard mplexListen.handle()
|
discard mplexListen.handle()
|
||||||
|
|
||||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
let transport1: TcpTransport = newTransport(TcpTransport)
|
||||||
discard await transport1.listen(ma, connHandler)
|
let listenFut = await transport1.listen(ma, connHandler)
|
||||||
defer:
|
|
||||||
await transport1.close()
|
|
||||||
|
|
||||||
let transport2: TcpTransport = newTransport(TcpTransport)
|
let transport2: TcpTransport = newTransport(TcpTransport)
|
||||||
let conn = await transport2.dial(transport1.ma)
|
let conn = await transport2.dial(transport1.ma)
|
||||||
|
@ -177,9 +175,14 @@ suite "Mplex":
|
||||||
let openState = cast[LPChannel](stream.stream).isOpen
|
let openState = cast[LPChannel](stream.stream).isOpen
|
||||||
await stream.writeLp("Hello from stream!")
|
await stream.writeLp("Hello from stream!")
|
||||||
await conn.close()
|
await conn.close()
|
||||||
|
|
||||||
check not openState # assert lazy
|
check not openState # assert lazy
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
await mplexDial.close()
|
||||||
|
await transport1.close()
|
||||||
|
await listenFut
|
||||||
|
|
||||||
check:
|
check:
|
||||||
waitFor(testNewStream()) == true
|
waitFor(testNewStream()) == true
|
||||||
|
|
||||||
|
@ -208,9 +211,7 @@ suite "Mplex":
|
||||||
discard mplexListen.handle()
|
discard mplexListen.handle()
|
||||||
|
|
||||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
let transport1: TcpTransport = newTransport(TcpTransport)
|
||||||
discard await transport1.listen(ma, connHandler)
|
let listenFut = await transport1.listen(ma, connHandler)
|
||||||
defer:
|
|
||||||
await transport1.close()
|
|
||||||
|
|
||||||
let transport2: TcpTransport = newTransport(TcpTransport)
|
let transport2: TcpTransport = newTransport(TcpTransport)
|
||||||
let conn = await transport2.dial(transport1.ma)
|
let conn = await transport2.dial(transport1.ma)
|
||||||
|
@ -232,6 +233,10 @@ suite "Mplex":
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
await mplexDial.close()
|
||||||
|
await transport1.close()
|
||||||
|
await listenFut
|
||||||
|
|
||||||
check:
|
check:
|
||||||
waitFor(testNewStream()) == true
|
waitFor(testNewStream()) == true
|
||||||
|
|
||||||
|
@ -249,9 +254,7 @@ suite "Mplex":
|
||||||
await mplexListen.handle()
|
await mplexListen.handle()
|
||||||
|
|
||||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
let transport1: TcpTransport = newTransport(TcpTransport)
|
||||||
discard await transport1.listen(ma, connHandler)
|
let listenFut = await transport1.listen(ma, connHandler)
|
||||||
defer:
|
|
||||||
await transport1.close()
|
|
||||||
|
|
||||||
let transport2: TcpTransport = newTransport(TcpTransport)
|
let transport2: TcpTransport = newTransport(TcpTransport)
|
||||||
let conn = await transport2.dial(transport1.ma)
|
let conn = await transport2.dial(transport1.ma)
|
||||||
|
@ -265,6 +268,10 @@ suite "Mplex":
|
||||||
# await dialFut
|
# await dialFut
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
await mplexDial.close()
|
||||||
|
await transport1.close()
|
||||||
|
await listenFut
|
||||||
|
|
||||||
check:
|
check:
|
||||||
waitFor(testNewStream()) == true
|
waitFor(testNewStream()) == true
|
||||||
|
|
||||||
|
@ -286,22 +293,26 @@ suite "Mplex":
|
||||||
mplexListen.streamHandler = handleMplexListen
|
mplexListen.streamHandler = handleMplexListen
|
||||||
await mplexListen.handle()
|
await mplexListen.handle()
|
||||||
|
|
||||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
let transport1 = newTransport(TcpTransport)
|
||||||
discard await transport1.listen(ma, connHandler)
|
let listenFut = await transport1.listen(ma, connHandler)
|
||||||
defer:
|
|
||||||
await transport1.close()
|
|
||||||
|
|
||||||
let transport2: TcpTransport = newTransport(TcpTransport)
|
let transport2: TcpTransport = newTransport(TcpTransport)
|
||||||
let conn = await transport2.dial(transport1.ma)
|
let conn = await transport2.dial(transport1.ma)
|
||||||
|
|
||||||
let mplexDial = newMplex(conn)
|
let mplexDial = newMplex(conn)
|
||||||
for i in 1..<10:
|
for i in 1..10:
|
||||||
let stream = await mplexDial.newStream()
|
let stream = await mplexDial.newStream()
|
||||||
await stream.writeLp(&"stream {i}!")
|
await stream.writeLp(&"stream {i}!")
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
||||||
await conn.close()
|
await sleepAsync(1.seconds) # allow messages to get to the handler
|
||||||
|
await conn.close() # TODO: chronos sockets don't seem to have half-closed functionality
|
||||||
|
|
||||||
|
await mplexDial.close()
|
||||||
await listenConn.close()
|
await listenConn.close()
|
||||||
|
await transport1.close()
|
||||||
|
await listenFut
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
@ -330,9 +341,7 @@ suite "Mplex":
|
||||||
= trace "completed listener")
|
= trace "completed listener")
|
||||||
|
|
||||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
let transport1: TcpTransport = newTransport(TcpTransport)
|
||||||
discard transport1.listen(ma, connHandler)
|
let transportFut = await transport1.listen(ma, connHandler)
|
||||||
defer:
|
|
||||||
await transport1.close()
|
|
||||||
|
|
||||||
let transport2: TcpTransport = newTransport(TcpTransport)
|
let transport2: TcpTransport = newTransport(TcpTransport)
|
||||||
let conn = await transport2.dial(transport1.ma)
|
let conn = await transport2.dial(transport1.ma)
|
||||||
|
@ -351,6 +360,8 @@ suite "Mplex":
|
||||||
await conn.close()
|
await conn.close()
|
||||||
await listenConn.close()
|
await listenConn.close()
|
||||||
await allFutures(dialFut, listenFut)
|
await allFutures(dialFut, listenFut)
|
||||||
|
await transport1.close()
|
||||||
|
await transportFut
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
@ -397,10 +408,7 @@ suite "Mplex":
|
||||||
discard mplexListen.handle()
|
discard mplexListen.handle()
|
||||||
|
|
||||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
let transport1: TcpTransport = newTransport(TcpTransport)
|
||||||
discard await transport1.listen(ma, connHandler)
|
let listenFut = await transport1.listen(ma, connHandler)
|
||||||
|
|
||||||
defer:
|
|
||||||
await transport1.close()
|
|
||||||
|
|
||||||
let transport2: TcpTransport = newTransport(TcpTransport)
|
let transport2: TcpTransport = newTransport(TcpTransport)
|
||||||
let conn = await transport2.dial(transport1.ma)
|
let conn = await transport2.dial(transport1.ma)
|
||||||
|
@ -442,6 +450,9 @@ suite "Mplex":
|
||||||
await conn.close()
|
await conn.close()
|
||||||
await complete
|
await complete
|
||||||
|
|
||||||
|
await transport1.close()
|
||||||
|
await listenFut
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
@ -465,10 +476,7 @@ suite "Mplex":
|
||||||
discard mplexListen.handle()
|
discard mplexListen.handle()
|
||||||
|
|
||||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
let transport1: TcpTransport = newTransport(TcpTransport)
|
||||||
discard await transport1.listen(ma, connHandler)
|
let listenFut = await transport1.listen(ma, connHandler)
|
||||||
|
|
||||||
defer:
|
|
||||||
await transport1.close()
|
|
||||||
|
|
||||||
let transport2: TcpTransport = newTransport(TcpTransport)
|
let transport2: TcpTransport = newTransport(TcpTransport)
|
||||||
let conn = await transport2.dial(transport1.ma)
|
let conn = await transport2.dial(transport1.ma)
|
||||||
|
@ -500,6 +508,9 @@ suite "Mplex":
|
||||||
await conn.close()
|
await conn.close()
|
||||||
await complete
|
await complete
|
||||||
|
|
||||||
|
await transport1.close()
|
||||||
|
await listenFut
|
||||||
|
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
|
Loading…
Reference in New Issue