Commit 0045a79d authored by Jason Yellick's avatar Jason Yellick
Browse files

[FAB-2030] Fix protos with uppercase abbreviations

https://jira.hyperledger.org/browse/FAB-2030

According to the proto style guide, fields should be lower_underscored
which generally converts nicely to golang as LowerUnderscored.  However,
for certain cases, like chaincode_id, this converts to ChaincodeId
rather than as desired to ChaincodeID.  This change updates the
problematic fields to use the correct proto style, and updates the
golang to expect the appropriate (although odd) output.

Note, per the proto devs, https://github.com/golang/protobuf/issues/53
there is no intent to modify the protoc generation to attempt to produce
upper case ID API, etc.

Still, the odd golang results seem worth following the style guide.

Note, this CR also changes chainID to channel_id as these lines were
already being affected and a community apparently came to a decision
that the world channel is preferable to the word chain.

https://jira.hyperledger.org/browse/FAB-2033



Change-Id: I9c5ebab88fc8d7f45335c904a56676c55a467e5d
Signed-off-by: default avatarJason Yellick <jyellick@us.ibm.com>
parent 31b9c402
......@@ -29,7 +29,7 @@ import (
func createChaincodeSpec(ccType string, path string, args [][]byte) *pb.ChaincodeSpec {
// make chaincode spec for chaincode to be deployed
ccSpec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[ccType]),
ChaincodeID: &pb.ChaincodeID{Path: path},
ChaincodeId: &pb.ChaincodeID{Path: path},
Input: &pb.ChaincodeInput{Args: args}}
return ccSpec
......@@ -46,7 +46,7 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen
return nil, fmt.Errorf("Error creating proposal from ChaincodeDeploymentSpec: %s", err)
}
lcChaincodeSpec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG,
ChaincodeID: &pb.ChaincodeID{Name: "lccc"},
ChaincodeId: &pb.ChaincodeID{Name: "lccc"},
Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec}
......
......@@ -80,7 +80,7 @@ func SignedByMspMember(mspId string) *cb.SignaturePolicyEnvelope {
// specify the principal: it's a member of the msp we just found
principal := &cb.MSPPrincipal{
PrincipalClassification: cb.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&cb.MSPRole{Role: cb.MSPRole_MEMBER, MSPIdentifier: mspId})}
Principal: utils.MarshalOrPanic(&cb.MSPRole{Role: cb.MSPRole_MEMBER, MspIdentifier: mspId})}
// create the policy: it requires exactly 1 signature from the first (and only) principal
p := &cb.SignaturePolicyEnvelope{
......
......@@ -148,7 +148,7 @@ func secondPass(args ...interface{}) (interface{}, error) {
/* build the principal we've been told */
p := &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{MSPIdentifier: subm[0][1], Role: r})}
Principal: utils.MarshalOrPanic(&common.MSPRole{MspIdentifier: subm[0][1], Role: r})}
ctx.principals = append(ctx.principals, p)
/* create a SignaturePolicy that requires a signature from
......
......@@ -33,11 +33,11 @@ func TestAnd(t *testing.T) {
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
p2 := &common.SignaturePolicyEnvelope{
Version: 0,
......@@ -56,11 +56,11 @@ func TestOr(t *testing.T) {
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
p2 := &common.SignaturePolicyEnvelope{
Version: 0,
......@@ -79,15 +79,15 @@ func TestComplex1(t *testing.T) {
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "C"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "C"})})
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
p2 := &common.SignaturePolicyEnvelope{
Version: 0,
......@@ -106,19 +106,19 @@ func TestComplex2(t *testing.T) {
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "A"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "A"})})
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "B"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "B"})})
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_ADMIN, MSPIdentifier: "C"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_ADMIN, MspIdentifier: "C"})})
principals = append(principals, &common.MSPPrincipal{
PrincipalClassification: common.MSPPrincipal_ROLE,
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MSPIdentifier: "D"})})
Principal: utils.MarshalOrPanic(&common.MSPRole{Role: common.MSPRole_MEMBER, MspIdentifier: "D"})})
p2 := &common.SignaturePolicyEnvelope{
Version: 0,
......
......@@ -59,9 +59,9 @@ type configManager struct {
callOnUpdate []func(api.Manager)
}
// computeChainIDAndSequence returns the chain id and the sequence number for a config envelope
// computeChannelIdAndSequence returns the chain id and the sequence number for a config envelope
// or an error if there is a problem with the config envelope
func computeChainIDAndSequence(config *cb.Config) (string, uint64, error) {
func computeChannelIdAndSequence(config *cb.Config) (string, uint64, error) {
if len(config.Items) == 0 {
return "", 0, errors.New("Empty envelope unsupported")
}
......@@ -72,11 +72,11 @@ func computeChainIDAndSequence(config *cb.Config) (string, uint64, error) {
return "", 0, fmt.Errorf("Header not set")
}
if config.Header.ChainID == "" {
if config.Header.ChannelId == "" {
return "", 0, fmt.Errorf("Header chainID was not set")
}
chainID := config.Header.ChainID
chainID := config.Header.ChannelId
if err := validateChainID(chainID); err != nil {
return "", 0, err
......@@ -146,7 +146,7 @@ func NewManagerImpl(configtx *cb.ConfigEnvelope, initializer api.Initializer, ca
return nil, err
}
chainID, seq, err := computeChainIDAndSequence(config)
chainID, seq, err := computeChannelIdAndSequence(config)
if err != nil {
return nil, fmt.Errorf("Error computing chain ID and sequence: %s", err)
}
......@@ -206,7 +206,7 @@ func (cm *configManager) processConfig(configtx *cb.ConfigEnvelope) (configMap m
return nil, err
}
chainID, seq, err := computeChainIDAndSequence(config)
chainID, seq, err := computeChannelIdAndSequence(config)
if err != nil {
return nil, err
}
......
......@@ -77,7 +77,7 @@ func makeConfigItem(id, modificationPolicy string, lastModified uint64, data []b
func makeMarshaledConfig(chainID string, configItems ...*cb.ConfigItem) []byte {
config := &cb.Config{
Header: &cb.ChainHeader{ChainID: chainID},
Header: &cb.ChainHeader{ChannelId: chainID},
Items: configItems,
}
return utils.MarshalOrPanic(config)
......
......@@ -98,8 +98,8 @@ func (st *simpleTemplate) Envelope(chainID string) (*cb.ConfigEnvelope, error) {
marshaledConfig, err := proto.Marshal(&cb.ConfigNext{
Header: &cb.ChainHeader{
ChainID: chainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
ChannelId: chainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
},
Channel: channel,
})
......@@ -173,8 +173,8 @@ func (ct *compositeTemplate) Envelope(chainID string) (*cb.ConfigEnvelope, error
marshaledConfig, err := proto.Marshal(&cb.ConfigNext{
Header: &cb.ChainHeader{
ChainID: chainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
ChannelId: chainID,
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
},
Channel: channel,
})
......
......@@ -15,7 +15,7 @@ qp6CP8TFHZ9bw5nRtZxIEDAfBgNVHSMEGDAWgBQXZ0I9qp6CP8TFHZ9bw5nRtZxI
EDAKBggqhkjOPQQDAgNHADBEAiAHp5Rbp9Em1G/UmKn8WsCbqDfWecVbZPQj3RK4
oG5kQQIgQAe4OOKYhJdh3f7URaKfGTf492/nmRmtK+ySKjpHSrU=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
"-----BEGIN CERTIFICATE-----
MIICYjCCAgmgAwIBAgIUB3CTDOU47sUC5K4kn/Caqnh114YwCgYIKoZIzj0EAwIw
fzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh
biBGcmFuY2lzY28xHzAdBgNVBAoTFkludGVybmV0IFdpZGdldHMsIEluYy4xDDAK
......@@ -30,7 +30,7 @@ qp6CP8TFHZ9bw5nRtZxIEDAfBgNVHSMEGDAWgBQXZ0I9qp6CP8TFHZ9bw5nRtZxI
EDAKBggqhkjOPQQDAgNHADBEAiAHp5Rbp9Em1G/UmKn8WsCbqDfWecVbZPQj3RK4
oG5kQQIgQAe4OOKYhJdh3f7URaKfGTf492/nmRmtK+ySKjpHSrU=
-----END CERTIFICATE-----
*
2
-----BEGIN CERTIFICATE-----
MIICjDCCAjKgAwIBAgIUBEVwsSx0TmqdbzNwleNBBzoIT0wwCgYIKoZIzj0EAwIw
fzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh
......
......@@ -207,5 +207,5 @@ func extractTxID(txEnvelopBytes []byte) (string, error) {
if err != nil {
return "", nil
}
return txPayload.Header.ChainHeader.TxID, nil
return txPayload.Header.ChainHeader.TxId, nil
}
......@@ -482,11 +482,11 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
}
}
if cds != nil {
cID = cds.ChaincodeSpec.ChaincodeID
cID = cds.ChaincodeSpec.ChaincodeId
cMsg = cds.ChaincodeSpec.Input
cLang = cds.ChaincodeSpec.Type
} else {
cID = ci.ChaincodeSpec.ChaincodeID
cID = ci.ChaincodeSpec.ChaincodeId
cMsg = ci.ChaincodeSpec.Input
}
......
......@@ -31,7 +31,7 @@ import (
//create a chaincode invocation spec
func createCIS(ccname string, args [][]byte) (*pb.ChaincodeInvocationSpec, error) {
var err error
spec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: ccname}, Input: &pb.ChaincodeInput{Args: args}}}
spec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: ccname}, Input: &pb.ChaincodeInput{Args: args}}}
if nil != err {
return nil, err
}
......
......@@ -52,7 +52,7 @@ func TestExecuteConcurrentInvokes(t *testing.T) {
args := util.ToChaincodeArgs("init", "")
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
cccid := ccprovider.NewCCContext(chainID, "nkpi", "0", "", false, nil)
......@@ -85,7 +85,7 @@ func TestExecuteConcurrentInvokes(t *testing.T) {
args = util.ToChaincodeArgs("get", newkey)
}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
//start with a new background
_, _, results[qnum], err = invoke(context.Background(), chainID, spec)
......
......@@ -85,8 +85,8 @@ func Execute(ctxt context.Context, cccid *ccprovider.CCContext, spec interface{}
}
if resp.ChaincodeEvent != nil {
resp.ChaincodeEvent.ChaincodeID = cccid.Name
resp.ChaincodeEvent.TxID = cccid.TxID
resp.ChaincodeEvent.ChaincodeId = cccid.Name
resp.ChaincodeEvent.TxId = cccid.TxID
}
if resp.Type == pb.ChaincodeMessage_COMPLETED {
......
......@@ -85,7 +85,7 @@ func initPeer(chainIDs ...string) (net.Listener, error) {
}
getPeerEndpoint := func() (*pb.PeerEndpoint, error) {
return &pb.PeerEndpoint{ID: &pb.PeerID{Name: "testpeer"}, Address: peerAddress}, nil
return &pb.PeerEndpoint{Id: &pb.PeerID{Name: "testpeer"}, Address: peerAddress}, nil
}
ccStartupTimeout := time.Duration(chaincodeStartupTimeoutDefault) * time.Millisecond
......@@ -241,7 +241,7 @@ func getDeployLCCCSpec(chainID string, cds *pb.ChaincodeDeploymentSpec) (*pb.Cha
sysCCVers := util.GetSysCCVersion()
//wrap the deployment in an invocation spec to lccc...
lcccSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeID: &pb.ChaincodeID{Name: "lccc", Version: sysCCVers}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte(chainID), b}}}}
lcccSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: &pb.ChaincodeID{Name: "lccc", Version: sysCCVers}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte(chainID), b}}}}
return lcccSpec, nil
}
......@@ -288,7 +288,7 @@ func deploy2(ctx context.Context, cccid *ccprovider.CCContext, chaincodeDeployme
}
sysCCVers := util.GetSysCCVersion()
lcccid := ccprovider.NewCCContext(cccid.ChainID, cis.ChaincodeSpec.ChaincodeID.Name, sysCCVers, uuid, true, nil)
lcccid := ccprovider.NewCCContext(cccid.ChainID, cis.ChaincodeSpec.ChaincodeId.Name, sysCCVers, uuid, true, nil)
//write to lccc
if _, _, err = ExecuteWithErrorFilter(ctx, lcccid, cis); err != nil {
......@@ -331,7 +331,7 @@ func invokeWithVersion(ctx context.Context, chainID string, version string, spec
}
}()
cccid := ccprovider.NewCCContext(chainID, chaincodeInvocationSpec.ChaincodeSpec.ChaincodeID.Name, version, uuid, false, nil)
cccid := ccprovider.NewCCContext(chainID, chaincodeInvocationSpec.ChaincodeSpec.ChaincodeId.Name, version, uuid, false, nil)
retval, ccevt, err = ExecuteWithErrorFilter(ctx, cccid, chaincodeInvocationSpec)
if err != nil {
return nil, uuid, nil, fmt.Errorf("Error invoking chaincode: %s", err)
......@@ -360,13 +360,13 @@ func executeDeployTransaction(t *testing.T, chainID string, name string, url str
f := "init"
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: name, Path: url, Version: "0"}, Input: &pb.ChaincodeInput{Args: args}}
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: name, Path: url, Version: "0"}, Input: &pb.ChaincodeInput{Args: args}}
cccid := ccprovider.NewCCContext(chainID, name, "0", "", false, nil)
_, err = deploy(ctxt, cccid, spec)
chaincodeID := spec.ChaincodeID.Name
chaincodeID := spec.ChaincodeId.Name
if err != nil {
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec})
t.Fail()
......@@ -387,13 +387,13 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f := "init"
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, Input: &pb.ChaincodeInput{Args: args}}
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID1, Input: &pb.ChaincodeInput{Args: args}}
cccid1 := ccprovider.NewCCContext(chainID, "example02", "0", "", false, nil)
_, err := deploy(ctxt, cccid1, spec1)
chaincodeID1 := spec1.ChaincodeID.Name
chaincodeID1 := spec1.ChaincodeId.Name
if err != nil {
theChaincodeSupport.Stop(ctxt, cccid1, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1})
return fmt.Errorf("Error initializing chaincode %s(%s)", chaincodeID1, err)
......@@ -408,12 +408,12 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f = "init"
args = util.ToChaincodeArgs(f, "sum", "0")
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}}
cccid2 := ccprovider.NewCCContext(chainID, "example05", "0", "", false, nil)
_, err = deploy(ctxt, cccid2, spec2)
chaincodeID2 := spec2.ChaincodeID.Name
chaincodeID2 := spec2.ChaincodeId.Name
if err != nil {
theChaincodeSupport.Stop(ctxt, cccid1, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec1})
theChaincodeSupport.Stop(ctxt, cccid2, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec2})
......@@ -426,7 +426,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f = "invoke"
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
var retVal []byte
_, _, retVal, err = invoke(ctxt, chainID, spec2)
......@@ -449,7 +449,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f = "query"
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
_, _, retVal, err = invoke(ctxt, chainID, spec2)
......@@ -550,9 +550,9 @@ func invokeExample02Transaction(ctxt context.Context, cccid *ccprovider.CCContex
f := "init"
argsDeploy := util.ToChaincodeArgs(f, "a", "100", "b", "200")
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: argsDeploy}}
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: argsDeploy}}
_, err := deploy(ctxt, cccid, spec)
chaincodeID := spec.ChaincodeID.Name
chaincodeID := spec.ChaincodeId.Name
if err != nil {
return fmt.Errorf("Error deploying <%s>: %s", chaincodeID, err)
}
......@@ -572,7 +572,7 @@ func invokeExample02Transaction(ctxt context.Context, cccid *ccprovider.CCContex
f = "invoke"
invokeArgs := append([]string{f}, args...)
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(invokeArgs...)}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(invokeArgs...)}}
_, uuid, _, err := invoke(ctxt, cccid.ChainID, spec)
if err != nil {
return fmt.Errorf("Error invoking <%s>: %s", cccid.Name, err)
......@@ -587,7 +587,7 @@ func invokeExample02Transaction(ctxt context.Context, cccid *ccprovider.CCContex
// Test for delete state
f = "delete"
delArgs := util.ToChaincodeArgs(f, "a")
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: delArgs}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: delArgs}}
_, uuid, _, err = invoke(ctxt, cccid.ChainID, spec)
if err != nil {
return fmt.Errorf("Error deleting state in <%s>: %s", cccid.Name, err)
......@@ -623,7 +623,7 @@ func TestExecuteInvokeTransaction(t *testing.T) {
t.Logf("Invoke test passed")
}
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeID: chaincodeID}})
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeId: chaincodeID}})
}
// Test the execution of an invalid transaction.
......@@ -654,7 +654,7 @@ func TestExecuteInvokeInvalidTransaction(t *testing.T) {
errStr := err.Error()
t.Logf("Got error %s\n", errStr)
t.Logf("InvalidInvoke test passed")
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeID: chaincodeID}})
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeId: chaincodeID}})
return
}
......@@ -662,7 +662,7 @@ func TestExecuteInvokeInvalidTransaction(t *testing.T) {
t.Fail()
t.Logf("Error invoking transaction %s", err)
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeID: chaincodeID}})
theChaincodeSupport.Stop(ctxt, cccid, &pb.ChaincodeDeploymentSpec{ChaincodeSpec: &pb.ChaincodeSpec{ChaincodeId: chaincodeID}})
}
// Test the execution of a chaincode that invokes another chaincode.
......@@ -698,12 +698,12 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
f := "init"
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, Input: &pb.ChaincodeInput{Args: args}}
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID1, Input: &pb.ChaincodeInput{Args: args}}
cccid1 := ccprovider.NewCCContext(chainID, "example02", "0", "", false, nil)
_, err = deploy(ctxt, cccid1, spec1)
chaincodeID1 := spec1.ChaincodeID.Name
chaincodeID1 := spec1.ChaincodeId.Name
if err != nil {
t.Fail()
t.Logf("Error initializing chaincode %s(%s)", chaincodeID1, err)
......@@ -722,12 +722,12 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
f = "init"
args = util.ToChaincodeArgs(f, "e", "0")
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}}
cccid2 := ccprovider.NewCCContext(chainID, "example04", "0", "", false, nil)
_, err = deploy(ctxt, cccid2, spec2)
chaincodeID2 := spec2.ChaincodeID.Name
chaincodeID2 := spec2.ChaincodeId.Name
if err != nil {
t.Fail()
t.Logf("Error initializing chaincode %s(%s)", chaincodeID2, err)
......@@ -741,10 +741,10 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
// Invoke second chaincode passing the first chaincode's name as first param,
// which will inturn invoke the first chaincode
f = "invoke"
cid := spec1.ChaincodeID.Name
cid := spec1.ChaincodeId.Name
args = util.ToChaincodeArgs(f, cid, "e", "1")
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
var uuid string
_, uuid, _, err = invoke(ctxt, chainID, spec2)
......@@ -797,12 +797,12 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
f := "init"
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, Input: &pb.ChaincodeInput{Args: args}}
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID1, Input: &pb.ChaincodeInput{Args: args}}
cccid1 := ccprovider.NewCCContext(chainID, "example02", "0", "", false, nil)
_, err = deploy(ctxt, cccid1, spec1)
chaincodeID1 := spec1.ChaincodeID.Name
chaincodeID1 := spec1.ChaincodeId.Name
if err != nil {
t.Fail()
t.Logf("Error initializing chaincode %s(%s)", chaincodeID1, err)
......@@ -819,12 +819,12 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
f = "init"
args = util.ToChaincodeArgs(f)
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}}
cccid2 := ccprovider.NewCCContext(chainID, "pthru", "0", "", false, nil)
_, err = deploy(ctxt, cccid2, spec2)
chaincodeID2 := spec2.ChaincodeID.Name
chaincodeID2 := spec2.ChaincodeId.Name
if err != nil {
t.Fail()
t.Logf("Error initializing chaincode %s(%s)", chaincodeID2, err)
......@@ -839,7 +839,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
f = chaincodeID1
args = util.ToChaincodeArgs(f, "invoke", "a")
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID2, Input: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
_, _, _, err = invoke(ctxt, chainID, spec2)
......@@ -884,12 +884,12 @@ func TestQueries(t *testing.T) {
f := "init"
args := util.ToChaincodeArgs(f)
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}}
cccid := ccprovider.NewCCContext(chainID, "tmap", "0", "", false, nil)
_, err = deploy(ctxt, cccid, spec)
chaincodeID := spec.ChaincodeID.Name
chaincodeID := spec.ChaincodeId.Name
if err != nil {
t.Fail()
t.Logf("Error initializing chaincode %s(%s)", chaincodeID, err)
......@@ -900,7 +900,7 @@ func TestQueries(t *testing.T) {
// Invoke second chaincode, which will inturn invoke the first chaincode
f = "put"
args = util.ToChaincodeArgs(f, "key1", "{\"shipmentID\":\"161003PKC7300\",\"customsInvoice\":{\"methodOfTransport\":\"GROUND\",\"invoiceNumber\":\"00091622\"},\"weightUnitOfMeasure\":\"KGM\",\"volumeUnitOfMeasure\": \"CO\",\"dimensionUnitOfMeasure\":\"CM\",\"currency\":\"USD\"}")
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}}
_, _, _, err = invoke(ctxt, chainID, spec)
if err != nil {
......@@ -912,7 +912,7 @@ func TestQueries(t *testing.T) {
f = "put"
args = util.ToChaincodeArgs(f, "key2", "{\"shipmentID\":\"161003PKC7300\",\"customsInvoice\":{\"methodOfTransport\":\"GROUND\",\"invoiceNumber\":\"00091622\"},\"weightUnitOfMeasure\":\"KGM\",\"volumeUnitOfMeasure\": \"CO\",\"dimensionUnitOfMeasure\":\"CM\",\"currency\":\"USD\"}")
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}}
_, _, _, err = invoke(ctxt, chainID, spec)
if err != nil {
......@@ -924,7 +924,7 @@ func TestQueries(t *testing.T) {
f = "put"
args = util.ToChaincodeArgs(f, "key3", "{\"shipmentID\":\"161003PKC7300\",\"customsInvoice\":{\"methodOfTransport\":\"GROUND\",\"invoiceNumber\":\"00091622\"},\"weightUnitOfMeasure\":\"KGM\",\"volumeUnitOfMeasure\": \"CO\",\"dimensionUnitOfMeasure\":\"CM\",\"currency\":\"USD\"}")
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}}
_, _, _, err = invoke(ctxt, chainID, spec)
if err != nil {
......@@ -937,7 +937,7 @@ func TestQueries(t *testing.T) {
f = "keys"
args = util.ToChaincodeArgs(f, "key0", "key3")
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}}
_, _, _, err = invoke(ctxt, chainID, spec)
if err != nil {
......@@ -951,7 +951,7 @@ func TestQueries(t *testing.T) {
f = "query"
args = util.ToChaincodeArgs(f, "{\"selector\":{\"currency\":\"USD\"}}")
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: args}}
_, _, _, err = invoke(ctxt, chainID, spec)
if err != nil {
......@@ -981,12 +981,12 @@ func TestGetEvent(t *testing.T) {
cID := &pb.ChaincodeID{Name: "esender", Path: url, Version: "0"}
f := "init"
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(f)}}
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: cID, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(f)}}
cccid := ccprovider.NewCCContext(chainID, "esender", "0", "", false, nil)
_, err = deploy(ctxt, cccid, spec)
chaincodeID := spec.ChaincodeID.Name
chaincodeID := spec.ChaincodeId.Name
if err != nil {
t.Fail()
t.Logf("Error initializing chaincode %s(%s)", chaincodeID, err)
......@@ -998,7 +998,7 @@ func TestGetEvent(t *testing.T) {
args := util.ToChaincodeArgs("invoke", "i", "am", "satoshi")