Skip to content

Commit e3fe1e0

Browse files
committed
Revert "... uses hardcoded hashcode for example02"
This reverts commit 5d9a3ea. chaincode_example04 calls chaincode_example02 via a hard-coded ID. This is intentional to catch change to the ID when NOTHING in chaincode_example02 or in its folder changes. ie, a test for the constancy of the hash generation algorithm. The patch attempt pass the ID as a parameter to prevent accidental changes to chaincode_example02 from causing test failures. While well-intented, this subverts the above reasoning behind the hard-coding. Also note that chaincode_example05 does take the argument as a parameter (so that usage is already covered). Change-Id: I8e305efb6fd577bc7d7e3d720d293cfb0e3c191f Signed-off-by: Greg Haskins <[email protected]>
1 parent 39f8802 commit e3fe1e0

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

core/chaincode/exectransaction_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,11 @@ 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-
887885
time.Sleep(time.Second)
888886

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

893891
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
894892
// 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) != 3 {
74-
return nil, errors.New("Incorrect number of arguments. Expecting 3")
73+
if len(args) != 2 {
74+
return nil, errors.New("Incorrect number of arguments. Expecting 2")
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 := args[2] //t.GetChaincodeToCall()
89+
chainCodeToCall := 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", scc.GetChaincodeToCall()})
107+
checkInvoke(t, stub, []string{"Event", "1"})
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", scc.GetChaincodeToCall()})
113+
checkInvoke(t, stub, []string{"Event", "1"})
114114
checkQuery(t, stub, "Event", eventResponse)
115115
checkQuery(t, stubEx2, "a", "91")
116116
checkQuery(t, stubEx2, "b", "242")

0 commit comments

Comments
 (0)