nim-libp2p/tests/testconnection.nim

42 lines
908 B
Nim
Raw Normal View History

{.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
import ../libp2p/[stream/connection,
2020-04-05 02:45:00 +00:00
stream/bufferstream]
import ./helpers
2020-04-05 02:45:00 +00:00
suite "Connection":
asyncTest "close":
var conn = BufferStream.new()
await conn.close()
2020-04-05 02:45:00 +00:00
check:
conn.closed == true
2020-04-05 02:45:00 +00:00
asyncTest "parent close":
var buf = BufferStream.new()
var conn = buf
2020-04-05 02:45:00 +00:00
await conn.close()
2020-04-05 02:45:00 +00:00
check:
conn.closed == true
buf.closed == true
2020-04-05 02:45:00 +00:00
asyncTest "child close":
var buf = BufferStream.new()
var conn = buf
2020-04-05 02:45:00 +00:00
await buf.close()
2020-04-05 02:45:00 +00:00
check:
conn.closed == true
buf.closed == true