aboutsummaryrefslogtreecommitdiffstats
path: root/eth/handler_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-10-05 21:31:48 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-10-05 21:34:07 +0800
commite482b5694faece927a29289f88d7a87b1ce1fbd1 (patch)
treeeedbb105046f909300744dcd89993ff97a6bb5fa /eth/handler_test.go
parenta7cc3248fe3ecb3439d0b69f5823f294b2854886 (diff)
downloadgo-tangerine-e482b5694faece927a29289f88d7a87b1ce1fbd1.tar
go-tangerine-e482b5694faece927a29289f88d7a87b1ce1fbd1.tar.gz
go-tangerine-e482b5694faece927a29289f88d7a87b1ce1fbd1.tar.bz2
go-tangerine-e482b5694faece927a29289f88d7a87b1ce1fbd1.tar.lz
go-tangerine-e482b5694faece927a29289f88d7a87b1ce1fbd1.tar.xz
go-tangerine-e482b5694faece927a29289f88d7a87b1ce1fbd1.tar.zst
go-tangerine-e482b5694faece927a29289f88d7a87b1ce1fbd1.zip
eth: monitor malicious header retrieval requests
Diffstat (limited to 'eth/handler_test.go')
-rw-r--r--eth/handler_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/eth/handler_test.go b/eth/handler_test.go
index 91989cb8f..f0f18d0a6 100644
--- a/eth/handler_test.go
+++ b/eth/handler_test.go
@@ -17,6 +17,7 @@
package eth
import (
+ "math"
"math/big"
"math/rand"
"testing"
@@ -173,6 +174,20 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
pm.blockchain.GetBlockByNumber(0).Hash(),
},
},
+ // Check a corner case where skipping overflow loops back into the chain start
+ {
+ &getBlockHeadersData{Origin: hashOrNumber{Hash: pm.blockchain.GetBlockByNumber(3).Hash()}, Amount: 2, Reverse: false, Skip: math.MaxUint64 - 1},
+ []common.Hash{
+ pm.blockchain.GetBlockByNumber(3).Hash(),
+ },
+ },
+ // Check a corner case where skipping overflow loops back to the same header
+ {
+ &getBlockHeadersData{Origin: hashOrNumber{Hash: pm.blockchain.GetBlockByNumber(1).Hash()}, Amount: 2, Reverse: false, Skip: math.MaxUint64},
+ []common.Hash{
+ pm.blockchain.GetBlockByNumber(1).Hash(),
+ },
+ },
// Check that non existing headers aren't returned
{
&getBlockHeadersData{Origin: hashOrNumber{Hash: unknown}, Amount: 1},