@@ -926,6 +926,7 @@ func TestPEXReactorWhenAddressBookIsSmallerThanMaxDials(t *testing.T) {
926926// not only PEX, but also some test reactors.
927927// It is asserted that nodes can connect to each other and the address books contain other peers.
928928func TestPexFromScratch (t * testing.T ) {
929+ t .Parallel ()
929930 testCases := []struct {
930931 name string
931932 bootstrap int // n - number of bootstrap nodes
@@ -957,9 +958,8 @@ func TestPexFromScratch(t *testing.T) {
957958
958959 sw .SetLogger (logger .With ("pex" , i ))
959960
960- r := NewReactor (books [i ], & ReactorConfig {SeedMode : true })
961+ r := NewReactor (books [i ], & ReactorConfig {SeedMode : false })
961962 r .SetLogger (logger .With ("pex" , i ))
962- r .SetEnsurePeersPeriod (250 * time .Millisecond )
963963 sw .AddReactor ("pex" , r )
964964
965965 return sw
@@ -1007,15 +1007,18 @@ func TestPexFromScratch(t *testing.T) {
10071007// assertFullAddressBooks checks if all address books have the expected number of peer entries within a timeout period.
10081008func assertFullAddressBooks (t * testing.T , totalNodes int , books []AddrBook ) {
10091009 var (
1010- ticker = time .NewTicker (50 * time .Millisecond )
1011- timeoutCh = time .After (5 * time .Second )
1010+ ticker = time .NewTicker (1 * time .Second )
1011+ timeoutCh = time .After (90 * time .Second )
10121012 )
10131013 defer ticker .Stop ()
10141014
10151015 allGood := false
10161016 expected := totalNodes - 1
10171017 for ! allGood {
10181018 select {
1019+ case <- timeoutCh :
1020+ t .Errorf ("expected all nodes to connect to each other" )
1021+ t .FailNow ()
10191022 case <- ticker .C :
10201023 // PEX is responsible for address exchange, so we need to check address books, not the number of connections
10211024 // let's make a strong assumption - each node knows of all other nodes
@@ -1030,9 +1033,6 @@ func assertFullAddressBooks(t *testing.T, totalNodes int, books []AddrBook) {
10301033 if cnt == totalNodes {
10311034 allGood = true
10321035 }
1033- case <- timeoutCh :
1034- t .Errorf ("expected all nodes to connect to each other" )
1035- t .Fail ()
10361036 }
10371037 }
10381038 assert .True (t , allGood , "Not all nodes connected to each other" )
0 commit comments