@@ -868,7 +868,7 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
868
868
await tearDownGossipsubs ( psubs )
869
869
} )
870
870
871
- it . only ( 'test gossipsub direct peers' , async function ( ) {
871
+ it ( 'test gossipsub direct peers' , async function ( ) {
872
872
// Create 3 gossipsub nodes
873
873
// 2 and 3 with direct peer connections with each other
874
874
// Connect nodes: 2 <- 1 -> 3
@@ -960,14 +960,16 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
960
960
await Promise . all ( sendRecv )
961
961
await tearDownGossipsubs ( psubs )
962
962
} )
963
+
963
964
it ( 'test gossipsub flood publish' , async function ( ) {
964
965
// Create 30 gossipsub nodes
965
966
// Connect in star topology
966
967
// Subscribe to the topic, all nodes
967
968
// Publish 20 messages, each from the center node
968
969
// Assert that the other nodes receive the message
970
+ const numPeers = 30 ;
969
971
const psubs = await createGossipsubs ( {
970
- number : 30 ,
972
+ number : numPeers ,
971
973
options : { scoreParams : { IPColocationFactorThreshold : 30 } }
972
974
} )
973
975
@@ -977,17 +979,21 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
977
979
} )
978
980
)
979
981
982
+ const owner = 0
983
+ const psub0 = psubs [ owner ]
984
+ const peerIdStrs = psubs . filter ( ( _ , j ) => j !== owner ) . map ( psub => psub . peerId . toB58String ( ) )
980
985
// build the (partial, unstable) mesh
981
986
const topic = 'foobar'
987
+ const subscriptionPromise = checkReceivedSubscriptions ( psub0 , peerIdStrs , topic )
982
988
psubs . forEach ( ( ps ) => ps . subscribe ( topic ) )
983
989
984
990
await Promise . all ( psubs . map ( ( ps ) => awaitEvents ( ps , 'gossipsub:heartbeat' , 1 ) ) )
991
+ await subscriptionPromise
985
992
986
993
// send messages from the star and assert they were received
987
994
let sendRecv = [ ]
988
995
for ( let i = 0 ; i < 20 ; i ++ ) {
989
996
const msg = uint8ArrayFromString ( `${ i } its not a flooooood ${ i } ` )
990
- const owner = 0
991
997
const results = Promise . all (
992
998
psubs . filter ( ( psub , j ) => j !== owner ) . map ( checkReceivedMessage ( topic , msg , owner , i ) )
993
999
)
@@ -997,6 +1003,7 @@ describe('go-libp2p-pubsub gossipsub tests', function () {
997
1003
await Promise . all ( sendRecv )
998
1004
await tearDownGossipsubs ( psubs )
999
1005
} )
1006
+
1000
1007
it ( 'test gossipsub negative score' , async function ( ) {
1001
1008
// Create 20 gossipsub nodes, with scoring params to quickly lower node 0's score
1002
1009
// Connect densely
0 commit comments