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
a9e4b965
Commit
a9e4b965
authored
Apr 24, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: fixed tests
parent
d84c2202
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
downloader_test.go
eth/downloader/downloader_test.go
+8
-12
No files found.
eth/downloader/downloader_test.go
View file @
a9e4b965
...
...
@@ -65,10 +65,6 @@ func (dl *downloadTester) hasBlock(hash common.Hash) bool {
func
(
dl
*
downloadTester
)
insertChain
(
blocks
types
.
Blocks
)
error
{
dl
.
insertedBlocks
+=
len
(
blocks
)
if
len
(
dl
.
blocks
)
-
1
<=
dl
.
insertedBlocks
{
dl
.
done
<-
true
}
return
nil
}
...
...
@@ -93,14 +89,14 @@ func (dl *downloadTester) getBlocks(id string) func([]common.Hash) error {
func
(
dl
*
downloadTester
)
newPeer
(
id
string
,
td
*
big
.
Int
,
hash
common
.
Hash
)
{
dl
.
pcount
++
dl
.
downloader
.
RegisterPeer
(
id
,
td
,
hash
,
dl
.
getHashes
,
dl
.
getBlocks
(
id
))
dl
.
downloader
.
RegisterPeer
(
id
,
hash
,
dl
.
getHashes
,
dl
.
getBlocks
(
id
))
}
func
(
dl
*
downloadTester
)
badBlocksPeer
(
id
string
,
td
*
big
.
Int
,
hash
common
.
Hash
)
{
dl
.
pcount
++
// This bad peer never returns any blocks
dl
.
downloader
.
RegisterPeer
(
id
,
td
,
hash
,
dl
.
getHashes
,
func
([]
common
.
Hash
)
error
{
dl
.
downloader
.
RegisterPeer
(
id
,
hash
,
dl
.
getHashes
,
func
([]
common
.
Hash
)
error
{
return
nil
})
}
...
...
@@ -122,13 +118,13 @@ func TestDownload(t *testing.T) {
tester
.
badBlocksPeer
(
"peer3"
,
big
.
NewInt
(
0
),
common
.
Hash
{})
tester
.
badBlocksPeer
(
"peer4"
,
big
.
NewInt
(
0
),
common
.
Hash
{})
blox
,
err
:=
tester
.
downloader
.
Synchronise
(
"peer1"
,
hashes
[
0
])
err
:=
tester
.
downloader
.
Synchronise
(
"peer1"
,
hashes
[
0
])
if
err
!=
nil
{
t
.
Error
(
"download error"
,
err
)
}
if
len
(
blox
)
!=
targetBlocks
{
t
.
Error
(
"expected"
,
targetBlocks
,
"have"
,
len
(
blox
)
)
if
tester
.
insertedBlocks
!=
targetBlocks
{
t
.
Error
(
"expected"
,
targetBlocks
,
"have"
,
tester
.
insertedBlocks
)
}
}
...
...
@@ -147,12 +143,12 @@ func TestMissing(t *testing.T) {
hashes
=
append
(
extraHashes
,
hashes
[
:
len
(
hashes
)
-
1
]
...
)
tester
.
newPeer
(
"peer2"
,
big
.
NewInt
(
0
),
common
.
Hash
{})
blox
,
err
:=
tester
.
downloader
.
Synchronise
(
"peer1"
,
hashes
[
0
])
err
:=
tester
.
downloader
.
Synchronise
(
"peer1"
,
hashes
[
0
])
if
err
!=
nil
{
t
.
Error
(
"download error"
,
err
)
}
if
len
(
blox
)
!=
targetBlocks
{
t
.
Error
(
"expected"
,
targetBlocks
,
"have"
,
len
(
blox
)
)
if
tester
.
insertedBlocks
!=
targetBlocks
{
t
.
Error
(
"expected"
,
targetBlocks
,
"have"
,
tester
.
insertedBlocks
)
}
}
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