2020-04-04 20:45:00 -06:00
|
|
|
import chronos, nimcrypto/utils
|
2020-06-19 11:29:43 -06:00
|
|
|
import ../libp2p/[stream/connection,
|
2020-04-04 20:45:00 -06:00
|
|
|
stream/bufferstream]
|
|
|
|
|
2020-11-12 21:44:02 -06:00
|
|
|
import ./helpers
|
2020-04-04 20:45:00 -06:00
|
|
|
|
2020-11-12 21:44:02 -06:00
|
|
|
suite "Connection":
|
|
|
|
asyncTest "close":
|
2021-06-07 09:32:08 +02:00
|
|
|
var conn = BufferStream.new()
|
2020-11-12 21:44:02 -06:00
|
|
|
await conn.close()
|
2020-04-04 20:45:00 -06:00
|
|
|
check:
|
2020-11-12 21:44:02 -06:00
|
|
|
conn.closed == true
|
2020-04-04 20:45:00 -06:00
|
|
|
|
2020-11-12 21:44:02 -06:00
|
|
|
asyncTest "parent close":
|
2021-06-07 09:32:08 +02:00
|
|
|
var buf = BufferStream.new()
|
2020-11-12 21:44:02 -06:00
|
|
|
var conn = buf
|
2020-04-04 20:45:00 -06:00
|
|
|
|
2020-11-12 21:44:02 -06:00
|
|
|
await conn.close()
|
2020-04-04 20:45:00 -06:00
|
|
|
check:
|
2020-11-12 21:44:02 -06:00
|
|
|
conn.closed == true
|
|
|
|
buf.closed == true
|
2020-04-04 20:45:00 -06:00
|
|
|
|
2020-11-12 21:44:02 -06:00
|
|
|
asyncTest "child close":
|
2021-06-07 09:32:08 +02:00
|
|
|
var buf = BufferStream.new()
|
2020-11-12 21:44:02 -06:00
|
|
|
var conn = buf
|
2020-04-04 20:45:00 -06:00
|
|
|
|
2020-11-12 21:44:02 -06:00
|
|
|
await buf.close()
|
2020-04-04 20:45:00 -06:00
|
|
|
check:
|
2020-11-12 21:44:02 -06:00
|
|
|
conn.closed == true
|
|
|
|
buf.closed == true
|