@@ -17,12 +17,11 @@ limitations under the License.
17
17
package service
18
18
19
19
import (
20
+ "bytes"
20
21
"fmt"
21
22
"net"
22
23
"sync"
23
24
"testing"
24
-
25
- "bytes"
26
25
"time"
27
26
28
27
"github.com/hyperledger/fabric/common/localmsp"
@@ -119,8 +118,7 @@ func TestLeaderElectionWithDeliverClient(t *testing.T) {
119
118
gossips [i ].(* gossipServiceImpl ).deliveryFactory = deliverServiceFactory
120
119
deliverServiceFactory .service .running [channelName ] = false
121
120
122
- gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {0 }, []string {"localhost:5005" })
123
- gossips [i ].(* gossipServiceImpl ).chains [channelName ].Stop ()
121
+ gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {1 }, []string {"localhost:5005" })
124
122
service , exist := gossips [i ].(* gossipServiceImpl ).leaderElection [channelName ]
125
123
assert .True (t , exist , "Leader election service should be created for peer %d and channel %s" , i , channelName )
126
124
services [i ] = & electionService {nil , false , 0 }
@@ -176,8 +174,7 @@ func TestWithStaticDeliverClientLeader(t *testing.T) {
176
174
for i := 0 ; i < n ; i ++ {
177
175
gossips [i ].(* gossipServiceImpl ).deliveryFactory = deliverServiceFactory
178
176
deliverServiceFactory .service .running [channelName ] = false
179
- gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {0 }, []string {"localhost:5005" })
180
- gossips [i ].(* gossipServiceImpl ).chains [channelName ].Stop ()
177
+ gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {1 }, []string {"localhost:5005" })
181
178
}
182
179
183
180
for i := 0 ; i < n ; i ++ {
@@ -188,7 +185,7 @@ func TestWithStaticDeliverClientLeader(t *testing.T) {
188
185
channelName = "chanB"
189
186
for i := 0 ; i < n ; i ++ {
190
187
deliverServiceFactory .service .running [channelName ] = false
191
- gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {0 }, []string {"localhost:5005" })
188
+ gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {1 }, []string {"localhost:5005" })
192
189
}
193
190
194
191
for i := 0 ; i < n ; i ++ {
@@ -225,8 +222,7 @@ func TestWithStaticDeliverClientNotLeader(t *testing.T) {
225
222
for i := 0 ; i < n ; i ++ {
226
223
gossips [i ].(* gossipServiceImpl ).deliveryFactory = deliverServiceFactory
227
224
deliverServiceFactory .service .running [channelName ] = false
228
- gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {0 }, []string {"localhost:5005" })
229
- gossips [i ].(* gossipServiceImpl ).chains [channelName ].Stop ()
225
+ gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {1 }, []string {"localhost:5005" })
230
226
}
231
227
232
228
for i := 0 ; i < n ; i ++ {
@@ -263,7 +259,7 @@ func TestWithStaticDeliverClientBothStaticAndLeaderElection(t *testing.T) {
263
259
for i := 0 ; i < n ; i ++ {
264
260
gossips [i ].(* gossipServiceImpl ).deliveryFactory = deliverServiceFactory
265
261
assert .Panics (t , func () {
266
- gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {0 }, []string {"localhost:5005" })
262
+ gossips [i ].InitializeChannel (channelName , & mockLedgerInfo {1 }, []string {"localhost:5005" })
267
263
}, "Dynamic leader lection based and static connection to ordering service can't exist simultaniosly" )
268
264
}
269
265
@@ -626,7 +622,7 @@ func newGossipInstance(portPrefix int, id int, maxMsgCount int, boot ...int) Gos
626
622
func bootPeers (portPrefix int , ids ... int ) []string {
627
623
peers := []string {}
628
624
for _ , id := range ids {
629
- peers = append (peers , fmt .Sprintf ("localhost:%d" , ( id + portPrefix ) ))
625
+ peers = append (peers , fmt .Sprintf ("localhost:%d" , id + portPrefix ))
630
626
}
631
627
return peers
632
628
}
0 commit comments