@@ -18,6 +18,7 @@ import (
1818 "github.com/hyperledger/fabric-sdk-go/pkg/common/options"
1919 "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/context"
2020 "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
21+ "github.com/hyperledger/fabric-sdk-go/pkg/util/test"
2122
2223 "github.com/hyperledger/fabric-sdk-go/pkg/fab/events/api"
2324 "github.com/hyperledger/fabric-sdk-go/pkg/fab/events/client/dispatcher"
@@ -824,7 +825,7 @@ func checkConcurrentEvents(blockTestErr chan error, t *testing.T, fblockTestErr
824825
825826func checkIfAllEventsRecv (blockTestDone bool , fblockTestDone bool , ccTestDone bool , txStatusTestDone bool ) bool {
826827 if blockTestDone && fblockTestDone && ccTestDone && txStatusTestDone {
827- fmt . Println ("All tests completed successfully" )
828+ test . Logf ("All tests completed successfully" )
828829 return true
829830 }
830831 return false
@@ -880,15 +881,15 @@ func listenBlockEvents(channelID string, eventch <-chan *fab.BlockEvent, expecte
880881 select {
881882 case _ , ok := <- eventch :
882883 if ! ok {
883- fmt . Println ("Block events channel was closed" )
884+ test . Logf ("Block events channel was closed" )
884885 return
885886 }
886887 numReceived ++
887888 case <- time .After (5 * time .Second ):
888889 if numReceived != expected {
889890 errch <- errors .Errorf ("Expected [%d] events but received [%d]" , expected , numReceived )
890891 } else {
891- fmt . Printf ("Received %d block events\n " , numReceived )
892+ test . Logf ("Received %d block events" , numReceived )
892893 errch <- nil
893894 }
894895 return
@@ -903,7 +904,7 @@ func listenFilteredBlockEvents(channelID string, eventch <-chan *fab.FilteredBlo
903904 select {
904905 case fbevent , ok := <- eventch :
905906 if ! ok {
906- fmt . Print ("Filtered block events channel was closed \n " )
907+ test . Logf ("Filtered block events channel was closed" )
907908 return
908909 }
909910 if fbevent .FilteredBlock == nil {
@@ -919,7 +920,7 @@ func listenFilteredBlockEvents(channelID string, eventch <-chan *fab.FilteredBlo
919920 if numReceived != expected {
920921 errch <- errors .Errorf ("Expected [%d] events but received [%d]" , expected , numReceived )
921922 } else {
922- fmt . Printf ("Received %d filtered block events\n " , numReceived )
923+ test . Logf ("Received %d filtered block events" , numReceived )
923924 errch <- nil
924925 }
925926 return
@@ -935,7 +936,7 @@ func listenChaincodeEvents(channelID string, eventch <-chan *fab.CCEvent, expect
935936 select {
936937 case event , ok := <- eventch :
937938 if ! ok {
938- fmt . Println ("CC events channel was closed" )
939+ test . Logf ("CC events channel was closed" )
939940 return
940941 }
941942 if event .BlockNumber > 0 && event .BlockNumber <= lastBlockNum {
@@ -947,7 +948,7 @@ func listenChaincodeEvents(channelID string, eventch <-chan *fab.CCEvent, expect
947948 if numReceived != expected {
948949 errch <- errors .Errorf ("Expected [%d] events but received [%d]" , expected , numReceived )
949950 } else {
950- fmt . Printf ("Received %d CC events\n " , numReceived )
951+ test . Logf ("Received %d CC events" , numReceived )
951952 errch <- nil
952953 }
953954 return
@@ -1216,15 +1217,15 @@ func listenConnection(eventch chan *dispatcher.ConnectionEvent, outcome chan moc
12161217
12171218 for {
12181219 e , ok := <- eventch
1219- fmt . Printf ("listenConnection - got event [%+v] - ok=[%t]\n " , e , ok )
1220+ test . Logf ("listenConnection - got event [%+v] - ok=[%t]" , e , ok )
12201221 if ! ok {
1221- fmt . Println ("listenConnection - Returning terminated outcome" )
1222+ test . Logf ("listenConnection - Returning terminated outcome" )
12221223 outcome <- mockconn .ClosedOutcome
12231224 break
12241225 }
12251226 if e .Connected {
12261227 if state == Disconnected {
1227- fmt . Println ("listenConnection - Returning reconnected outcome" )
1228+ test . Logf ("listenConnection - Returning reconnected outcome" )
12281229 outcome <- mockconn .ReconnectedOutcome
12291230 }
12301231 state = Connected
@@ -1273,11 +1274,11 @@ var clientProvider = func(context context.Client, chConfig fab.ChannelCfg, disco
12731274 opts = append (opts , WithBlockEvents ())
12741275 return newClient (context , chConfig , discoveryService , connectionProvider , opts ,
12751276 func () error {
1276- fmt . Println ("AfterConnect called" )
1277+ test . Logf ("AfterConnect called" )
12771278 return nil
12781279 },
12791280 func () error {
1280- fmt . Println ("BeforeReconnect called" )
1281+ test . Logf ("BeforeReconnect called" )
12811282 return nil
12821283 })
12831284}
@@ -1294,11 +1295,11 @@ var failAfterConnectClientProvider = func(context context.Client, chConfig fab.C
12941295var filteredClientProvider = func (context context.Client , chConfig fab.ChannelCfg , discoveryService fab.DiscoveryService , connectionProvider api.ConnectionProvider , opts []options.Opt ) (* Client , error ) {
12951296 return newClient (context , chConfig , discoveryService , connectionProvider , opts ,
12961297 func () error {
1297- fmt . Println ("AfterConnect called" )
1298+ test . Logf ("AfterConnect called" )
12981299 return nil
12991300 },
13001301 func () error {
1301- fmt . Println ("BeforeReconnect called" )
1302+ test . Logf ("BeforeReconnect called" )
13021303 return nil
13031304 })
13041305}
0 commit comments