Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
4ed3509a
Commit
4ed3509a
authored
Jun 08, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: test registration rejection on head ban
parent
c4f22493
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
downloader_test.go
eth/downloader/downloader_test.go
+10
-2
No files found.
eth/downloader/downloader_test.go
View file @
4ed3509a
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment