@@ -297,6 +297,34 @@ func testGetBlockHeaders(t *testing.T, protocol uint) {
297
297
backend .chain .GetBlockByNumber (0 ).Hash (),
298
298
},
299
299
},
300
+ // Check a corner case where skipping causes overflow with reverse=false
301
+ {
302
+ & GetBlockHeadersRequest {Origin : HashOrNumber {Number : 1 }, Amount : 2 , Reverse : false , Skip : math .MaxUint64 - 1 },
303
+ []common.Hash {
304
+ backend .chain .GetBlockByNumber (1 ).Hash (),
305
+ },
306
+ },
307
+ // Check a corner case where skipping causes overflow with reverse=true
308
+ {
309
+ & GetBlockHeadersRequest {Origin : HashOrNumber {Number : 1 }, Amount : 2 , Reverse : true , Skip : math .MaxUint64 - 1 },
310
+ []common.Hash {
311
+ backend .chain .GetBlockByNumber (1 ).Hash (),
312
+ },
313
+ },
314
+ // Check another corner case where skipping causes overflow with reverse=false
315
+ {
316
+ & GetBlockHeadersRequest {Origin : HashOrNumber {Number : 1 }, Amount : 2 , Reverse : false , Skip : math .MaxUint64 },
317
+ []common.Hash {
318
+ backend .chain .GetBlockByNumber (1 ).Hash (),
319
+ },
320
+ },
321
+ // Check another corner case where skipping causes overflow with reverse=true
322
+ {
323
+ & GetBlockHeadersRequest {Origin : HashOrNumber {Number : 1 }, Amount : 2 , Reverse : true , Skip : math .MaxUint64 },
324
+ []common.Hash {
325
+ backend .chain .GetBlockByNumber (1 ).Hash (),
326
+ },
327
+ },
300
328
// Check a corner case where skipping overflow loops back into the chain start
301
329
{
302
330
& GetBlockHeadersRequest {Origin : HashOrNumber {Hash : backend .chain .GetBlockByNumber (3 ).Hash ()}, Amount : 2 , Reverse : false , Skip : math .MaxUint64 - 1 },
0 commit comments