Commit e3fe1e09 authored by Gregory Haskins's avatar Gregory Haskins
Browse files

Revert "... uses hardcoded hashcode for example02"

This reverts commit 5d9a3eab

.

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: default avatarGreg Haskins <gregory.haskins@gmail.com>
parent 39f88026
......@@ -882,13 +882,11 @@ func chaincodeInvokeChaincode(t *testing.T, user string) (err error) {
return
}
t.Logf("deployed chaincode_example04 got cID2:% s,\n chaincodeID2:% s", cID2, chaincodeID2)
time.Sleep(time.Second)
// Invoke second chaincode, which will inturn invoke the first chaincode
f = "invoke"
args = util.ToChaincodeArgs(f, "e", "1", chaincodeID1)
args = util.ToChaincodeArgs(f, "e", "1")
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
// Invoke chaincode
......
......@@ -70,8 +70,8 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function stri
var eventVal int // State of event
var err error
if len(args) != 3 {
return nil, errors.New("Incorrect number of arguments. Expecting 3")
if len(args) != 2 {
return nil, errors.New("Incorrect number of arguments. Expecting 2")
}
event = args[0]
......@@ -86,7 +86,7 @@ func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface, function stri
}
// Get the chaincode to call from the ledger
chainCodeToCall := args[2] //t.GetChaincodeToCall()
chainCodeToCall := t.GetChaincodeToCall()
f := "invoke"
invokeArgs := util.ToChaincodeArgs(f, "a", "b", "10")
......
......@@ -104,13 +104,13 @@ func TestExample04_Invoke(t *testing.T) {
checkInit(t, stub, []string{"Event", "1"})
// Invoke A->B for 10 via Example04's chaincode
checkInvoke(t, stub, []string{"Event", "1", scc.GetChaincodeToCall()})
checkInvoke(t, stub, []string{"Event", "1"})
checkQuery(t, stub, "Event", eventResponse)
checkQuery(t, stubEx2, "a", "101")
checkQuery(t, stubEx2, "b", "232")
// Invoke A->B for 10 via Example04's chaincode
checkInvoke(t, stub, []string{"Event", "1", scc.GetChaincodeToCall()})
checkInvoke(t, stub, []string{"Event", "1"})
checkQuery(t, stub, "Event", eventResponse)
checkQuery(t, stubEx2, "a", "91")
checkQuery(t, stubEx2, "b", "242")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment