2020-04-05 02:45:00 +00:00
|
|
|
import chronos, nimcrypto/utils
|
2020-06-19 17:29:43 +00:00
|
|
|
import ../libp2p/[stream/connection,
|
2020-04-05 02:45:00 +00:00
|
|
|
stream/bufferstream]
|
|
|
|
|
2020-11-13 03:44:02 +00:00
|
|
|
import ./helpers
|
2020-04-05 02:45:00 +00:00
|
|
|
|
2020-11-13 03:44:02 +00:00
|
|
|
suite "Connection":
|
|
|
|
asyncTest "close":
|
|
|
|
var conn = newBufferStream()
|
|
|
|
await conn.close()
|
2020-04-05 02:45:00 +00:00
|
|
|
check:
|
2020-11-13 03:44:02 +00:00
|
|
|
conn.closed == true
|
2020-04-05 02:45:00 +00:00
|
|
|
|
2020-11-13 03:44:02 +00:00
|
|
|
asyncTest "parent close":
|
|
|
|
var buf = newBufferStream()
|
|
|
|
var conn = buf
|
2020-04-05 02:45:00 +00:00
|
|
|
|
2020-11-13 03:44:02 +00:00
|
|
|
await conn.close()
|
2020-04-05 02:45:00 +00:00
|
|
|
check:
|
2020-11-13 03:44:02 +00:00
|
|
|
conn.closed == true
|
|
|
|
buf.closed == true
|
2020-04-05 02:45:00 +00:00
|
|
|
|
2020-11-13 03:44:02 +00:00
|
|
|
asyncTest "child close":
|
|
|
|
var buf = newBufferStream()
|
|
|
|
var conn = buf
|
2020-04-05 02:45:00 +00:00
|
|
|
|
2020-11-13 03:44:02 +00:00
|
|
|
await buf.close()
|
2020-04-05 02:45:00 +00:00
|
|
|
check:
|
2020-11-13 03:44:02 +00:00
|
|
|
conn.closed == true
|
|
|
|
buf.closed == true
|