Skip to content

Commit bdda26a

Browse files
authored
fix(headertest): sanity check range (#166)
1 parent b9fa9aa commit bdda26a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

headertest/store.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,11 @@ func (m *Store[H]) GetRangeByHeight(ctx context.Context, fromHead H, to uint64)
8080
}
8181

8282
func (m *Store[H]) getRangeByHeight(ctx context.Context, from, to uint64) ([]H, error) {
83-
amount := to - from
84-
if amount == 0 {
85-
return nil, fmt.Errorf("no headers requested")
83+
if to <= from {
84+
return nil, fmt.Errorf("malformed range, from: %d, to: %d", from, to)
8685
}
8786

88-
headers := make([]H, amount)
87+
headers := make([]H, to-from)
8988

9089
// As the requested range is [from; to),
9190
// check that (to-1) height in request is less than

0 commit comments

Comments
 (0)