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
95d3bbfa
Commit
95d3bbfa
authored
Nov 23, 2019
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test prune px with a star topology
parent
d118e1d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
gossipsub_test.go
gossipsub_test.go
+51
-0
No files found.
gossipsub_test.go
View file @
95d3bbfa
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"time"
"time"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peerstore"
)
)
func
getGossipsub
(
ctx
context
.
Context
,
h
host
.
Host
,
opts
...
Option
)
*
PubSub
{
func
getGossipsub
(
ctx
context
.
Context
,
h
host
.
Host
,
opts
...
Option
)
*
PubSub
{
...
@@ -923,3 +924,53 @@ func TestGossipsubTreeTopology(t *testing.T) {
...
@@ -923,3 +924,53 @@ func TestGossipsubTreeTopology(t *testing.T) {
checkMessageRouting
(
t
,
"fizzbuzz"
,
[]
*
PubSub
{
psubs
[
9
],
psubs
[
3
]},
chs
)
checkMessageRouting
(
t
,
"fizzbuzz"
,
[]
*
PubSub
{
psubs
[
9
],
psubs
[
3
]},
chs
)
}
}
// this tests overlay bootstrapping through px in Gossipsub v1.1
// we start with a star topology and rely on px through prune to build the mesh
func
TestGossipsubStarTopology
(
t
*
testing
.
T
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
hosts
:=
getNetHosts
(
t
,
ctx
,
20
)
psubs
:=
getGossipsubs
(
ctx
,
hosts
)
// add all peer addresses to the peerstores
// this is necessary because we can't have signed address records witout identify
// pushing them
for
i
:=
range
hosts
{
for
j
:=
range
hosts
{
if
i
==
j
{
continue
}
hosts
[
i
]
.
Peerstore
()
.
AddAddrs
(
hosts
[
j
]
.
ID
(),
hosts
[
j
]
.
Addrs
(),
peerstore
.
PermanentAddrTTL
)
}
}
// build the star
for
i
:=
1
;
i
<
20
;
i
++
{
connect
(
t
,
hosts
[
0
],
hosts
[
i
])
}
// build the mesh
var
subs
[]
*
Subscription
for
_
,
ps
:=
range
psubs
{
sub
,
err
:=
ps
.
Subscribe
(
"test"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
subs
=
append
(
subs
,
sub
)
}
// wait a bit for the mesh to build
time
.
Sleep
(
10
*
time
.
Second
)
// send a message from each peer and assert it was propagated
for
i
:=
0
;
i
<
20
;
i
++
{
msg
:=
[]
byte
(
fmt
.
Sprintf
(
"message %d"
,
i
))
psubs
[
i
]
.
Publish
(
"test"
,
msg
)
for
_
,
sub
:=
range
subs
{
assertReceive
(
t
,
sub
,
msg
)
}
}
}
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