File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ const createNode = async (bootstrappers) => {
6767 const peer = evt . detail
6868 console . log ( `Peer ${ node1 . peerId . toString ( ) } discovered: ${ peer . id . toString ( ) } ` )
6969 } )
70- node2 . addEventListener ( 'peer:discovery' , ( evt ) => {
70+ node2 . addEventListener ( 'peer:discovery' , ( evt ) => {
7171 const peer = evt . detail
7272 console . log ( `Peer ${ node2 . peerId . toString ( ) } discovered: ${ peer . id . toString ( ) } ` )
7373 } )
@@ -77,4 +77,4 @@ const createNode = async (bootstrappers) => {
7777 node1 . start ( ) ,
7878 node2 . start ( )
7979 ] )
80- } ) ( ) ;
80+ } ) ( )
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export async function test () {
2727 } )
2828 } )
2929
30- await pWaitFor ( ( ) => discoveredNodes > 1 )
30+ await pWaitFor ( ( ) => discoveredNodes > 1 , 600000 )
3131
3232 proc . kill ( )
3333}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { fileURLToPath } from 'url'
77const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
88
99export async function test ( ) {
10- let discoveredNodes = 0
10+ const discoveredPeers = [ ]
1111
1212 process . stdout . write ( '3.js\n' )
1313
@@ -19,15 +19,20 @@ export async function test () {
1919 proc . all . on ( 'data' , async ( data ) => {
2020 process . stdout . write ( data )
2121 const str = uint8ArrayToString ( data )
22-
22+ const discoveredPeersRegex = / P e e r \s + (?< Peer1 > [ ^ \s ] + ) \s + d i s c o v e r e d : \s + (?< Peer2 > [ ^ \s ] + ) /
2323 str . split ( '\n' ) . forEach ( line => {
24- if ( line . includes ( 'discovered:' ) ) {
25- discoveredNodes ++
24+ const peers = line . match ( discoveredPeersRegex )
25+ if ( peers != null ) {
26+ // sort so we don't count reversed pair twice
27+ const match = [ peers . groups . Peer1 , peers . groups . Peer2 ] . sort ( ) . join ( ',' )
28+ if ( ! discoveredPeers . includes ( match ) ) {
29+ discoveredPeers . push ( match )
30+ }
2631 }
2732 } )
2833 } )
2934
30- await pWaitFor ( ( ) => discoveredNodes > 3 )
35+ await pWaitFor ( ( ) => discoveredPeers . length > 2 , 600000 )
3136
3237 proc . kill ( )
3338}
Original file line number Diff line number Diff line change 99 },
1010 "license" : " MIT" ,
1111 "dependencies" : {
12- "@libp2p/pubsub-peer-discovery" : " ^6.0.1 " ,
12+ "@libp2p/pubsub-peer-discovery" : " ^6.0.2 " ,
1313 "@libp2p/floodsub" : " ^3.0.3" ,
1414 "@nodeutils/defaults-deep" : " ^1.1.0" ,
1515 "execa" : " ^6.1.0" ,
You can’t perform that action at this time.
0 commit comments