Skip to content

Commit

Permalink
example04 uses hardcoded hashcode for example02
Browse files Browse the repository at this point in the history
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 <gongsugongsu@gmail.com>
  • Loading branch information
s390xlinux committed Oct 14, 2016
1 parent 551fa9b commit 5d9a3ea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,11 +882,13 @@ 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")
args = util.ToChaincodeArgs(f, "e", "1", chaincodeID1)

spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
// Invoke chaincode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) != 2 {
return nil, errors.New("Incorrect number of arguments. Expecting 2")
if len(args) != 3 {
return nil, errors.New("Incorrect number of arguments. Expecting 3")
}

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

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

f := "invoke"
invokeArgs := util.ToChaincodeArgs(f, "a", "b", "10")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
checkInvoke(t, stub, []string{"Event", "1", scc.GetChaincodeToCall()})
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"})
checkInvoke(t, stub, []string{"Event", "1", scc.GetChaincodeToCall()})
checkQuery(t, stub, "Event", eventResponse)
checkQuery(t, stubEx2, "a", "91")
checkQuery(t, stubEx2, "b", "242")
Expand Down

0 comments on commit 5d9a3ea

Please sign in to comment.