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
61845421
Unverified
Commit
61845421
authored
4 years ago
by
jk-jeongkyun
Committed by
GitHub
4 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: enhanced test cases for downloader queue (#22114)
parent
9ba306d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
9 deletions
+35
-9
queue_test.go
eth/downloader/queue_test.go
+35
-9
No files found.
eth/downloader/queue_test.go
View file @
61845421
...
...
@@ -97,6 +97,9 @@ func dummyPeer(id string) *peerConnection {
}
func
TestBasics
(
t
*
testing
.
T
)
{
numOfBlocks
:=
len
(
emptyChain
.
blocks
)
numOfReceipts
:=
len
(
emptyChain
.
blocks
)
/
2
q
:=
newQueue
(
10
,
10
)
if
!
q
.
Idle
()
{
t
.
Errorf
(
"new queue should be idle"
)
...
...
@@ -135,6 +138,12 @@ func TestBasics(t *testing.T) {
t
.
Fatalf
(
"expected header %d, got %d"
,
exp
,
got
)
}
}
if
exp
,
got
:=
q
.
blockTaskQueue
.
Size
(),
numOfBlocks
-
10
;
exp
!=
got
{
t
.
Errorf
(
"expected block task queue to be %d, got %d"
,
exp
,
got
)
}
if
exp
,
got
:=
q
.
receiptTaskQueue
.
Size
(),
numOfReceipts
;
exp
!=
got
{
t
.
Errorf
(
"expected receipt task queue to be %d, got %d"
,
exp
,
got
)
}
{
peer
:=
dummyPeer
(
"peer-2"
)
fetchReq
,
_
,
throttle
:=
q
.
ReserveBodies
(
peer
,
50
)
...
...
@@ -148,8 +157,12 @@ func TestBasics(t *testing.T) {
t
.
Fatalf
(
"should have no fetches, got %d"
,
len
(
fetchReq
.
Headers
))
}
}
//fmt.Printf("blockTaskQueue len: %d\n", q.blockTaskQueue.Size())
//fmt.Printf("receiptTaskQueue len: %d\n", q.receiptTaskQueue.Size())
if
exp
,
got
:=
q
.
blockTaskQueue
.
Size
(),
numOfBlocks
-
10
;
exp
!=
got
{
t
.
Errorf
(
"expected block task queue to be %d, got %d"
,
exp
,
got
)
}
if
exp
,
got
:=
q
.
receiptTaskQueue
.
Size
(),
numOfReceipts
;
exp
!=
got
{
t
.
Errorf
(
"expected receipt task queue to be %d, got %d"
,
exp
,
got
)
}
{
// The receipt delivering peer should not be affected
// by the throttling of body deliveries
...
...
@@ -168,12 +181,20 @@ func TestBasics(t *testing.T) {
}
}
//fmt.Printf("blockTaskQueue len: %d\n", q.blockTaskQueue.Size())
//fmt.Printf("receiptTaskQueue len: %d\n", q.receiptTaskQueue.Size())
//fmt.Printf("processable: %d\n", q.resultCache.countCompleted())
if
exp
,
got
:=
q
.
blockTaskQueue
.
Size
(),
numOfBlocks
-
10
;
exp
!=
got
{
t
.
Errorf
(
"expected block task queue to be %d, got %d"
,
exp
,
got
)
}
if
exp
,
got
:=
q
.
receiptTaskQueue
.
Size
(),
numOfReceipts
-
5
;
exp
!=
got
{
t
.
Errorf
(
"expected receipt task queue to be %d, got %d"
,
exp
,
got
)
}
if
got
,
exp
:=
q
.
resultCache
.
countCompleted
(),
0
;
got
!=
exp
{
t
.
Errorf
(
"wrong processable count, got %d, exp %d"
,
got
,
exp
)
}
}
func
TestEmptyBlocks
(
t
*
testing
.
T
)
{
numOfBlocks
:=
len
(
emptyChain
.
blocks
)
q
:=
newQueue
(
10
,
10
)
q
.
Prepare
(
1
,
FastSync
)
...
...
@@ -208,13 +229,12 @@ func TestEmptyBlocks(t *testing.T) {
}
}
if
q
.
blockTaskQueue
.
Size
()
!=
len
(
emptyChain
.
blocks
)
-
10
{
t
.
Errorf
(
"expected block task queue to be
0, got %d"
,
q
.
blockTaskQueue
.
Size
())
if
q
.
blockTaskQueue
.
Size
()
!=
numOfBlocks
-
10
{
t
.
Errorf
(
"expected block task queue to be
%d, got %d"
,
numOfBlocks
-
10
,
q
.
blockTaskQueue
.
Size
())
}
if
q
.
receiptTaskQueue
.
Size
()
!=
0
{
t
.
Errorf
(
"expected receipt task queue to be
0, got %d"
,
q
.
receiptTaskQueue
.
Size
())
t
.
Errorf
(
"expected receipt task queue to be
%d, got %d"
,
0
,
q
.
receiptTaskQueue
.
Size
())
}
//fmt.Printf("receiptTaskQueue len: %d\n", q.receiptTaskQueue.Size())
{
peer
:=
dummyPeer
(
"peer-3"
)
fetchReq
,
_
,
_
:=
q
.
ReserveReceipts
(
peer
,
50
)
...
...
@@ -224,6 +244,12 @@ func TestEmptyBlocks(t *testing.T) {
t
.
Fatal
(
"there should be no body fetch tasks remaining"
)
}
}
if
q
.
blockTaskQueue
.
Size
()
!=
numOfBlocks
-
10
{
t
.
Errorf
(
"expected block task queue to be %d, got %d"
,
numOfBlocks
-
10
,
q
.
blockTaskQueue
.
Size
())
}
if
q
.
receiptTaskQueue
.
Size
()
!=
0
{
t
.
Errorf
(
"expected receipt task queue to be %d, got %d"
,
0
,
q
.
receiptTaskQueue
.
Size
())
}
if
got
,
exp
:=
q
.
resultCache
.
countCompleted
(),
10
;
got
!=
exp
{
t
.
Errorf
(
"wrong processable count, got %d, exp %d"
,
got
,
exp
)
}
...
...
This diff is collapsed.
Click to expand it.
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