Skip to content

Commit

Permalink
test(nodebuilder): Add test that also checks that empty block is stor…
Browse files Browse the repository at this point in the history
…ed (celestiaorg#1895)

Small additional check in lifecycle.
  • Loading branch information
renaynay authored Mar 16, 2023
1 parent 596c16b commit ef8c9e7
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions nodebuilder/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"google.golang.org/protobuf/proto"

"github.com/celestiaorg/celestia-node/nodebuilder/node"
"github.com/celestiaorg/celestia-node/share"
)

func TestLifecycle(t *testing.T) {
var test = []struct {
tp node.Type
coreExpected bool
tp node.Type
}{
{tp: node.Bridge},
{tp: node.Full},
Expand Down Expand Up @@ -133,3 +133,34 @@ func StartMockOtelCollectorHTTPServer(t *testing.T) (string, func()) {
server.EnableHTTP2 = true
return server.URL, server.Close
}

func TestEmptyBlockExists(t *testing.T) {
var test = []struct {
tp node.Type
}{
{tp: node.Bridge},
{tp: node.Full},
// technically doesn't need to be tested as a SharesAvailable call to
// light node short circuits on an empty Root
{tp: node.Light},
}
for i, tt := range test {
t.Run(strconv.Itoa(i), func(t *testing.T) {
node := TestNode(t, tt.tp)

ctx, cancel := context.WithTimeout(context.Background(), Timeout)
defer cancel()

err := node.Start(ctx)
require.NoError(t, err)

// ensure an empty block exists in store
err = node.ShareServ.SharesAvailable(ctx, share.EmptyRoot())
require.NoError(t, err)

err = node.Stop(ctx)
require.NoError(t, err)
})
}

}

0 comments on commit ef8c9e7

Please sign in to comment.