Skip to content

Commit

Permalink
Merge pull request #477 from celestiaorg/hlib/fix-#453
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan authored Mar 1, 2022
2 parents 1fcf0c0 + 9bb2077 commit b71470e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions service/header/core_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@ func TestCoreListener(t *testing.T) {
fetcher := createCoreFetcher(t)

// create CoreListener and start listening
cl := createCoreListener(t, fetcher, ps0)
cl := createCoreListener(ctx, t, fetcher, ps0)
err = cl.Start(ctx)
require.NoError(t, err)

// ensure headers are getting broadcasted to the gossipsub topic
for i := 1; i < 6; i++ {
msg, err := sub.Next(context.Background())
msg, err := sub.Next(ctx)
require.NoError(t, err)

var resp ExtendedHeader
err = resp.UnmarshalBinary(msg.Data)
require.NoError(t, err)
require.Equal(t, i, int(resp.Height))
}

err = cl.Stop(ctx)
Expand Down Expand Up @@ -87,15 +86,17 @@ func createMocknetWithTwoPubsubEndpoints(ctx context.Context, t *testing.T) (*pu
}

func createCoreListener(
ctx context.Context,
t *testing.T,
fetcher *core.BlockFetcher,
ps *pubsub.PubSub,
) *CoreListener {
p2pSub := NewP2PSubscriber(ps)
err := p2pSub.Start(context.Background())
err := p2pSub.Start(ctx)
require.NoError(t, err)
t.Cleanup(func() {
p2pSub.Stop(context.Background()) //nolint:errcheck
err := p2pSub.Stop(ctx)
require.NoError(t, err)
})

return NewCoreListener(p2pSub, fetcher, mdutils.Mock())
Expand Down
2 changes: 1 addition & 1 deletion service/header/p2p_subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (p *P2PSubscriber) Start(context.Context) (err error) {
func (p *P2PSubscriber) Stop(context.Context) error {
err := p.pubsub.UnregisterTopicValidator(PubSubTopic)
if err != nil {
return err
log.Warnf("unregistering validator: %s", err)
}

return p.topic.Close()
Expand Down

0 comments on commit b71470e

Please sign in to comment.