diff --git a/test/fixtures/src/github.com/events_cc/events_cc.go b/test/fixtures/src/github.com/events_cc/events_cc.go index 6630049184..36c8a00bcf 100644 --- a/test/fixtures/src/github.com/events_cc/events_cc.go +++ b/test/fixtures/src/github.com/events_cc/events_cc.go @@ -33,13 +33,14 @@ type EventSender struct { func (t *EventSender) Init(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("*********** Init ***********") - err := stub.PutState("num_events", []byte("0")) + err := stub.PutState("numEvents", []byte("0")) if err != nil { return shim.Error(err.Error()) } return shim.Success(nil) } +// Invoke - invoke the chaincode func (t *EventSender) Invoke(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("*********** Invoke ***********") function, args := stub.GetFunctionAndParameters() @@ -67,20 +68,20 @@ func (t *EventSender) invoke(stub shim.ChaincodeStubInterface) pb.Response { if len(args) != 2 { return shim.Error("Incorrect number of arguments. Expecting 2") } - b, err := stub.GetState("num_events") + b, err := stub.GetState("numEvents") if err != nil { return shim.Error("Failed to get state") } - num_events, _ := strconv.Atoi(string(b)) + numEvents, _ := strconv.Atoi(string(b)) tosend := "Event " + string(b) + args[1] eventName := "evtsender" + args[0] - logger.Infof("########### invoke - num_events:%s\n", num_events) + logger.Infof("########### invoke - numEvents:%s\n", numEvents) logger.Infof("########### invoke - tosend:%s\n", tosend) logger.Infof("########### invoke - eventName:%s\n", eventName) - err = stub.PutState("num_events", []byte(strconv.Itoa(num_events+1))) + err = stub.PutState("numEvents", []byte(strconv.Itoa(numEvents+1))) if err != nil { return shim.Error(err.Error()) } @@ -96,7 +97,7 @@ func (t *EventSender) invoke(stub shim.ChaincodeStubInterface) pb.Response { func (t *EventSender) clear(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### clear ###########") - err := stub.PutState("num_events", []byte("0")) + err := stub.PutState("numEvents", []byte("0")) if err != nil { return shim.Error(err.Error()) } @@ -107,9 +108,9 @@ func (t *EventSender) clear(stub shim.ChaincodeStubInterface) pb.Response { func (t *EventSender) query(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### query ###########") - b, err := stub.GetState("num_events") - num_events, _ := strconv.Atoi(string(b)) - logger.Infof("########### query - num_events:%s\n", num_events) + b, err := stub.GetState("numEvents") + numEvents, _ := strconv.Atoi(string(b)) + logger.Infof("########### query - numEvents:%s\n", numEvents) if err != nil { return shim.Error("Failed to get state") diff --git a/test/fixtures/src/github.com/example_cc/example_cc.go b/test/fixtures/src/github.com/example_cc/example_cc.go index 8608cd14a3..bb52a03a23 100644 --- a/test/fixtures/src/github.com/example_cc/example_cc.go +++ b/test/fixtures/src/github.com/example_cc/example_cc.go @@ -31,6 +31,7 @@ var logger = shim.NewLogger("example_cc0") type SimpleChaincode struct { } +// Init - initialize the state func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### example_cc0 Init ###########") @@ -70,12 +71,12 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { return shim.Success(nil) } -// Transaction makes payment of X units from A to B +// Invoke - Transaction makes payment of X units from A to B func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### example_cc0 Invoke ###########") function, args := stub.GetFunctionAndParameters() - + if function == "delete" { // Deletes an entity from its state return t.delete(stub, args) diff --git a/test/fixtures/src/github.com/example_cc1/example_cc1.go b/test/fixtures/src/github.com/example_cc1/example_cc1.go index aaef4f17e9..06e6664c64 100644 --- a/test/fixtures/src/github.com/example_cc1/example_cc1.go +++ b/test/fixtures/src/github.com/example_cc1/example_cc1.go @@ -31,6 +31,7 @@ var logger = shim.NewLogger("example_cc1") type SimpleChaincode struct { } +//Init - instantiation of the state func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### example_cc1 Init ###########") @@ -39,7 +40,7 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { return t.testTransient(stub) } -// Transaction makes payment of X units from A to B +// Invoke - Transaction makes payment of X units from A to B func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### example_cc1 Invoke ###########") @@ -109,7 +110,7 @@ func (t *SimpleChaincode) move(stub shim.ChaincodeStubInterface, args []string) return shim.Error("Invalid transaction amount, expecting a integer value") } Aval = Aval - X - Bval = Bval + X + 10 //new version chaincode gives a bonus + Bval = Bval + X + 10 //new version chaincode gives a bonus logger.Infof("Aval = %d, Bval = %d\n", Aval, Bval) // Write the state back to the ledger diff --git a/test/fixtures/src/github.com/example_cc2/example_cc2.go b/test/fixtures/src/github.com/example_cc2/example_cc2.go index 6acdf8d511..45600182ea 100644 --- a/test/fixtures/src/github.com/example_cc2/example_cc2.go +++ b/test/fixtures/src/github.com/example_cc2/example_cc2.go @@ -31,7 +31,7 @@ var logger = shim.NewLogger("example_cc2") type SimpleChaincode struct { } -// Re-initialize one of the parties' asset holdings +// Init - Re-initialize one of the parties' asset holdings func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### example_cc2 Init ###########") @@ -58,7 +58,7 @@ func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { return shim.Success(nil) } -// Transaction makes payment of X units from A to B +// Invoke - Transaction makes payment of X units from A to B func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { logger.Info("########### example_cc1 Invoke ###########")