Skip to content

Commit dd0ad53

Browse files
committed
Fix 'test gossipsub flood publish'
1 parent a580b59 commit dd0ad53

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/go-gossipsub.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
868868
await tearDownGossipsubs(psubs)
869869
})
870870

871-
it.only('test gossipsub direct peers', async function () {
871+
it('test gossipsub direct peers', async function () {
872872
// Create 3 gossipsub nodes
873873
// 2 and 3 with direct peer connections with each other
874874
// Connect nodes: 2 <- 1 -> 3
@@ -960,14 +960,16 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
960960
await Promise.all(sendRecv)
961961
await tearDownGossipsubs(psubs)
962962
})
963+
963964
it('test gossipsub flood publish', async function () {
964965
// Create 30 gossipsub nodes
965966
// Connect in star topology
966967
// Subscribe to the topic, all nodes
967968
// Publish 20 messages, each from the center node
968969
// Assert that the other nodes receive the message
970+
const numPeers = 30;
969971
const psubs = await createGossipsubs({
970-
number: 30,
972+
number: numPeers,
971973
options: { scoreParams: { IPColocationFactorThreshold: 30 } }
972974
})
973975

@@ -977,17 +979,21 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
977979
})
978980
)
979981

982+
const owner = 0
983+
const psub0 = psubs[owner]
984+
const peerIdStrs = psubs.filter((_, j) => j !== owner).map(psub => psub.peerId.toB58String())
980985
// build the (partial, unstable) mesh
981986
const topic = 'foobar'
987+
const subscriptionPromise = checkReceivedSubscriptions(psub0, peerIdStrs, topic)
982988
psubs.forEach((ps) => ps.subscribe(topic))
983989

984990
await Promise.all(psubs.map((ps) => awaitEvents(ps, 'gossipsub:heartbeat', 1)))
991+
await subscriptionPromise
985992

986993
// send messages from the star and assert they were received
987994
let sendRecv = []
988995
for (let i = 0; i < 20; i++) {
989996
const msg = uint8ArrayFromString(`${i} its not a flooooood ${i}`)
990-
const owner = 0
991997
const results = Promise.all(
992998
psubs.filter((psub, j) => j !== owner).map(checkReceivedMessage(topic, msg, owner, i))
993999
)
@@ -997,6 +1003,7 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
9971003
await Promise.all(sendRecv)
9981004
await tearDownGossipsubs(psubs)
9991005
})
1006+
10001007
it('test gossipsub negative score', async function () {
10011008
// Create 20 gossipsub nodes, with scoring params to quickly lower node 0's score
10021009
// Connect densely

0 commit comments

Comments
 (0)