From 7277a18bb0ed0279e3181c18a8c1eb3b75e5daf7 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:48:22 -0600 Subject: [PATCH] fix(headertest): Store should fail if a range of 0 is requested (#147) --- headertest/store.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/headertest/store.go b/headertest/store.go index 7a663360..c0ab6438 100644 --- a/headertest/store.go +++ b/headertest/store.go @@ -3,6 +3,7 @@ package headertest import ( "bytes" "context" + "fmt" "testing" "github.com/celestiaorg/go-header" @@ -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),