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
p2p
go-p2p-pubsub
Commits
cc791f28
Commit
cc791f28
authored
Jun 07, 2019
by
Adin Schmahmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made TestSubscriptionNotification thread safe
parent
8037a2e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
floodsub_test.go
floodsub_test.go
+5
-0
No files found.
floodsub_test.go
View file @
cc791f28
...
...
@@ -1075,6 +1075,8 @@ func TestSubscriptionNotification(t *testing.T) {
msgs
:=
make
([]
*
Subscription
,
numHosts
)
subPeersFound
:=
make
([]
map
[
peer
.
ID
]
struct
{},
numHosts
)
wg
:=
sync
.
WaitGroup
{}
for
i
,
ps
:=
range
psubs
{
subch
,
err
:=
ps
.
Subscribe
(
"foobar"
)
if
err
!=
nil
{
...
...
@@ -1084,7 +1086,9 @@ func TestSubscriptionNotification(t *testing.T) {
msgs
[
i
]
=
subch
peersFound
:=
make
(
map
[
peer
.
ID
]
struct
{})
subPeersFound
[
i
]
=
peersFound
wg
.
Add
(
1
)
go
func
(
peersFound
map
[
peer
.
ID
]
struct
{})
{
defer
wg
.
Done
()
for
i
:=
0
;
i
<
numHosts
-
1
;
i
++
{
pid
,
err
:=
subch
.
NextSubscribedPeer
(
ctx
)
if
err
!=
nil
{
...
...
@@ -1099,6 +1103,7 @@ func TestSubscriptionNotification(t *testing.T) {
time
.
Sleep
(
time
.
Millisecond
*
100
)
wg
.
Wait
()
for
_
,
peersFound
:=
range
subPeersFound
{
if
len
(
peersFound
)
!=
numHosts
-
1
{
t
.
Fatal
(
"incorrect number of peers found"
)
...
...
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