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
a38d8a9c
Commit
a38d8a9c
authored
Jun 03, 2020
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: race in tests
parent
c7e7afca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
internal/session/session_test.go
internal/session/session_test.go
+8
-0
internal/session/sessionwantsender_test.go
internal/session/sessionwantsender_test.go
+3
-3
No files found.
internal/session/session_test.go
View file @
a38d8a9c
...
...
@@ -94,6 +94,14 @@ func (fpt *fakePeerTagger) Unprotect(p peer.ID, tag string) bool {
return
false
}
func
(
fpt
*
fakePeerTagger
)
isProtected
(
p
peer
.
ID
,
tag
string
)
bool
{
fpt
.
lk
.
Lock
()
defer
fpt
.
lk
.
Unlock
()
_
,
ok
:=
fpt
.
protectedPeers
[
p
][
tag
]
return
ok
}
type
fakeProviderFinder
struct
{
findMorePeersRequested
chan
cid
.
Cid
}
...
...
internal/session/sessionwantsender_test.go
View file @
a38d8a9c
...
...
@@ -406,7 +406,7 @@ func TestProtectConnFirstPeerToSendWantedBlock(t *testing.T) {
time
.
Sleep
(
10
*
time
.
Millisecond
)
// Expect peer A to be protected as it was first to send the block
if
_
,
ok
:=
fpt
.
p
rotected
Peers
[
peerA
][
sidStr
];
!
ok
{
if
!
fpt
.
isP
rotected
(
peerA
,
sidStr
)
{
t
.
Fatal
(
"Expected first peer to send block to have protected connection"
)
}
...
...
@@ -417,7 +417,7 @@ func TestProtectConnFirstPeerToSendWantedBlock(t *testing.T) {
time
.
Sleep
(
10
*
time
.
Millisecond
)
// Expect peer B not to be protected as it was not first to send the block
if
_
,
ok
:=
fpt
.
p
rotected
Peers
[
peerB
][
sidStr
];
ok
{
if
fpt
.
isP
rotected
(
peerB
,
sidStr
)
{
t
.
Fatal
(
"Expected peer not to be protected"
)
}
...
...
@@ -428,7 +428,7 @@ func TestProtectConnFirstPeerToSendWantedBlock(t *testing.T) {
time
.
Sleep
(
10
*
time
.
Millisecond
)
// Expect peer C not to be protected as we didn't want the block it sent
if
_
,
ok
:=
fpt
.
p
rotected
Peers
[
peerC
][
sidStr
];
ok
{
if
fpt
.
isP
rotected
(
peerC
,
sidStr
)
{
t
.
Fatal
(
"Expected peer not to be protected"
)
}
}
...
...
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