From 758f14d392ab02a4fff63d6e9f6c084dd2d89374 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:05:58 +0100 Subject: [PATCH] fix(headertest): sanity check range --- headertest/store.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/headertest/store.go b/headertest/store.go index 99b5d3b3..8eae0e99 100644 --- a/headertest/store.go +++ b/headertest/store.go @@ -80,12 +80,11 @@ 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") + if to <= from { + return nil, fmt.Errorf("malformed range, from: %d, to: %d", from, to) } - headers := make([]H, amount) + headers := make([]H, to-from) // As the requested range is [from; to), // check that (to-1) height in request is less than