diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-08 20:02:52 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-08 20:02:52 +0800 |
commit | 4ed3509a02c7f5a09036e6e9cb615c6def6d25f3 (patch) | |
tree | 38d8ae6f0bf132964d99bb84c63cc76103d377fa /eth | |
parent | c4f224932f69099f595211755ebc0a9933616315 (diff) | |
download | dexon-4ed3509a02c7f5a09036e6e9cb615c6def6d25f3.tar dexon-4ed3509a02c7f5a09036e6e9cb615c6def6d25f3.tar.gz dexon-4ed3509a02c7f5a09036e6e9cb615c6def6d25f3.tar.bz2 dexon-4ed3509a02c7f5a09036e6e9cb615c6def6d25f3.tar.lz dexon-4ed3509a02c7f5a09036e6e9cb615c6def6d25f3.tar.xz dexon-4ed3509a02c7f5a09036e6e9cb615c6def6d25f3.tar.zst dexon-4ed3509a02c7f5a09036e6e9cb615c6def6d25f3.zip |
eth/downloader: test registration rejection on head ban
Diffstat (limited to 'eth')
-rw-r--r-- | eth/downloader/downloader_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index c9e84371c..5f10fb41f 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -169,8 +169,9 @@ func (dl *downloadTester) getBlocks(id string) func([]common.Hash) error { } } -func (dl *downloadTester) newPeer(id string, td *big.Int, hash common.Hash) { - dl.downloader.RegisterPeer(id, hash, dl.getHashes, dl.getBlocks(id)) +// newPeer registers a new block download source into the syncer. +func (dl *downloadTester) newPeer(id string, td *big.Int, hash common.Hash) error { + return dl.downloader.RegisterPeer(id, hash, dl.getHashes, dl.getBlocks(id)) } // Tests that simple synchronization, without throttling from a good peer works. @@ -559,6 +560,13 @@ func TestBannedChainStarvationAttack(t *testing.T) { } banned = bans } + // Check that after banning an entire chain, bad peers get dropped + if err := tester.newPeer("new attacker", big.NewInt(10000), hashes[0]); err != errBannedHead { + t.Fatalf("peer registration mismatch: have %v, want %v", err, errBannedHead) + } + if peer := tester.downloader.peers.Peer("net attacker"); peer != nil { + t.Fatalf("banned attacker registered: %v", peer) + } } // Tests that if a peer sends excessively many/large invalid chains that are |