From 3cf61a80f95b7f0ae87d05b16825db21989e4b95 Mon Sep 17 00:00:00 2001 From: Hlib Kanunnikov Date: Tue, 14 Jan 2025 14:40:49 +0100 Subject: [PATCH] test(store): add multi-subscription heightSub testcase (#242) Coming out as a result of reviewing #239 --- store/heightsub_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/store/heightsub_test.go b/store/heightsub_test.go index 3a48d950..f5958422 100644 --- a/store/heightsub_test.go +++ b/store/heightsub_test.go @@ -45,6 +45,27 @@ func TestHeightSub(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, h) } + + // assert multiple subscriptions work + { + ch := make(chan error, 10) + for range cap(ch) { + go func() { + _, err := hs.Sub(ctx, 103) + ch <- err + }() + } + + time.Sleep(time.Millisecond * 10) + + h3 := headertest.RandDummyHeader(t) + h3.HeightI = 103 + hs.Pub(h3) + + for range cap(ch) { + assert.NoError(t, <-ch) + } + } } func TestHeightSubCancellation(t *testing.T) {