@@ -15,6 +15,7 @@ import (
1515 "time"
1616
1717 "github.com/hyperledger/fabric-sdk-go/pkg/common/errors/multi"
18+ "github.com/hyperledger/fabric-sdk-go/pkg/common/errors/retry"
1819 "github.com/hyperledger/fabric-sdk-go/pkg/common/errors/status"
1920 contextAPI "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/context"
2021 "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/msp"
@@ -197,7 +198,8 @@ func testWithOrg1(t *testing.T, sdk *fabsdk.FabricSDK) int {
197198 }
198199
199200 // Call with a dummy function and expect a fail with multiple errors
200- response , err := chClientOrg1User .Query (channel.Request {ChaincodeID : "exampleCC" , Fcn : "DUMMY_FUNCTION" , Args : integration .ExampleCCQueryArgs ()})
201+ response , err := chClientOrg1User .Query (channel.Request {ChaincodeID : "exampleCC" , Fcn : "DUMMY_FUNCTION" , Args : integration .ExampleCCQueryArgs ()},
202+ channel .WithRetry (retry .DefaultChClientOpts ))
201203 if err == nil {
202204 t .Fatal ("Should have failed with dummy function" )
203205 }
@@ -217,7 +219,8 @@ func testWithOrg1(t *testing.T, sdk *fabsdk.FabricSDK) int {
217219 }
218220
219221 // Org1 user queries initial value on both peers
220- response , err = chClientOrg1User .Query (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCQueryArgs ()})
222+ response , err = chClientOrg1User .Query (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCQueryArgs ()},
223+ channel .WithRetry (retry .DefaultChClientOpts ))
221224 if err != nil {
222225 t .Fatalf ("Failed to query funds: %s" , err )
223226 }
@@ -265,7 +268,8 @@ func testWithOrg1(t *testing.T, sdk *fabsdk.FabricSDK) int {
265268 }
266269
267270 // Org2 user moves funds on org2 peer
268- response , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()}, channel .WithTargets (orgTestPeer1 ))
271+ response , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()}, channel .WithTargets (orgTestPeer1 ),
272+ channel .WithRetry (retry .DefaultChClientOpts ))
269273 if err != nil {
270274 t .Fatalf ("Failed to move funds: %s" , err )
271275 }
@@ -336,13 +340,15 @@ func testWithOrg1(t *testing.T, sdk *fabsdk.FabricSDK) int {
336340 assert .NotEmpty (t , upgradeResp , "transaction response should be populated" )
337341
338342 // Org2 user moves funds on org2 peer (cc policy fails since both Org1 and Org2 peers should participate)
339- response , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()}, channel .WithTargets (orgTestPeer1 ))
343+ response , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()}, channel .WithTargets (orgTestPeer1 ),
344+ channel .WithRetry (retry .DefaultChClientOpts ))
340345 if err == nil {
341346 t .Fatalf ("Should have failed to move funds due to cc policy" )
342347 }
343348
344349 // Org2 user moves funds (cc policy ok since we have provided peers for both Orgs)
345- response , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()}, channel .WithTargets (orgTestPeer0 , orgTestPeer1 ))
350+ response , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()}, channel .WithTargets (orgTestPeer0 , orgTestPeer1 ),
351+ channel .WithRetry (retry .DefaultChClientOpts ))
346352 if err != nil {
347353 t .Fatalf ("Failed to move funds: %s" , err )
348354 }
@@ -379,7 +385,8 @@ func testWithOrg2(t *testing.T, expectedValue int) int {
379385 }
380386
381387 // Org2 user moves funds (dynamic selection will inspect chaincode policy to determine endorsers)
382- _ , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()})
388+ _ , err = chClientOrg2User .Execute (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCTxArgs ()},
389+ channel .WithRetry (retry .DefaultChClientOpts ))
383390 if err != nil {
384391 t .Fatalf ("Failed to move funds: %s" , err )
385392 }
@@ -407,7 +414,8 @@ func verifyValue(t *testing.T, chClient *channel.Client, expected int) {
407414 var valueInt int
408415 for i := 0 ; i < pollRetries ; i ++ {
409416 // Query final value on org1 peer
410- response , err := chClient .Query (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCQueryArgs ()}, channel .WithTargets (orgTestPeer0 ))
417+ response , err := chClient .Query (channel.Request {ChaincodeID : "exampleCC" , Fcn : "invoke" , Args : integration .ExampleCCQueryArgs ()}, channel .WithTargets (orgTestPeer0 ),
418+ channel .WithRetry (retry .DefaultChClientOpts ))
411419 if err != nil {
412420 t .Fatalf ("Failed to query funds after transaction: %s" , err )
413421 }
0 commit comments