@@ -44,7 +44,10 @@ func TestFullReconstructFromBridge(t *testing.T) {
4444 ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Minute )
4545 t .Cleanup (cancel )
4646 sw := swamp .NewSwamp (t , swamp .WithBlockTime (btime ))
47- go sw .FillBlocks (ctx , t , bsize , blocks )
47+ errCh := make (chan error )
48+ go func () {
49+ errCh <- sw .FillBlocks (ctx , bsize , blocks )
50+ }()
4851
4952 bridge := sw .NewBridgeNode ()
5053 err := bridge .Start (ctx )
@@ -66,9 +69,8 @@ func TestFullReconstructFromBridge(t *testing.T) {
6669 return full .ShareServ .SharesAvailable (bctx , h .DAH )
6770 })
6871 }
69-
70- err = errg .Wait ()
71- require .NoError (t , err )
72+ require .NoError (t , <- errCh )
73+ require .NoError (t , errg .Wait ())
7274}
7375
7476/*
@@ -79,12 +81,13 @@ Pre-Reqs:
7981Steps:
80821. Create a Bridge Node(BN)
81832. Start a BN
82- 3. Create 69 Light Nodes(LNs) with BN as a trusted peer
83- 4. Start 69 LNs
84- 5. Create a Full Node(FN) with 69 LNs as trusted peers
85- 6. Unlink FN connection to BN
86- 7. Start a FN
87- 8. Check that a FN can retrieve shares from 1 to 20 blocks
84+ 3. Create a Full Node(FN) that will act as a bootstraper
85+ 4. Create 69 Light Nodes(LNs) with BN as a trusted peer and a bootstaper
86+ 5. Start 69 LNs
87+ 6. Create a Full Node(FN) with a bootstraper
88+ 7. Unlink FN connection to BN
89+ 8. Start a FN
90+ 9. Check that a FN can retrieve shares from 1 to 20 blocks
8891*/
8992func TestFullReconstructFromLights (t * testing.T ) {
9093 ipld .RetrieveQuadrantTimeout = time .Millisecond * 100
@@ -96,36 +99,52 @@ func TestFullReconstructFromLights(t *testing.T) {
9699 lnodes = 69
97100 )
98101
99- ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Minute )
102+ ctx , cancel := context .WithTimeout (context .Background (), time .Second * 30 )
100103 t .Cleanup (cancel )
101104 sw := swamp .NewSwamp (t , swamp .WithBlockTime (btime ))
102- go sw .FillBlocks (ctx , t , bsize , blocks )
105+ errCh := make (chan error )
106+ go func () {
107+ errCh <- sw .FillBlocks (ctx , bsize , blocks )
108+ }()
103109
104- cfg := node .DefaultConfig (node .Bridge )
105- cfg .P2P .Bootstrapper = true
106- const defaultTimeInterval = time .Second * 10
110+ const defaultTimeInterval = time .Second * 5
107111 var defaultOptions = []node.Option {
108112 node .WithRefreshRoutingTablePeriod (defaultTimeInterval ),
109113 node .WithDiscoveryInterval (defaultTimeInterval ),
110114 node .WithAdvertiseInterval (defaultTimeInterval ),
111115 }
112116
113- bridgeConfig := append ([] node.Option { node .WithConfig ( cfg )}, defaultOptions ... )
117+ cfg := node .DefaultConfig ( node .Full )
114118 cfg .P2P .Bootstrapper = true
115- bridge := sw .NewBridgeNode (bridgeConfig ... )
119+ bridge := sw .NewBridgeNode ()
120+ addrsBridge , err := peer .AddrInfoToP2pAddrs (host .InfoFromHost (bridge .Host ))
121+ require .NoError (t , err )
122+ bootstrapConfig := append ([]node.Option {node .WithConfig (cfg )}, defaultOptions ... )
123+ bootstapFN := sw .NewFullNode (bootstrapConfig ... )
124+ require .NoError (t , bootstapFN .Start (ctx ))
116125 require .NoError (t , bridge .Start (ctx ))
117- addr := host .InfoFromHost (bridge .Host )
126+ addrBootstrapNode := host .InfoFromHost (bootstapFN .Host )
118127
119- nodesConfig := append ([]node.Option {node .WithBootstrappers ([]peer.AddrInfo {* addr })}, defaultOptions ... )
128+ nodesConfig := append (
129+ []node.Option {
130+ node .WithTrustedPeers (addrsBridge [0 ].String ()),
131+ node .WithBootstrappers ([]peer.AddrInfo {* addrBootstrapNode })},
132+ defaultOptions ... ,
133+ )
120134 full := sw .NewFullNode (nodesConfig ... )
121135 lights := make ([]* node.Node , lnodes )
122136 subs := make ([]event.Subscription , lnodes )
123137 errg , errCtx := errgroup .WithContext (ctx )
124138 for i := 0 ; i < lnodes ; i ++ {
125139 i := i
126140 errg .Go (func () error {
127- light := sw .NewLightNode (nodesConfig ... )
128- sub , err := light .Host .EventBus ().Subscribe (& event.EvtPeerConnectednessChanged {})
141+ lnConfig := append (
142+ []node.Option {
143+ node .WithTrustedPeers (addrsBridge [0 ].String ())},
144+ nodesConfig ... ,
145+ )
146+ light := sw .NewLightNode (lnConfig ... )
147+ sub , err := light .Host .EventBus ().Subscribe (& event.EvtPeerIdentificationCompleted {})
129148 if err != nil {
130149 return err
131150 }
@@ -141,6 +160,7 @@ func TestFullReconstructFromLights(t *testing.T) {
141160 case <- ctx .Done ():
142161 t .Fatal ("peer was not found" )
143162 case <- subs [i ].Out ():
163+ require .NoError (t , subs [i ].Close ())
144164 continue
145165 }
146166 }
@@ -156,7 +176,7 @@ func TestFullReconstructFromLights(t *testing.T) {
156176 return full .ShareServ .SharesAvailable (bctx , h .DAH )
157177 })
158178 }
159-
179+ require . NoError ( t , <- errCh )
160180 require .NoError (t , errg .Wait ())
161181}
162182
0 commit comments