Skip to content

Commit 5d9a3ea

Browse files
committed
example04 uses hardcoded hashcode for example02
If chaincode_example02 directory has other files, its deployment hashcode will be different from the hashcode ee5b... hardcoded in chaincode_example04. Change-Id: I4d435123a58d07b3a434f32a3d08e9cf98fdb9c6 Signed-off-by: Gong Su <[email protected]>
1 parent 551fa9b commit 5d9a3ea

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

core/chaincode/exectransaction_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -882,11 +882,13 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
882882
return
883883
}
884884

885+
t.Logf("deployed chaincode_example04 got cID2:% s,\n chaincodeID2:% s", cID2, chaincodeID2)
886+
885887
time.Sleep(time.Second)
886888

887889
// Invoke second chaincode, which will inturn invoke the first chaincode
888890
f = "invoke"
889-
args = util.ToChaincodeArgs(f, "e", "1")
891+
args = util.ToChaincodeArgs(f, "e", "1", chaincodeID1)
890892

891893
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
892894
// Invoke chaincode

examples/chaincode/go/chaincode_example04/chaincode_example04.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function stri
7070
var eventVal int // State of event
7171
var err error
7272

73-
if len(args) != 2 {
74-
return nil, errors.New("Incorrect number of arguments. Expecting 2")
73+
if len(args) != 3 {
74+
return nil, errors.New("Incorrect number of arguments. Expecting 3")
7575
}
7676

7777
event = args[0]
@@ -86,7 +86,7 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function stri
8686
}
8787

8888
// Get the chaincode to call from the ledger
89-
chainCodeToCall := t.GetChaincodeToCall()
89+
chainCodeToCall := args[2] //t.GetChaincodeToCall()
9090

9191
f := "invoke"
9292
invokeArgs := util.ToChaincodeArgs(f, "a", "b", "10")

examples/chaincode/go/chaincode_example04/chaincode_example04_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ func TestExample04_Invoke(t *testing.T) {
104104
checkInit(t, stub, []string{"Event", "1"})
105105

106106
// Invoke A->B for 10 via Example04's chaincode
107-
checkInvoke(t, stub, []string{"Event", "1"})
107+
checkInvoke(t, stub, []string{"Event", "1", scc.GetChaincodeToCall()})
108108
checkQuery(t, stub, "Event", eventResponse)
109109
checkQuery(t, stubEx2, "a", "101")
110110
checkQuery(t, stubEx2, "b", "232")
111111

112112
// Invoke A->B for 10 via Example04's chaincode
113-
checkInvoke(t, stub, []string{"Event", "1"})
113+
checkInvoke(t, stub, []string{"Event", "1", scc.GetChaincodeToCall()})
114114
checkQuery(t, stub, "Event", eventResponse)
115115
checkQuery(t, stubEx2, "a", "91")
116116
checkQuery(t, stubEx2, "b", "242")

0 commit comments

Comments
 (0)