Repository: celestiaorg/celestia-node
Pull request #1627 (2023-01-23 09:57:24)

refactor(header): Extract `CoreExchange` and `CoreListener` out of the header root package
This PR is a blocker to #1423 

It extracts `CoreExchange` and `CoreListener` from the header package into the core package and moves header testing utilities into a separate package at the root level called `headertest`.


Patch:
diff --git a/header/core/exchange.go b/core/exchange.go
similarity index 86%
rename from header/core/exchange.go
rename to core/exchange.go
index de895cbf..bd9d0de6 100644
--- a/header/core/exchange.go
+++ b/core/exchange.go
@@ -6,22 +6,22 @@ import (
 	"fmt"
 
 	"github.com/ipfs/go-blockservice"
-	logging "github.com/ipfs/go-log/v2"
 
-	"github.com/celestiaorg/celestia-node/core"
 	"github.com/celestiaorg/celestia-node/header"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 )
 
-var log = logging.Logger("header/core")
-
 type Exchange struct {
-	fetcher    *core.BlockFetcher
+	fetcher    *BlockFetcher
 	shareStore blockservice.BlockService
 	construct  header.ConstructFn
 }
 
-func NewExchange(fetcher *core.BlockFetcher, bServ blockservice.BlockService, construct header.ConstructFn) *Exchange {
+func NewExchange(
+	fetcher *BlockFetcher,
+	bServ blockservice.BlockService,
+	construct header.ConstructFn,
+) *Exchange {
 	return &Exchange{
 		fetcher:    fetcher,
 		shareStore: bServ,
@@ -54,7 +54,10 @@ func (ce *Exchange) GetRangeByHeight(ctx context.Context, from, amount uint64) (
 	return headers, nil
 }
 
-func (ce *Exchange) GetVerifiedRange(ctx context.Context, from *header.ExtendedHeader, amount uint64,
+func (ce *Exchange) GetVerifiedRange(
+	ctx context.Context,
+	from *header.ExtendedHeader,
+	amount uint64,
 ) ([]*header.ExtendedHeader, error) {
 	headers, err := ce.GetRangeByHeight(ctx, uint64(from.Height())+1, amount)
 	if err != nil {
diff --git a/header/core/listener.go b/core/listener.go
similarity index 96%
rename from header/core/listener.go
rename to core/listener.go
index c1e4d6f0..76746adb 100644
--- a/header/core/listener.go
+++ b/core/listener.go
@@ -8,7 +8,6 @@ import (
 	pubsub "github.com/libp2p/go-libp2p-pubsub"
 	"github.com/tendermint/tendermint/types"
 
-	"github.com/celestiaorg/celestia-node/core"
 	"github.com/celestiaorg/celestia-node/header"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/share/p2p/shrexsub"
@@ -22,7 +21,7 @@ import (
 // broadcasts the new `ExtendedHeader` to the header-sub gossipsub
 // network.
 type Listener struct {
-	fetcher *core.BlockFetcher
+	fetcher *BlockFetcher
 	bServ   blockservice.BlockService
 
 	construct header.ConstructFn
@@ -35,7 +34,7 @@ type Listener struct {
 
 func NewListener(
 	bcast libhead.Broadcaster[*header.ExtendedHeader],
-	fetcher *core.BlockFetcher,
+	fetcher *BlockFetcher,
 	extHeaderBroadcaster shrexsub.BroadcastFn,
 	bServ blockservice.BlockService,
 	construct header.ConstructFn,
diff --git a/nodebuilder/core/module.go b/nodebuilder/core/module.go
index 165e0150..44982f02 100644
--- a/nodebuilder/core/module.go
+++ b/nodebuilder/core/module.go
@@ -8,7 +8,6 @@ import (
 
 	"github.com/celestiaorg/celestia-node/core"
 	"github.com/celestiaorg/celestia-node/header"
-	headercore "github.com/celestiaorg/celestia-node/header/core"
 	"github.com/celestiaorg/celestia-node/libs/fxutil"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
@@ -34,19 +33,20 @@ func ConstructModule(tp node.Type, cfg *Config, options ...fx.Option) fx.Option
 		return fx.Module("core",
 			baseComponents,
 			fx.Provide(core.NewBlockFetcher),
-			fxutil.ProvideAs(headercore.NewExchange, new(libhead.Exchange[*header.ExtendedHeader])),
+			fxutil.ProvideAs(core.NewExchange, new(libhead.Exchange[*header.ExtendedHeader])),
 			fx.Invoke(fx.Annotate(
 				func(bcast libhead.Broadcaster[*header.ExtendedHeader],
 					fetcher *core.BlockFetcher,
 					pubsub *shrexsub.PubSub,
 					bServ blockservice.BlockService,
-					construct header.ConstructFn) *headercore.Listener {
-					return headercore.NewListener(bcast, fetcher, pubsub.Broadcast, bServ, construct)
+					construct header.ConstructFn,
+				) *core.Listener {
+					return core.NewListener(bcast, fetcher, pubsub.Broadcast, bServ, construct)
 				},
-				fx.OnStart(func(ctx context.Context, listener *headercore.Listener) error {
+				fx.OnStart(func(ctx context.Context, listener *core.Listener) error {
 					return listener.Start(ctx)
 				}),
-				fx.OnStop(func(ctx context.Context, listener *headercore.Listener) error {
+				fx.OnStop(func(ctx context.Context, listener *core.Listener) error {
 					return listener.Stop(ctx)
 				}),
 			)),


Test patch:
diff --git a/header/core/exchange_test.go b/core/exchange_test.go
similarity index 80%
rename from header/core/exchange_test.go
rename to core/exchange_test.go
index c667dc2b..0a7b58cc 100644
--- a/header/core/exchange_test.go
+++ b/core/exchange_test.go
@@ -9,7 +9,6 @@ import (
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 
-	"github.com/celestiaorg/celestia-node/core"
 	"github.com/celestiaorg/celestia-node/header"
 )
 
@@ -34,12 +33,12 @@ func Test_hashMatch(t *testing.T) {
 	assert.False(t, bytes.Equal(expected, mismatch))
 }
 
-func createCoreFetcher(t *testing.T) *core.BlockFetcher {
-	client := core.StartTestNode(t).Client
-	return core.NewBlockFetcher(client)
+func createCoreFetcher(t *testing.T) *BlockFetcher {
+	client := StartTestNode(t).Client
+	return NewBlockFetcher(client)
 }
 
-func generateBlocks(t *testing.T, fetcher *core.BlockFetcher) {
+func generateBlocks(t *testing.T, fetcher *BlockFetcher) {
 	sub, err := fetcher.SubscribeNewBlockEvent(context.Background())
 	require.NoError(t, err)
 
diff --git a/header/core/listener_test.go b/core/listener_test.go
similarity index 98%
rename from header/core/listener_test.go
rename to core/listener_test.go
index 9a8e07b0..050d2d0e 100644
--- a/header/core/listener_test.go
+++ b/core/listener_test.go
@@ -12,7 +12,6 @@ import (
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 
-	"github.com/celestiaorg/celestia-node/core"
 	"github.com/celestiaorg/celestia-node/header"
 	"github.com/celestiaorg/celestia-node/libs/header/p2p"
 	"github.com/celestiaorg/celestia-node/share/p2p/shrexsub"
@@ -101,7 +100,7 @@ func createMocknetWithTwoPubsubEndpoints(ctx context.Context, t *testing.T) (*pu
 func createListener(
 	ctx context.Context,
 	t *testing.T,
-	fetcher *core.BlockFetcher,
+	fetcher *BlockFetcher,
 	ps *pubsub.PubSub,
 	edsSub *shrexsub.PubSub,
 ) *Listener {
diff --git a/das/daser_test.go b/das/daser_test.go
index 7d086383..05b7d480 100644
--- a/das/daser_test.go
+++ b/das/daser_test.go
@@ -19,6 +19,7 @@ import (
 
 	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/headertest"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/share"
 	"github.com/celestiaorg/celestia-node/share/availability/full"
@@ -157,7 +158,7 @@ func TestDASer_stopsAfter_BEFP(t *testing.T) {
 	// create fraud service and break one header
 	f := fraud.NewProofService(ps, net.Hosts()[0], mockGet.GetByHeight, ds, false, "private")
 	require.NoError(t, f.Start(ctx))
-	mockGet.headers[1] = header.CreateFraudExtHeader(t, mockGet.headers[1], bServ)
+	mockGet.headers[1] = headertest.CreateFraudExtHeader(t, mockGet.headers[1], bServ)
 	newCtx := context.Background()
 
 	// create and start DASer
@@ -200,7 +201,7 @@ func TestDASerSampleTimeout(t *testing.T) {
 		})
 
 	ds := ds_sync.MutexWrap(datastore.NewMapDatastore())
-	sub := new(header.DummySubscriber)
+	sub := new(headertest.DummySubscriber)
 	f := new(fraud.DummyService)
 
 	// create and start DASer
@@ -229,7 +230,7 @@ func createDASerSubcomponents(
 	bServ blockservice.BlockService,
 	numGetter,
 	numSub int,
-) (*mockGetter, *header.DummySubscriber, *fraud.DummyService) {
+) (*mockGetter, *headertest.DummySubscriber, *fraud.DummyService) {
 	mockGet, sub := createMockGetterAndSub(t, bServ, numGetter, numSub)
 	fraud := new(fraud.DummyService)
 	return mockGet, sub, fraud
@@ -240,7 +241,7 @@ func createMockGetterAndSub(
 	bServ blockservice.BlockService,
 	numGetter,
 	numSub int,
-) (*mockGetter, *header.DummySubscriber) {
+) (*mockGetter, *headertest.DummySubscriber) {
 	mockGet := &mockGetter{
 		headers:        make(map[int64]*header.ExtendedHeader),
 		doneCh:         make(chan struct{}),
@@ -249,7 +250,7 @@ func createMockGetterAndSub(
 
 	mockGet.generateHeaders(t, bServ, 0, numGetter)
 
-	sub := new(header.DummySubscriber)
+	sub := new(headertest.DummySubscriber)
 	mockGet.fillSubWithHeaders(t, sub, bServ, numGetter, numGetter+numSub)
 
 	return mockGet, sub
@@ -258,7 +259,7 @@ func createMockGetterAndSub(
 // fillSubWithHeaders generates `num` headers from the future for p2pSub to pipe through to DASer.
 func (m *mockGetter) fillSubWithHeaders(
 	t *testing.T,
-	sub *header.DummySubscriber,
+	sub *headertest.DummySubscriber,
 	bServ blockservice.BlockService,
 	startHeight,
 	endHeight int,
@@ -269,7 +270,7 @@ func (m *mockGetter) fillSubWithHeaders(
 	for i := startHeight; i < endHeight; i++ {
 		dah := availability_test.RandFillBS(t, 16, bServ)
 
-		randHeader := header.RandExtendedHeader(t)
+		randHeader := headertest.RandExtendedHeader(t)
 		randHeader.DataHash = dah.Hash()
 		randHeader.DAH = dah
 		randHeader.RawHeader.Height = int64(i + 1)
@@ -297,7 +298,7 @@ func (m *mockGetter) generateHeaders(t *testing.T, bServ blockservice.BlockServi
 	for i := startHeight; i < endHeight; i++ {
 		dah := availability_test.RandFillBS(t, 16, bServ)
 
-		randHeader := header.RandExtendedHeader(t)
+		randHeader := headertest.RandExtendedHeader(t)
 		randHeader.DataHash = dah.Hash()
 		randHeader.DAH = dah
 		randHeader.RawHeader.Height = int64(i + 1)
diff --git a/fraud/testing.go b/fraud/testing.go
index d891cf45..355d0440 100644
--- a/fraud/testing.go
+++ b/fraud/testing.go
@@ -15,6 +15,7 @@ import (
 	"github.com/stretchr/testify/require"
 
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/headertest"
 )
 
 type DummyService struct {
@@ -45,7 +46,7 @@ func createStore(t *testing.T, numHeaders int) *mockStore {
 		headHeight: 0,
 	}
 
-	suite := header.NewTestSuite(t, numHeaders)
+	suite := headertest.NewTestSuite(t, numHeaders)
 
 	for i := 0; i < numHeaders; i++ {
 		header := suite.GenExtendedHeader()
diff --git a/header/header_test.go b/headertest/header_test.go
similarity index 83%
rename from header/header_test.go
rename to headertest/header_test.go
index 43f0204a..3e360504 100644
--- a/header/header_test.go
+++ b/headertest/header_test.go
@@ -1,4 +1,4 @@
-package header
+package headertest
 
 import (
 	"context"
@@ -10,6 +10,7 @@ import (
 	"github.com/tendermint/tendermint/libs/rand"
 
 	"github.com/celestiaorg/celestia-node/core"
+	"github.com/celestiaorg/celestia-node/header"
 )
 
 func TestMakeExtendedHeaderForEmptyBlock(t *testing.T) {
@@ -32,10 +33,10 @@ func TestMakeExtendedHeaderForEmptyBlock(t *testing.T) {
 	comm, val, err := fetcher.GetBlockInfo(ctx, &height)
 	require.NoError(t, err)
 
-	headerExt, err := MakeExtendedHeader(ctx, b, comm, val, store)
+	headerExt, err := header.MakeExtendedHeader(ctx, b, comm, val, store)
 	require.NoError(t, err)
 
-	assert.Equal(t, EmptyDAH(), *headerExt.DAH)
+	assert.Equal(t, header.EmptyDAH(), *headerExt.DAH)
 }
 
 func TestMismatchedDataHash_ComputedRoot(t *testing.T) {
diff --git a/header/serde_test.go b/headertest/serde_test.go
similarity index 84%
rename from header/serde_test.go
rename to headertest/serde_test.go
index 2972b8c7..d06f7dfd 100644
--- a/header/serde_test.go
+++ b/headertest/serde_test.go
@@ -1,10 +1,12 @@
-package header
+package headertest
 
 import (
 	"testing"
 
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
+
+	"github.com/celestiaorg/celestia-node/header"
 )
 
 func TestMarshalUnmarshalExtendedHeader(t *testing.T) {
@@ -12,7 +14,7 @@ func TestMarshalUnmarshalExtendedHeader(t *testing.T) {
 	binaryData, err := in.MarshalBinary()
 	require.NoError(t, err)
 
-	out := &ExtendedHeader{}
+	out := &header.ExtendedHeader{}
 	err = out.UnmarshalBinary(binaryData)
 	require.NoError(t, err)
 	equalExtendedHeader(t, in, out)
@@ -22,13 +24,13 @@ func TestMarshalUnmarshalExtendedHeader(t *testing.T) {
 	jsonData, err := in.MarshalJSON()
 	require.NoError(t, err)
 
-	out = &ExtendedHeader{}
+	out = &header.ExtendedHeader{}
 	err = out.UnmarshalJSON(jsonData)
 	require.NoError(t, err)
 	equalExtendedHeader(t, in, out)
 }
 
-func equalExtendedHeader(t *testing.T, in, out *ExtendedHeader) {
+func equalExtendedHeader(t *testing.T, in, out *header.ExtendedHeader) {
 	// ValidatorSet.totalVotingPower is not set (is a cached value that can be recomputed client side)
 	assert.Equal(t, in.ValidatorSet.Validators, out.ValidatorSet.Validators)
 	assert.Equal(t, in.ValidatorSet.Proposer, out.ValidatorSet.Proposer)
diff --git a/header/testing.go b/headertest/testing.go
similarity index 79%
rename from header/testing.go
rename to headertest/testing.go
index abf2db38..4028042e 100644
--- a/header/testing.go
+++ b/headertest/testing.go
@@ -1,7 +1,4 @@
-// TODO(@Wondertan): Ideally, we should move that into subpackage, so this does not get included
-// into binary of  production code, but that does not matter at the moment.
-
-package header
+package headertest
 
 import (
 	"context"
@@ -11,6 +8,7 @@ import (
 	"time"
 
 	"github.com/ipfs/go-blockservice"
+	logging "github.com/ipfs/go-log/v2"
 	pubsub "github.com/libp2p/go-libp2p-pubsub"
 	"github.com/stretchr/testify/require"
 	"github.com/tendermint/tendermint/crypto/tmhash"
@@ -24,11 +22,14 @@ import (
 	"github.com/celestiaorg/celestia-app/pkg/da"
 
 	"github.com/celestiaorg/celestia-node/core"
+	"github.com/celestiaorg/celestia-node/header"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/libs/header/test"
 	"github.com/celestiaorg/celestia-node/share"
 )
 
+var log = logging.Logger("headertest")
+
 // TestSuite provides everything you need to test chain of Headers.
 // If not, please don't hesitate to extend it for your case.
 type TestSuite struct {
@@ -38,7 +39,7 @@ type TestSuite struct {
 	valSet  *types.ValidatorSet
 	valPntr int
 
-	head *ExtendedHeader
+	head *header.ExtendedHeader
 }
 
 // NewTestSuite setups a new test suite with a given number of validators.
@@ -51,8 +52,8 @@ func NewTestSuite(t *testing.T, num int) *TestSuite {
 	}
 }
 
-func (s *TestSuite) genesis() *ExtendedHeader {
-	dah := EmptyDAH()
+func (s *TestSuite) genesis() *header.ExtendedHeader {
+	dah := header.EmptyDAH()
 
 	gen := RandRawHeader(s.t)
 
@@ -64,7 +65,7 @@ func (s *TestSuite) genesis() *ExtendedHeader {
 	commit, err := core.MakeCommit(RandBlockID(s.t), gen.Height, 0, voteSet, s.vals, time.Now())
 	require.NoError(s.t, err)
 
-	eh := &ExtendedHeader{
+	eh := &header.ExtendedHeader{
 		RawHeader:    *gen,
 		Commit:       commit,
 		ValidatorSet: s.valSet,
@@ -74,28 +75,28 @@ func (s *TestSuite) genesis() *ExtendedHeader {
 	return eh
 }
 
-func (s *TestSuite) Head() *ExtendedHeader {
+func (s *TestSuite) Head() *header.ExtendedHeader {
 	if s.head == nil {
 		s.head = s.genesis()
 	}
 	return s.head
 }
 
-func (s *TestSuite) GenExtendedHeaders(num int) []*ExtendedHeader {
-	headers := make([]*ExtendedHeader, num)
+func (s *TestSuite) GenExtendedHeaders(num int) []*header.ExtendedHeader {
+	headers := make([]*header.ExtendedHeader, num)
 	for i := range headers {
 		headers[i] = s.GenExtendedHeader()
 	}
 	return headers
 }
 
-func (s *TestSuite) GetRandomHeader() *ExtendedHeader {
+func (s *TestSuite) GetRandomHeader() *header.ExtendedHeader {
 	return s.GenExtendedHeader()
 }
 
-var _ test.Generator[*ExtendedHeader] = &TestSuite{}
+var _ test.Generator[*header.ExtendedHeader] = &TestSuite{}
 
-func (s *TestSuite) GenExtendedHeader() *ExtendedHeader {
+func (s *TestSuite) GenExtendedHeader() *header.ExtendedHeader {
 	if s.head == nil {
 		s.head = s.genesis()
 		return s.head
@@ -104,7 +105,7 @@ func (s *TestSuite) GenExtendedHeader() *ExtendedHeader {
 	dah := da.MinDataAvailabilityHeader()
 	height := s.Head().Height() + 1
 	rh := s.GenRawHeader(height, s.Head().Hash(), libhead.Hash(s.Head().Commit.Hash()), dah.Hash())
-	s.head = &ExtendedHeader{
+	s.head = &header.ExtendedHeader{
 		RawHeader:    *rh,
 		Commit:       s.Commit(rh),
 		ValidatorSet: s.valSet,
@@ -115,7 +116,7 @@ func (s *TestSuite) GenExtendedHeader() *ExtendedHeader {
 }
 
 func (s *TestSuite) GenRawHeader(
-	height int64, lastHeader, lastCommit, dataHash libhead.Hash) *RawHeader {
+	height int64, lastHeader, lastCommit, dataHash libhead.Hash) *header.RawHeader {
 	rh := RandRawHeader(s.t)
 	rh.Height = height
 	rh.Time = time.Now()
@@ -128,7 +129,7 @@ func (s *TestSuite) GenRawHeader(
 	return rh
 }
 
-func (s *TestSuite) Commit(h *RawHeader) *types.Commit {
+func (s *TestSuite) Commit(h *header.RawHeader) *types.Commit {
 	bid := types.BlockID{
 		Hash: h.Hash(),
 		// Unfortunately, we still have to commit PartSetHeader even we don't need it in Celestia
@@ -166,8 +167,8 @@ func (s *TestSuite) nextProposer() *types.Validator {
 }
 
 // RandExtendedHeader provides an ExtendedHeader fixture.
-func RandExtendedHeader(t *testing.T) *ExtendedHeader {
-	dah := EmptyDAH()
+func RandExtendedHeader(t *testing.T) *header.ExtendedHeader {
+	dah := header.EmptyDAH()
 
 	rh := RandRawHeader(t)
 	rh.DataHash = dah.Hash()
@@ -178,7 +179,7 @@ func RandExtendedHeader(t *testing.T) *ExtendedHeader {
 	commit, err := core.MakeCommit(RandBlockID(t), rh.Height, 0, voteSet, vals, time.Now())
 	require.NoError(t, err)
 
-	return &ExtendedHeader{
+	return &header.ExtendedHeader{
 		RawHeader:    *rh,
 		Commit:       commit,
 		ValidatorSet: valSet,
@@ -187,8 +188,8 @@ func RandExtendedHeader(t *testing.T) *ExtendedHeader {
 }
 
 // RandRawHeader provides a RawHeader fixture.
-func RandRawHeader(t *testing.T) *RawHeader {
-	return &RawHeader{
+func RandRawHeader(t *testing.T) *header.RawHeader {
+	return &header.RawHeader{
 		Version:            version.Consensus{Block: 11, App: 1},
 		ChainID:            "test",
 		Height:             mrand.Int63(),
@@ -221,15 +222,15 @@ func RandBlockID(t *testing.T) types.BlockID {
 }
 
 // FraudMaker creates a custom ConstructFn that breaks the block at the given height.
-func FraudMaker(t *testing.T, faultHeight int64) ConstructFn {
+func FraudMaker(t *testing.T, faultHeight int64) header.ConstructFn {
 	log.Warn("Corrupting block...", "height", faultHeight)
 	return func(ctx context.Context,
 		b *types.Block,
 		comm *types.Commit,
 		vals *types.ValidatorSet,
-		bServ blockservice.BlockService) (*ExtendedHeader, error) {
+		bServ blockservice.BlockService) (*header.ExtendedHeader, error) {
 		if b.Height == faultHeight {
-			eh := &ExtendedHeader{
+			eh := &header.ExtendedHeader{
 				RawHeader:    b.Header,
 				Commit:       comm,
 				ValidatorSet: vals,
@@ -238,11 +239,15 @@ func FraudMaker(t *testing.T, faultHeight int64) ConstructFn {
 			eh = CreateFraudExtHeader(t, eh, bServ)
 			return eh, nil
 		}
-		return MakeExtendedHeader(ctx, b, comm, vals, bServ)
+		return header.MakeExtendedHeader(ctx, b, comm, vals, bServ)
 	}
 }
 
-func CreateFraudExtHeader(t *testing.T, eh *ExtendedHeader, dag blockservice.BlockService) *ExtendedHeader {
+func CreateFraudExtHeader(
+	t *testing.T,
+	eh *header.ExtendedHeader,
+	dag blockservice.BlockService,
+) *header.ExtendedHeader {
 	extended := share.RandEDS(t, 2)
 	shares := share.ExtractEDS(extended)
 	copy(shares[0][share.NamespaceSize:], shares[1][share.NamespaceSize:])
@@ -255,25 +260,25 @@ func CreateFraudExtHeader(t *testing.T, eh *ExtendedHeader, dag blockservice.Blo
 }
 
 type DummySubscriber struct {
-	Headers []*ExtendedHeader
+	Headers []*header.ExtendedHeader
 }
 
-func (mhs *DummySubscriber) AddValidator(func(context.Context, *ExtendedHeader) pubsub.ValidationResult) error {
+func (mhs *DummySubscriber) AddValidator(func(context.Context, *header.ExtendedHeader) pubsub.ValidationResult) error {
 	return nil
 }
 
-func (mhs *DummySubscriber) Subscribe() (libhead.Subscription[*ExtendedHeader], error) {
+func (mhs *DummySubscriber) Subscribe() (libhead.Subscription[*header.ExtendedHeader], error) {
 	return mhs, nil
 }
 
-func (mhs *DummySubscriber) NextHeader(ctx context.Context) (*ExtendedHeader, error) {
+func (mhs *DummySubscriber) NextHeader(ctx context.Context) (*header.ExtendedHeader, error) {
 	defer func() {
 		if len(mhs.Headers) > 1 {
 			// pop the already-returned header
 			cp := mhs.Headers
 			mhs.Headers = cp[1:]
 		} else {
-			mhs.Headers = make([]*ExtendedHeader, 0)
+			mhs.Headers = make([]*header.ExtendedHeader, 0)
 		}
 	}()
 	if len(mhs.Headers) == 0 {
diff --git a/header/verify_test.go b/headertest/verify_test.go
similarity index 98%
rename from header/verify_test.go
rename to headertest/verify_test.go
index b7350766..03aab15b 100644
--- a/header/verify_test.go
+++ b/headertest/verify_test.go
@@ -1,4 +1,4 @@
-package header
+package headertest
 
 import (
 	"strconv"
diff --git a/nodebuilder/testing.go b/nodebuilder/testing.go
index 8803037a..c478191f 100644
--- a/nodebuilder/testing.go
+++ b/nodebuilder/testing.go
@@ -14,6 +14,7 @@ import (
 
 	"github.com/celestiaorg/celestia-node/core"
 	coreheader "github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/headertest"
 	"github.com/celestiaorg/celestia-node/libs/fxutil"
 	"github.com/celestiaorg/celestia-node/libs/header/mocks"
 	"github.com/celestiaorg/celestia-node/nodebuilder/header"
@@ -45,7 +46,7 @@ func TestNodeWithConfig(t *testing.T, tp node.Type, cfg *Config, opts ...fx.Opti
 		fx.Replace(node.StorePath(t.TempDir())),
 		// avoid requesting trustedPeer during initialization
 		fxutil.ReplaceAs(mocks.NewStore[*coreheader.ExtendedHeader](
-			t, coreheader.NewTestSuite(t, 5), 20), new(header.InitStore),
+			t, headertest.NewTestSuite(t, 5), 20), new(header.InitStore),
 		),
 	)
 
diff --git a/nodebuilder/tests/fraud_test.go b/nodebuilder/tests/fraud_test.go
index 12ff92c6..a19c042e 100644
--- a/nodebuilder/tests/fraud_test.go
+++ b/nodebuilder/tests/fraud_test.go
@@ -10,7 +10,7 @@ import (
 	"github.com/stretchr/testify/require"
 
 	"github.com/celestiaorg/celestia-node/fraud"
-	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/headertest"
 	"github.com/celestiaorg/celestia-node/nodebuilder"
 	"github.com/celestiaorg/celestia-node/nodebuilder/core"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
@@ -35,7 +35,7 @@ func TestFraudProofBroadcasting(t *testing.T) {
 	testTimeout := time.Millisecond * 200
 	sw := swamp.NewSwamp(t, swamp.WithBlockTime(testTimeout))
 
-	bridge := sw.NewBridgeNode(core.WithHeaderConstructFn(header.FraudMaker(t, 20)))
+	bridge := sw.NewBridgeNode(core.WithHeaderConstructFn(headertest.FraudMaker(t, 20)))
 
 	ctx, cancel := context.WithTimeout(context.Background(), swamp.DefaultTestTimeout)
 	t.Cleanup(cancel)
@@ -99,7 +99,7 @@ func TestFraudProofSyncing(t *testing.T) {
 
 	cfg := nodebuilder.DefaultConfig(node.Bridge)
 	store := nodebuilder.MockStore(t, cfg)
-	bridge := sw.NewNodeWithStore(node.Bridge, store, core.WithHeaderConstructFn(header.FraudMaker(t, 10)))
+	bridge := sw.NewNodeWithStore(node.Bridge, store, core.WithHeaderConstructFn(headertest.FraudMaker(t, 10)))
 
 	ctx, cancel := context.WithTimeout(context.Background(), swamp.DefaultTestTimeout)
 	t.Cleanup(cancel)
diff --git a/nodebuilder/tests/swamp/swamp.go b/nodebuilder/tests/swamp/swamp.go
index 4dbf6e39..492c2ff9 100644
--- a/nodebuilder/tests/swamp/swamp.go
+++ b/nodebuilder/tests/swamp/swamp.go
@@ -20,7 +20,6 @@ import (
 
 	"github.com/celestiaorg/celestia-node/core"
 	"github.com/celestiaorg/celestia-node/header"
-	headercore "github.com/celestiaorg/celestia-node/header/core"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/libs/keystore"
 	"github.com/celestiaorg/celestia-node/logs"
@@ -164,7 +163,7 @@ func (s *Swamp) createPeer(ks keystore.Keystore) host.Host {
 func (s *Swamp) setupGenesis(ctx context.Context) {
 	s.WaitTillHeight(ctx, 1)
 
-	ex := headercore.NewExchange(
+	ex := core.NewExchange(
 		core.NewBlockFetcher(s.ClientContext.Client),
 		mdutils.Bserv(),
 		header.MakeExtendedHeader,
diff --git a/share/eds/retriever_test.go b/share/eds/retriever_test.go
index 725f0f16..a7bb8353 100644
--- a/share/eds/retriever_test.go
+++ b/share/eds/retriever_test.go
@@ -14,13 +14,15 @@ import (
 
 	"github.com/celestiaorg/celestia-app/pkg/da"
 	"github.com/celestiaorg/celestia-app/pkg/wrapper"
+	"github.com/celestiaorg/nmt"
+	"github.com/celestiaorg/rsmt2d"
+
 	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/headertest"
 	"github.com/celestiaorg/celestia-node/share"
 	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 	"github.com/celestiaorg/celestia-node/share/ipld"
-	"github.com/celestiaorg/nmt"
-	"github.com/celestiaorg/rsmt2d"
 )
 
 func init() {
@@ -155,7 +157,7 @@ func generateByzantineError(
 	h, err := store.GetByHeight(ctx, 1)
 	require.NoError(t, err)
 
-	faultHeader := header.CreateFraudExtHeader(t, h, bServ)
+	faultHeader := headertest.CreateFraudExtHeader(t, h, bServ)
 	_, err = NewRetriever(bServ).Retrieve(ctx, faultHeader.DAH)
 	return faultHeader, err
 }