@@ -387,7 +387,7 @@ func closeListenerAndSleep(l net.Listener) {
387
387
}
388
388
}
389
389
390
- func executeDeployTransaction (t * testing.T , url string ) {
390
+ func executeDeployTransaction (t * testing.T , name string , url string ) {
391
391
lis , err := initPeer ()
392
392
if err != nil {
393
393
t .Fail ()
@@ -400,7 +400,7 @@ func executeDeployTransaction(t *testing.T, url string) {
400
400
401
401
f := "init"
402
402
args := util .ToChaincodeArgs (f , "a" , "100" , "b" , "200" )
403
- spec := & pb.ChaincodeSpec {Type : 1 , ChaincodeID : & pb.ChaincodeID {Path : url }, CtorMsg : & pb.ChaincodeInput {Args : args }}
403
+ spec := & pb.ChaincodeSpec {Type : 1 , ChaincodeID : & pb.ChaincodeID {Name : name , Path : url }, CtorMsg : & pb.ChaincodeInput {Args : args }}
404
404
_ , err = deploy (ctxt , spec )
405
405
chaincodeID := spec .ChaincodeID .Name
406
406
if err != nil {
@@ -415,23 +415,23 @@ func executeDeployTransaction(t *testing.T, url string) {
415
415
416
416
// Test deploy of a transaction
417
417
func TestExecuteDeployTransaction (t * testing.T ) {
418
- executeDeployTransaction (t , "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" )
418
+ executeDeployTransaction (t , "example01" , " github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" )
419
419
}
420
420
421
421
// Test deploy of a transaction with a GOPATH with multiple elements
422
422
func TestGopathExecuteDeployTransaction (t * testing.T ) {
423
423
// add a trailing slash to GOPATH
424
424
// and a couple of elements - it doesn't matter what they are
425
425
os .Setenv ("GOPATH" , os .Getenv ("GOPATH" )+ string (os .PathSeparator )+ string (os .PathListSeparator )+ "/tmp/foo" + string (os .PathListSeparator )+ "/tmp/bar" )
426
- executeDeployTransaction (t , "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" )
426
+ executeDeployTransaction (t , "example01" , " github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" )
427
427
}
428
428
429
429
// Test deploy of a transaction with a chaincode over HTTP.
430
430
func TestHTTPExecuteDeployTransaction (t * testing.T ) {
431
431
// The chaincode used here cannot be from the fabric repo
432
432
// itself or it won't be downloaded because it will be found
433
433
// in GOPATH, which would defeat the test
434
- executeDeployTransaction (t , "http://gopkg.in/mastersingh24/fabric-test-resources.v1" )
434
+ executeDeployTransaction (t , "example01" , " http://gopkg.in/mastersingh24/fabric-test-resources.v1" )
435
435
}
436
436
437
437
// Check the correctness of the final state after transaction execution.
@@ -537,7 +537,7 @@ func TestExecuteInvokeTransaction(t *testing.T) {
537
537
var ctxt = context .Background ()
538
538
539
539
url := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
540
- chaincodeID := & pb.ChaincodeID {Path : url }
540
+ chaincodeID := & pb.ChaincodeID {Name : "example02" , Path : url }
541
541
542
542
args := []string {"a" , "b" , "10" }
543
543
err = invokeExample02Transaction (ctxt , chaincodeID , args , true )
@@ -601,7 +601,7 @@ func TestExecuteQuery(t *testing.T) {
601
601
602
602
url := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
603
603
604
- cID := & pb.ChaincodeID {Path : url }
604
+ cID := & pb.ChaincodeID {Name : "example02" , Path : url }
605
605
f := "init"
606
606
args := util .ToChaincodeArgs (f , "a" , "100" , "b" , "200" )
607
607
@@ -658,7 +658,7 @@ func TestExecuteInvokeInvalidTransaction(t *testing.T) {
658
658
var ctxt = context .Background ()
659
659
660
660
url := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
661
- chaincodeID := & pb.ChaincodeID {Path : url }
661
+ chaincodeID := & pb.ChaincodeID {Name : "example02" , Path : url }
662
662
663
663
//FAIL, FAIL!
664
664
args := []string {"x" , "-1" }
@@ -707,7 +707,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
707
707
// Deploy first chaincode
708
708
url1 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
709
709
710
- cID1 := & pb.ChaincodeID {Path : url1 }
710
+ cID1 := & pb.ChaincodeID {Name : "example02" , Path : url1 }
711
711
f := "init"
712
712
args := util .ToChaincodeArgs (f , "a" , "100" , "b" , "200" )
713
713
@@ -729,7 +729,7 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
729
729
// Deploy second chaincode
730
730
url2 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example04"
731
731
732
- cID2 := & pb.ChaincodeID {Path : url2 }
732
+ cID2 := & pb.ChaincodeID {Name : "example04" , Path : url2 }
733
733
f = "init"
734
734
args = util .ToChaincodeArgs (f , "e" , "0" )
735
735
@@ -747,8 +747,9 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
747
747
748
748
time .Sleep (time .Second )
749
749
750
- // Invoke second chaincode, which will inturn invoke the first chaincode
751
- f = "invoke"
750
+ // Invoke second chaincode passing the first chaincode's name as first param,
751
+ // which will inturn invoke the first chaincode
752
+ f = spec1 .ChaincodeID .Name
752
753
args = util .ToChaincodeArgs (f , "e" , "1" )
753
754
754
755
spec2 = & pb.ChaincodeSpec {Type : 1 , ChaincodeID : cID2 , CtorMsg : & pb.ChaincodeInput {Args : args }, SecureContext : user }
@@ -796,7 +797,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
796
797
// Deploy first chaincode
797
798
url1 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
798
799
799
- cID1 := & pb.ChaincodeID {Path : url1 }
800
+ cID1 := & pb.ChaincodeID {Name : "example02" , Path : url1 }
800
801
f := "init"
801
802
args := util .ToChaincodeArgs (f , "a" , "100" , "b" , "200" )
802
803
@@ -816,7 +817,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
816
817
// Deploy second chaincode
817
818
url2 := "github.com/hyperledger/fabric/examples/chaincode/go/passthru"
818
819
819
- cID2 := & pb.ChaincodeID {Path : url2 }
820
+ cID2 := & pb.ChaincodeID {Name : "pthru" , Path : url2 }
820
821
f = "init"
821
822
args = util .ToChaincodeArgs (f )
822
823
@@ -868,7 +869,7 @@ func chaincodeQueryChaincode(user string) error {
868
869
// Deploy first chaincode
869
870
url1 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
870
871
871
- cID1 := & pb.ChaincodeID {Path : url1 }
872
+ cID1 := & pb.ChaincodeID {Name : "example02" , Path : url1 }
872
873
f := "init"
873
874
args := util .ToChaincodeArgs (f , "a" , "100" , "b" , "200" )
874
875
@@ -886,7 +887,7 @@ func chaincodeQueryChaincode(user string) error {
886
887
// Deploy second chaincode
887
888
url2 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example05"
888
889
889
- cID2 := & pb.ChaincodeID {Path : url2 }
890
+ cID2 := & pb.ChaincodeID {Name : "example05" , Path : url2 }
890
891
f = "init"
891
892
args = util .ToChaincodeArgs (f , "sum" , "0" )
892
893
@@ -994,7 +995,7 @@ func TestChaincodeQueryChaincodeErrorCase(t *testing.T) {
994
995
// Deploy first chaincode
995
996
url1 := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
996
997
997
- cID1 := & pb.ChaincodeID {Path : url1 }
998
+ cID1 := & pb.ChaincodeID {Name : "example02" , Path : url1 }
998
999
f := "init"
999
1000
args := util .ToChaincodeArgs (f , "a" , "100" , "b" , "200" )
1000
1001
@@ -1014,7 +1015,7 @@ func TestChaincodeQueryChaincodeErrorCase(t *testing.T) {
1014
1015
// Deploy second chaincode
1015
1016
url2 := "github.com/hyperledger/fabric/examples/chaincode/go/passthru"
1016
1017
1017
- cID2 := & pb.ChaincodeID {Path : url2 }
1018
+ cID2 := & pb.ChaincodeID {Name : "pthru" , Path : url2 }
1018
1019
f = "init"
1019
1020
args = util .ToChaincodeArgs (f )
1020
1021
@@ -1128,7 +1129,7 @@ func TestRangeQuery(t *testing.T) {
1128
1129
var ctxt = context .Background ()
1129
1130
1130
1131
url := "github.com/hyperledger/fabric/examples/chaincode/go/map"
1131
- cID := & pb.ChaincodeID {Path : url }
1132
+ cID := & pb.ChaincodeID {Name : "tmap" , Path : url }
1132
1133
1133
1134
f := "init"
1134
1135
args := util .ToChaincodeArgs (f )
@@ -1173,7 +1174,7 @@ func TestGetEvent(t *testing.T) {
1173
1174
1174
1175
url := "github.com/hyperledger/fabric/examples/chaincode/go/eventsender"
1175
1176
1176
- cID := & pb.ChaincodeID {Path : url }
1177
+ cID := & pb.ChaincodeID {Name : "esender" , Path : url }
1177
1178
f := "init"
1178
1179
spec := & pb.ChaincodeSpec {Type : 1 , ChaincodeID : cID , CtorMsg : & pb.ChaincodeInput {Args : util .ToChaincodeArgs (f )}}
1179
1180
0 commit comments