diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index fdbd6e2f03..9ec9dbefdf 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -660,7 +660,7 @@ func TestDataCommitment(t *testing.T) { // check if data commitment is not nil. // Checking if the commitment is correct is done in `core/blocks_test.go`. - dataCommitment, err := c.DataCommitment(ctx, 0, uint64(expectedHeight)) + dataCommitment, err := c.DataCommitment(ctx, 1, uint64(expectedHeight)) require.NotNil(t, dataCommitment, "data commitment shouldn't be nul.") require.Nil(t, err, "%+v when creating data commitment.", err) } diff --git a/rpc/core/blocks.go b/rpc/core/blocks.go index d464ac06ab..bf1e95e00c 100644 --- a/rpc/core/blocks.go +++ b/rpc/core/blocks.go @@ -290,6 +290,9 @@ func generateHeightsList(beginBlock uint64, endBlock uint64) []int64 { // validateDataCommitmentRange runs basic checks on the asc sorted list of heights // that will be used subsequently in generating data commitments over the defined set of heights. func validateDataCommitmentRange(firstBlock uint64, lastBlock uint64) error { + if firstBlock == 0 { + return fmt.Errorf("the first block is 0") + } env := GetEnvironment() heightsRange := lastBlock - firstBlock + 1 if heightsRange > uint64(consts.DataCommitmentBlocksLimit) { diff --git a/rpc/core/blocks_test.go b/rpc/core/blocks_test.go index dc7b693ff7..b7b6a71b5b 100644 --- a/rpc/core/blocks_test.go +++ b/rpc/core/blocks_test.go @@ -166,6 +166,7 @@ func TestDataCommitmentResults(t *testing.T) { {2727, 2828, false}, {10, 9, false}, {0, 1000, false}, + {0, 10, false}, {10, 8, false}, } @@ -225,6 +226,7 @@ func TestDataRootInclusionProofResults(t *testing.T) { expectPass bool }{ {8, 10, 15, false}, + {10, 0, 15, false}, {10, 10, 15, true}, {13, 10, 15, true}, {15, 10, 15, true},