2023-05-18 08:24:17 +00:00
|
|
|
{.used.}
|
|
|
|
|
|
|
|
# Nim-Libp2p
|
|
|
|
# Copyright (c) 2023 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
|
|
|
|
|
|
|
import chronos
|
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":
|
2021-06-07 07:32:08 +00:00
|
|
|
var conn = BufferStream.new()
|
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
|
2020-04-05 02:45:00 +00:00
|
|
|
|
2020-11-13 03:44:02 +00:00
|
|
|
asyncTest "parent close":
|
2021-06-07 07:32:08 +00:00
|
|
|
var buf = BufferStream.new()
|
2020-11-13 03:44:02 +00:00
|
|
|
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":
|
2021-06-07 07:32:08 +00:00
|
|
|
var buf = BufferStream.new()
|
2020-11-13 03:44:02 +00:00
|
|
|
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
|