Skip to content

Commit

Permalink
fix(headertest): Store should fail if a range of 0 is requested (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay authored Jan 24, 2024
1 parent a5a9f28 commit 7277a18
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions headertest/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package headertest
import (
"bytes"
"context"
"fmt"
"testing"

"github.com/celestiaorg/go-header"
Expand Down Expand Up @@ -76,6 +77,10 @@ func (m *Store[H]) GetRangeByHeight(ctx context.Context, fromHead H, to uint64)

func (m *Store[H]) getRangeByHeight(ctx context.Context, from, to uint64) ([]H, error) {
amount := to - from
if amount == 0 {
return nil, fmt.Errorf("no headers requested")
}

headers := make([]H, amount)

// As the requested range is [from; to),
Expand Down

0 comments on commit 7277a18

Please sign in to comment.