Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
6a1362ca
Commit
6a1362ca
authored
Aug 20, 2019
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: session peer manager ordering test timing (2)
parent
ae275396
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
sessionpeermanager/sessionpeermanager_test.go
sessionpeermanager/sessionpeermanager_test.go
+2
-6
No files found.
sessionpeermanager/sessionpeermanager_test.go
View file @
6a1362ca
...
@@ -149,7 +149,7 @@ func TestRecordingReceivedBlocks(t *testing.T) {
...
@@ -149,7 +149,7 @@ func TestRecordingReceivedBlocks(t *testing.T) {
func
TestOrderingPeers
(
t
*
testing
.
T
)
{
func
TestOrderingPeers
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
3
0
*
time
.
Millisecond
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
6
0
*
time
.
Millisecond
)
defer
cancel
()
defer
cancel
()
peerCount
:=
100
peerCount
:=
100
peers
:=
testutil
.
GeneratePeers
(
peerCount
)
peers
:=
testutil
.
GeneratePeers
(
peerCount
)
...
@@ -184,8 +184,6 @@ func TestOrderingPeers(t *testing.T) {
...
@@ -184,8 +184,6 @@ func TestOrderingPeers(t *testing.T) {
time
.
Sleep
(
5
*
time
.
Millisecond
)
time
.
Sleep
(
5
*
time
.
Millisecond
)
sessionPeerManager
.
RecordPeerResponse
(
peer3
,
[]
cid
.
Cid
{
c
[
0
]})
sessionPeerManager
.
RecordPeerResponse
(
peer3
,
[]
cid
.
Cid
{
c
[
0
]})
time
.
Sleep
(
5
*
time
.
Millisecond
)
sessionPeers
:=
sessionPeerManager
.
GetOptimizedPeers
()
sessionPeers
:=
sessionPeerManager
.
GetOptimizedPeers
()
if
len
(
sessionPeers
)
!=
maxOptimizedPeers
{
if
len
(
sessionPeers
)
!=
maxOptimizedPeers
{
t
.
Fatal
(
fmt
.
Sprintf
(
"Should not return more (%d) than the max of optimized peers (%d)"
,
len
(
sessionPeers
),
maxOptimizedPeers
))
t
.
Fatal
(
fmt
.
Sprintf
(
"Should not return more (%d) than the max of optimized peers (%d)"
,
len
(
sessionPeers
),
maxOptimizedPeers
))
...
@@ -225,8 +223,6 @@ func TestOrderingPeers(t *testing.T) {
...
@@ -225,8 +223,6 @@ func TestOrderingPeers(t *testing.T) {
// Receive a second time
// Receive a second time
sessionPeerManager
.
RecordPeerResponse
(
peer3
,
[]
cid
.
Cid
{
c2
[
0
]})
sessionPeerManager
.
RecordPeerResponse
(
peer3
,
[]
cid
.
Cid
{
c2
[
0
]})
time
.
Sleep
(
5
*
time
.
Millisecond
)
// call again
// call again
nextSessionPeers
:=
sessionPeerManager
.
GetOptimizedPeers
()
nextSessionPeers
:=
sessionPeerManager
.
GetOptimizedPeers
()
if
len
(
nextSessionPeers
)
!=
maxOptimizedPeers
{
if
len
(
nextSessionPeers
)
!=
maxOptimizedPeers
{
...
@@ -235,7 +231,7 @@ func TestOrderingPeers(t *testing.T) {
...
@@ -235,7 +231,7 @@ func TestOrderingPeers(t *testing.T) {
// should sort by average latency
// should sort by average latency
// peer1: ~5ms
// peer1: ~5ms
// peer3: (~35ms +
~5ms +
~5ms) / 2 = ~2
3
ms
// peer3: (~35ms + ~5ms) / 2 = ~2
0
ms
// peer2: ~30ms
// peer2: ~30ms
if
(
nextSessionPeers
[
0
]
.
Peer
!=
peer1
)
||
(
nextSessionPeers
[
1
]
.
Peer
!=
peer3
)
||
if
(
nextSessionPeers
[
0
]
.
Peer
!=
peer1
)
||
(
nextSessionPeers
[
1
]
.
Peer
!=
peer3
)
||
(
nextSessionPeers
[
2
]
.
Peer
!=
peer2
)
{
(
nextSessionPeers
[
2
]
.
Peer
!=
peer2
)
{
...
...
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