提交 2baa3312 作者: Steven Allen

bitswap: test canceling subscription context after shutting down

License: MIT
Signed-off-by: 's avatarSteven Allen <steven@stebalien.com>
上级 53958266
......@@ -100,6 +100,25 @@ func TestDuplicateSubscribe(t *testing.T) {
assertBlocksEqual(t, e1, r2)
}
func TestShutdownBeforeUnsubscribe(t *testing.T) {
e1 := blocks.NewBlock([]byte("1"))
n := New()
ctx, cancel := context.WithCancel(context.Background())
ch := n.Subscribe(ctx, e1.Cid()) // no keys provided
n.Shutdown()
cancel()
select {
case _, ok := <-ch:
if ok {
t.Fatal("channel should have been closed")
}
default:
t.Fatal("channel should have been closed")
}
}
func TestSubscribeIsANoopWhenCalledWithNoKeys(t *testing.T) {
n := New()
defer n.Shutdown()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论