Skip to content

Commit

Permalink
Revert "... uses hardcoded hashcode for example02"
Browse files Browse the repository at this point in the history
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 <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Oct 21, 2016
1 parent 39f8802 commit e3fe1e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
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) != 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]
Expand All @@ -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")
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", 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")
Expand Down

0 comments on commit e3fe1e0

Please sign in to comment.