Commit 6be352ae authored by Matthew Sykes's avatar Matthew Sykes Committed by Gari Singh
Browse files

[FAB-11130] add keys to unkeyed struct literals



Use of unkeyed struct literals is flagged as an issue by vet as
reordering the definition of fields in a struct can be problematic. It's
also an anti-pattern with respect to "useful" zero values in idiomatic
go.

Change-Id: I440484a5baf214364b964b157ecbd31df389a59f
Signed-off-by: default avatarMatthew Sykes <sykesmat@us.ibm.com>
parent 74f01e0b
......@@ -54,7 +54,9 @@ func (bh *MSPConfigHandler) ProposeMSP(mspConfig *mspprotos.MSPConfig) (msp.MSP,
}
case int32(msp.IDEMIX):
// create the idemix msp instance
theMsp, err = msp.New(&msp.IdemixNewOpts{msp.NewBaseOpts{Version: bh.version}})
theMsp, err = msp.New(&msp.IdemixNewOpts{
NewBaseOpts: msp.NewBaseOpts{Version: bh.version},
})
if err != nil {
return nil, errors.WithMessage(err, "creating the MSP manager failed")
}
......
......@@ -461,15 +461,15 @@ func initializeCC(t *testing.T, chainID, ccname string, ccSide *mockpeer.MockCCC
// full response
// correct block number for ending sim
respSet = &mockpeer.MockResponseSet{errorFunc, nil, []*mockpeer.MockResponse{
respSet = &mockpeer.MockResponseSet{
DoneFunc: errorFunc,
ErrorFunc: nil,
Responses: []*mockpeer.MockResponse{
{&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_TRANSACTION}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_PUT_STATE, Payload: putils.MarshalOrPanic(&pb.PutState{Collection: "", Key: "A", Value: []byte("100")}), Txid: txid, ChannelId: chainID}},
{&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_PUT_STATE, Payload: putils.MarshalOrPanic(&pb.PutState{Collection: "", Key: "B", Value: []byte("200")}), Txid: txid, ChannelId: chainID}},
// The following private data parameters are disabled because
// this requires private data channel capability ON and hence should be present
// in a dedicated test. One such test is present in file - executetransaction_pvtdata_test.go
// {&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_PUT_STATE, Payload: putils.MarshalOrPanic(&pb.PutState{Collection: "c1", Key: "C", Value: []byte("300")}), Txid: txid, ChannelId: chainID}},
// {&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_PUT_STATE, Payload: putils.MarshalOrPanic(&pb.PutState{Collection: "c2", Key: "C", Value: []byte("300")}), Txid: txid, ChannelId: chainID}},
{&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_COMPLETED, Payload: putils.MarshalOrPanic(&pb.Response{Status: shim.OK, Payload: []byte("OK")}), ChaincodeEvent: &pb.ChaincodeEvent{ChaincodeId: ccname}, Txid: txid, ChannelId: chainID}}}}
{&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_RESPONSE}, &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_COMPLETED, Payload: putils.MarshalOrPanic(&pb.Response{Status: shim.OK, Payload: []byte("OK")}), ChaincodeEvent: &pb.ChaincodeEvent{ChaincodeId: ccname}, Txid: txid, ChannelId: chainID}},
},
}
cccid.Version = "1"
execCC(t, ctxt, ccSide, cccid, false, false, done, cis, respSet, chaincodeSupport)
......
......@@ -17,7 +17,6 @@ import (
"github.com/hyperledger/fabric/core/chaincode/platforms/ccmetadata"
cutil "github.com/hyperledger/fabric/core/container/util"
pb "github.com/hyperledger/fabric/protos/peer"
// "path/filepath"
)
// Platform for java chaincodes in java
......
This diff is collapsed.
......@@ -285,7 +285,9 @@ func (v *VsccValidatorImpl) getCDataForCC(chid, ccid string) (ccprovider.Chainco
bytes, err := qe.GetState("lscc", ccid)
if err != nil {
return nil, &commonerrors.VSCCInfoLookupFailureError{fmt.Sprintf("Could not retrieve state for chaincode %s, error %s", ccid, err)}
return nil, &commonerrors.VSCCInfoLookupFailureError{
Reason: fmt.Sprintf("Could not retrieve state for chaincode %s, error %s", ccid, err),
}
}
if bytes == nil {
......
......@@ -34,7 +34,7 @@ func (c *mockStoreSupport) GetIdentityDeserializer(chainID string) msp.IdentityD
func TestCollectionStore(t *testing.T) {
wState := make(map[string]map[string][]byte)
support := &mockStoreSupport{Qe: &lm.MockQueryExecutor{wState}}
support := &mockStoreSupport{Qe: &lm.MockQueryExecutor{State: wState}}
cs := NewSimpleCollectionStore(support)
assert.NotNil(t, cs)
......@@ -55,7 +55,9 @@ func TestCollectionStore(t *testing.T) {
_, err = cs.RetrieveCollection(ccr)
assert.Error(t, err)
cc := &common.CollectionConfig{Payload: &common.CollectionConfig_StaticCollectionConfig{&common.StaticCollectionConfig{Name: "mycollection"}}}
cc := &common.CollectionConfig{Payload: &common.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &common.StaticCollectionConfig{Name: "mycollection"}},
}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{cc}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
......@@ -70,8 +72,10 @@ func TestCollectionStore(t *testing.T) {
policyEnvelope := cauthdsl.Envelope(cauthdsl.Or(cauthdsl.SignedBy(0), cauthdsl.SignedBy(1)), signers)
accessPolicy := createCollectionPolicyConfig(policyEnvelope)
cc = &common.CollectionConfig{Payload: &common.CollectionConfig_StaticCollectionConfig{&common.StaticCollectionConfig{Name: "mycollection", MemberOrgsPolicy: accessPolicy}}}
ccp = &common.CollectionConfigPackage{[]*common.CollectionConfig{cc}}
cc = &common.CollectionConfig{Payload: &common.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &common.StaticCollectionConfig{Name: "mycollection", MemberOrgsPolicy: accessPolicy},
}}
ccp = &common.CollectionConfigPackage{Config: []*common.CollectionConfig{cc}}
ccpBytes, err = proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......
......@@ -91,7 +91,9 @@ func TestNewDeliverService(t *testing.T) {
return blocksDeliverer, nil
}
abcf := func(*grpc.ClientConn) orderer.AtomicBroadcastClient {
return &mocks.MockAtomicBroadcastClient{blocksDeliverer}
return &mocks.MockAtomicBroadcastClient{
BD: blocksDeliverer,
}
}
connFactory := func(_ string) func(string) (*grpc.ClientConn, error) {
......@@ -109,10 +111,10 @@ func TestNewDeliverService(t *testing.T) {
ConnFactory: connFactory,
})
assert.NoError(t, err)
assert.NoError(t, service.StartDeliverForChannel("TEST_CHAINID", &mocks.MockLedgerInfo{0}, func() {}))
assert.NoError(t, service.StartDeliverForChannel("TEST_CHAINID", &mocks.MockLedgerInfo{Height: 0}, func() {}))
// Lets start deliver twice
assert.Error(t, service.StartDeliverForChannel("TEST_CHAINID", &mocks.MockLedgerInfo{0}, func() {}), "can't start delivery")
assert.Error(t, service.StartDeliverForChannel("TEST_CHAINID", &mocks.MockLedgerInfo{Height: 0}, func() {}), "can't start delivery")
// Lets stop deliver that not started
assert.Error(t, service.StopDeliverForChannel("TEST_CHAINID2"), "can't stop delivery")
......@@ -127,7 +129,7 @@ func TestNewDeliverService(t *testing.T) {
assertBlockDissemination(0, gossipServiceAdapter.GossipBlockDisseminations, t)
assert.Equal(t, atomic.LoadInt32(&blocksDeliverer.RecvCnt), atomic.LoadInt32(&gossipServiceAdapter.AddPayloadsCnt))
assert.Error(t, service.StartDeliverForChannel("TEST_CHAINID", &mocks.MockLedgerInfo{0}, func() {}), "Delivery service is stopping")
assert.Error(t, service.StartDeliverForChannel("TEST_CHAINID", &mocks.MockLedgerInfo{Height: 0}, func() {}), "Delivery service is stopping")
assert.Error(t, service.StopDeliverForChannel("TEST_CHAINID"), "Delivery service is stopping")
}
......
......@@ -915,7 +915,7 @@ func TestValidateDeployWithCollection(t *testing.T) {
coll2 := createCollectionConfig(collName2, policyEnvelope, requiredPeerCount, maximumPeerCount, blockToLive)
// Test 1: Deploy chaincode with a valid collection configs --> success
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1, coll2}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1, coll2}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -946,7 +946,7 @@ func TestValidateDeployWithCollection(t *testing.T) {
// Test 2: Deploy the chaincode with duplicate collection configs --> no error as the
// peer is not in V1_2Validation mode
ccp = &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1, coll2, coll1}}
ccp = &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1, coll2, coll1}}
ccpBytes, err = proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -1308,7 +1308,7 @@ func validateUpgradeWithCollection(t *testing.T, V1_2Validation bool) {
// V1_2Validation enabled: success
// V1_2Validation disable: fail (as no collection updates are allowed)
// Note: We might change V1_2Validation with CollectionUpdate capability
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1, coll2}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1, coll2}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -1351,7 +1351,7 @@ func validateUpgradeWithCollection(t *testing.T, V1_2Validation bool) {
// Test 2: some existing collections are missing in the updated config and peer in
// V1_2Validation mode --> error
ccp = &common.CollectionConfigPackage{[]*common.CollectionConfig{coll3}}
ccp = &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll3}}
ccpBytes, err = proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -1376,7 +1376,7 @@ func validateUpgradeWithCollection(t *testing.T, V1_2Validation bool) {
// Test 3: some existing collections are missing in the updated config and peer in
// V1_2Validation mode --> error
ccp = &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1, coll3}}
ccp = &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1, coll3}}
ccpBytes, err = proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -1401,7 +1401,7 @@ func validateUpgradeWithCollection(t *testing.T, V1_2Validation bool) {
ccver = "3"
// Test 4: valid collection config config and peer in V1_2Validation mode --> success
ccp = &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1, coll2, coll3}}
ccp = &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1, coll2, coll3}}
ccpBytes, err = proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -1707,7 +1707,7 @@ func createCollectionConfig(collectionName string, signaturePolicyEnvelope *comm
return &common.CollectionConfig{
Payload: &common.CollectionConfig_StaticCollectionConfig{
&common.StaticCollectionConfig{
StaticCollectionConfig: &common.StaticCollectionConfig{
Name: collectionName,
MemberOrgsPolicy: accessPolicy,
RequiredPeerCount: requiredPeerCount,
......@@ -1721,7 +1721,7 @@ func createCollectionConfig(collectionName string, signaturePolicyEnvelope *comm
func testValidateCollection(t *testing.T, v *ValidatorOneValidSignature, collectionConfigs []*common.CollectionConfig, cdRWSet *ccprovider.ChaincodeData,
lsccFunc string, ac channelconfig.ApplicationCapabilities, chid string,
) error {
ccp := &common.CollectionConfigPackage{collectionConfigs}
ccp := &common.CollectionConfigPackage{Config: collectionConfigs}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -1849,7 +1849,7 @@ func TestValidateRWSetAndCollectionForDeploy(t *testing.T) {
assert.EqualError(t, err, "collection-name: mycollection3 -- error in member org policy: signature policy is not an OR concatenation, NOutOf 2")
// Test 13: deploy with existing collection config on the ledger -> error
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
state["lscc"][privdata.BuildCollectionKVSKey(ccid)] = ccpBytes
......@@ -1888,7 +1888,7 @@ func TestValidateRWSetAndCollectionForUpgrade(t *testing.T) {
coll2 := createCollectionConfig(collName2, policyEnvelope, requiredPeerCount, maximumPeerCount, blockToLive)
coll3 := createCollectionConfig(collName3, policyEnvelope, requiredPeerCount, maximumPeerCount, blockToLive)
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1, coll2}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1, coll2}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
......
......@@ -74,7 +74,7 @@ func TestValidateAndPreparePvtBatch(t *testing.T) {
pubSimulationResults = append(pubSimulationResults, res)
// Add tx1 private rwset to the private data map
tx1PvtData := &ledger.TxPvtData{0, tx1SimulationResults.PvtSimulationResults}
tx1PvtData := &ledger.TxPvtData{SeqInBlock: 0, WriteSet: tx1SimulationResults.PvtSimulationResults}
pvtDataMap[uint64(0)] = tx1PvtData
// Tx 2
......@@ -99,7 +99,7 @@ func TestValidateAndPreparePvtBatch(t *testing.T) {
pubSimulationResults = append(pubSimulationResults, res)
// Add tx3 private rwset to the private data map
tx3PvtData := &ledger.TxPvtData{2, tx3SimulationResults.PvtSimulationResults}
tx3PvtData := &ledger.TxPvtData{SeqInBlock: 2, WriteSet: tx3SimulationResults.PvtSimulationResults}
pvtDataMap[uint64(2)] = tx3PvtData
// Construct a block using all three transactions' simulation results
......
......@@ -32,7 +32,14 @@ import (
func TestCheckPolicyInvalidArgs(t *testing.T) {
policyManagerGetter := &mocks.MockChannelPolicyManagerGetter{
Managers: map[string]policies.Manager{
"A": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}}},
"A": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{
Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg1"),
},
},
},
},
}
pc := &policyChecker{channelPolicyManagerGetter: policyManagerGetter}
......@@ -54,7 +61,14 @@ func TestRegisterPolicyCheckerFactoryInvalidArgs(t *testing.T) {
func TestRegisterPolicyCheckerFactory(t *testing.T) {
policyManagerGetter := &mocks.MockChannelPolicyManagerGetter{
Managers: map[string]policies.Manager{
"A": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}}},
"A": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{
Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg1"),
},
},
},
},
}
pc := &policyChecker{channelPolicyManagerGetter: policyManagerGetter}
......@@ -70,7 +84,13 @@ func TestRegisterPolicyCheckerFactory(t *testing.T) {
func TestCheckPolicyBySignedDataInvalidArgs(t *testing.T) {
policyManagerGetter := &mocks.MockChannelPolicyManagerGetter{
Managers: map[string]policies.Manager{
"A": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}}},
"A": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{
Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg1"),
}},
},
},
}
pc := &policyChecker{channelPolicyManagerGetter: policyManagerGetter}
......@@ -98,13 +118,31 @@ func TestCheckPolicyBySignedDataInvalidArgs(t *testing.T) {
func TestPolicyCheckerInvalidArgs(t *testing.T) {
policyManagerGetter := &mocks.MockChannelPolicyManagerGetter{
map[string]policies.Manager{
"A": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}}},
"B": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Bob"), []byte("msg2")}}},
"C": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg3")}}},
Managers: map[string]policies.Manager{
"A": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg1"),
}},
},
"B": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Bob"),
Msg: []byte("msg2"),
}},
},
"C": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg3"),
}},
},
},
}
identityDeserializer := &mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}
identityDeserializer := &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg1"),
}
pc := NewPolicyChecker(
policyManagerGetter,
identityDeserializer,
......@@ -134,13 +172,34 @@ func TestPolicyCheckerInvalidArgs(t *testing.T) {
func TestPolicyChecker(t *testing.T) {
policyManagerGetter := &mocks.MockChannelPolicyManagerGetter{
map[string]policies.Manager{
"A": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}}},
"B": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Bob"), []byte("msg2")}}},
"C": &mocks.MockChannelPolicyManager{&mocks.MockPolicy{&mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg3")}}},
Managers: map[string]policies.Manager{
"A": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{
Deserializer: &mocks.MockIdentityDeserializer{Identity: []byte("Alice"), Msg: []byte("msg1")},
},
},
"B": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{
Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Bob"),
Msg: []byte("msg2"),
},
},
},
"C": &mocks.MockChannelPolicyManager{
MockPolicy: &mocks.MockPolicy{
Deserializer: &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg3"),
},
},
},
},
}
identityDeserializer := &mocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg1"),
}
identityDeserializer := &mocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}
pc := NewPolicyChecker(
policyManagerGetter,
identityDeserializer,
......
......@@ -137,7 +137,10 @@ func TestInstall(t *testing.T) {
}
func testInstall(t *testing.T, ccname string, version string, path string, createInvalidIndex bool, expectedErrorMsg string, caller string, scc *LifeCycleSysCC, stub *shim.MockStub) {
identityDeserializer := &policymocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}
identityDeserializer := &policymocks.MockIdentityDeserializer{
Identity: []byte("Alice"),
Msg: []byte("msg1"),
}
policyManagerGetter := &policymocks.MockChannelPolicyManagerGetter{
Managers: map[string]policies.Manager{
"test": &policymocks.MockChannelPolicyManager{MockPolicy: &policymocks.MockPolicy{Deserializer: identityDeserializer}},
......@@ -263,7 +266,7 @@ func TestDeploy(t *testing.T) {
maximumPeerCount = 2
coll1 := createCollectionConfig(collName1, policyEnvelope, requiredPeerCount, maximumPeerCount)
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -311,7 +314,7 @@ func createCollectionConfig(collectionName string, signaturePolicyEnvelope *comm
return &common.CollectionConfig{
Payload: &common.CollectionConfig_StaticCollectionConfig{
&common.StaticCollectionConfig{
StaticCollectionConfig: &common.StaticCollectionConfig{
Name: collectionName,
MemberOrgsPolicy: accessPolicy,
RequiredPeerCount: requiredPeerCount,
......@@ -331,7 +334,7 @@ func testDeploy(t *testing.T, ccname string, version string, path string, forceB
}
stub.ChannelID = chainid
identityDeserializer := &policymocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}
identityDeserializer := &policymocks.MockIdentityDeserializer{Identity: []byte("Alice"), Msg: []byte("msg1")}
policyManagerGetter := &policymocks.MockChannelPolicyManagerGetter{
Managers: map[string]policies.Manager{
"test": &policymocks.MockChannelPolicyManager{MockPolicy: &policymocks.MockPolicy{Deserializer: identityDeserializer}},
......@@ -502,7 +505,7 @@ func TestUpgrade(t *testing.T) {
maximumPeerCount = 2
coll1 := createCollectionConfig(collName1, policyEnvelope, requiredPeerCount, maximumPeerCount)
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......@@ -626,7 +629,7 @@ func TestFunctionsWithAliases(t *testing.T) {
res := stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
identityDeserializer := &policymocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}
identityDeserializer := &policymocks.MockIdentityDeserializer{Identity: []byte("Alice"), Msg: []byte("msg1")}
policyManagerGetter := &policymocks.MockChannelPolicyManagerGetter{
Managers: map[string]policies.Manager{
"test": &policymocks.MockChannelPolicyManager{MockPolicy: &policymocks.MockPolicy{Deserializer: identityDeserializer}},
......@@ -713,7 +716,7 @@ func TestGetInstalledChaincodes(t *testing.T) {
assert.NotEqual(t, int32(shim.OK), res.Status)
assert.Equal(t, "invalid number of arguments to lscc: 2", res.Message)
identityDeserializer := &policymocks.MockIdentityDeserializer{[]byte("Alice"), []byte("msg1")}
identityDeserializer := &policymocks.MockIdentityDeserializer{Identity: []byte("Alice"), Msg: []byte("msg1")}
policyManagerGetter := &policymocks.MockChannelPolicyManagerGetter{
Managers: map[string]policies.Manager{
"test": &policymocks.MockChannelPolicyManager{MockPolicy: &policymocks.MockPolicy{Deserializer: identityDeserializer}},
......@@ -829,7 +832,7 @@ func TestPutChaincodeCollectionData(t *testing.T) {
collName1 := "mycollection1"
policyEnvelope := &common.SignaturePolicyEnvelope{}
coll1 := createCollectionConfig(collName1, policyEnvelope, 1, 2)
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{coll1}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......
......@@ -64,9 +64,9 @@ var _ = Describe("PrivateData-EndToEnd", func() {
By("verify membership was built using discovery service")
expectedDiscoveredPeers = []helpers.DiscoveredPeer{
{"Org1MSP", 0, "0.0.0.0:7051", "", []string{}},
{"Org2MSP", 0, "0.0.0.0:8051", "", []string{}},
{"Org3MSP", 0, "0.0.0.0:9051", "", []string{}},
{MSPID: "Org1MSP", Endpoint: "0.0.0.0:7051"},
{MSPID: "Org2MSP", Endpoint: "0.0.0.0:8051"},
{MSPID: "Org3MSP", Endpoint: "0.0.0.0:9051"},
}
verifyMembership(w, d, expectedDiscoveredPeers)
......
......@@ -80,7 +80,7 @@ func (c *CouchDB) Run(sigCh <-chan os.Signal, ready chan<- struct{}) error {
hostConfig := &docker.HostConfig{
AutoRemove: true,
PortBindings: map[docker.Port][]docker.PortBinding{
c.ContainerPort: []docker.PortBinding{{
c.ContainerPort: {{
HostIP: c.HostIP,
HostPort: strconv.Itoa(c.HostPort),
}},
......
......@@ -95,7 +95,7 @@ var _ = Describe("CouchDB Runner", func() {
ID: "container-id",
NetworkSettings: &docker.NetworkSettings{
Ports: map[docker.Port][]docker.PortBinding{
docker.Port("5984/tcp"): []docker.PortBinding{{
docker.Port("5984/tcp"): {{
HostIP: couchHost,
HostPort: couchPort,
}},
......@@ -235,7 +235,7 @@ var _ = Describe("CouchDB Runner", func() {
HostConfig: &docker.HostConfig{
AutoRemove: true,
PortBindings: map[docker.Port][]docker.PortBinding{
docker.Port("5984/tcp"): []docker.PortBinding{{
docker.Port("5984/tcp"): {{
HostIP: "127.0.0.1",
HostPort: "33333",
}},
......
......@@ -47,14 +47,14 @@ var _ bool = Describe("DiscoveryService", func() {
BeforeEach(func() {
expectedDiscoverdPeers = []helpers.DiscoveredPeer{
{"Org1MSP", 0, "127.0.0.1:12051", "", []string{}},
{MSPID: "Org1MSP", Endpoint: "127.0.0.1:12051"},
}
ordererEndpoint := Endpoint{"127.0.0.1", 8050}
ordererEndpoint := Endpoint{Host: "127.0.0.1", Port: 8050}
expectedConfig = ConfigResult{
Msps: map[string]*msp.FabricMSPConfig{
"OrdererMSP": {"OrdererMSP", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
"Org1MSP": {"Org1MSP", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
"Org2MSP": {"Org2MSP", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil},
"OrdererMSP": {Name: "OrdererMSP"},
"Org1MSP": {Name: "Org1MSP"},
"Org2MSP": {Name: "Org2MSP"},
},
Orderers: map[string]*Endpoints{
"OrdererMSP": {[]*Endpoint{&ordererEndpoint}},
......@@ -63,7 +63,7 @@ var _ bool = Describe("DiscoveryService", func() {
expectedEndrorsementDescriptor = helpers.EndorsementDescriptor{
Chaincode: "mytest",
EndorsersByGroups: map[string][]helpers.DiscoveredPeer{
"A": {{"Org1MSP", 0, "127.0.0.1:12051", "", []string{}}},
"A": {{MSPID: "Org1MSP", Endpoint: "127.0.0.1:12051"}},
},
Layouts: []*Layout{
{QuantitiesByGroup: map[string]uint32{
......
......@@ -125,7 +125,7 @@ func (k *Kafka) Run(sigCh <-chan os.Signal, ready chan<- struct{}) error {
HostConfig: &docker.HostConfig{
AutoRemove: true,
PortBindings: map[docker.Port][]docker.PortBinding{
k.ContainerPort: []docker.PortBinding{{
k.ContainerPort: {{
HostIP: k.HostIP,
HostPort: strconv.Itoa(k.HostPort),
}},
......@@ -141,7 +141,7 @@ func (k *Kafka) Run(sigCh <-chan os.Signal, ready chan<- struct{}) error {
containerOptions.NetworkingConfig = &docker.NetworkingConfig{
EndpointsConfig: map[string]*docker.EndpointConfig{
k.NetworkName: &docker.EndpointConfig{
k.NetworkName: {
NetworkID: nw.ID,
},
},
......
......@@ -119,7 +119,7 @@ func (z *ZooKeeper) Run(sigCh <-chan os.Signal, ready chan<- struct{}) error {
containerOptions.NetworkingConfig = &docker.NetworkingConfig{
EndpointsConfig: map[string]*docker.EndpointConfig{
z.NetworkName: &docker.EndpointConfig{
z.NetworkName: {
NetworkID: nw.ID,
},
},
......
......@@ -179,7 +179,7 @@ func GenerateBasicConfig(ordererType string, numPeers, numPeerOrgs int, testDir
},
Orderer: orderer,
Consortiums: map[string]*localconfig.Consortium{
"SampleConsortium": &localconfig.Consortium{
"SampleConsortium": {
Organizations: append(oOrg, pOrg...),
},
},
......@@ -496,7 +496,7 @@ func (w *World) cleanupDeployment(d Deployment) {
containers, err := w.DockerClient.ListContainers(docker.ListContainersOptions{
All: true,
Filters: map[string][]string{
"name": []string{fmt.Sprintf("%s-%s", d.Chaincode.Name, d.Chaincode.Version)},
"name": {fmt.Sprintf("%s-%s", d.Chaincode.Name, d.Chaincode.Version)},
},
})
ExpectWithOffset(2, err).NotTo(HaveOccurred())
......@@ -508,7 +508,7 @@ func (w *World) cleanupDeployment(d Deployment) {
images, err := w.DockerClient.ListImages(docker.ListImagesOptions{
All: true,
Filters: map[string][]string{
"label": []string{fmt.Sprintf("org.hyperledger.fabric.chaincode.id.name=%s", d.Chaincode.Name)},
"label": {fmt.Sprintf("org.hyperledger.fabric.chaincode.id.name=%s", d.Chaincode.Name)},
},
})
ExpectWithOffset(2, err).NotTo(HaveOccurred())
......
......@@ -164,7 +164,7 @@ var _ = Describe("Config", func() {
Capabilities: map[string]bool{"V1_2": true}},
Orderer: orderer,
Consortiums: map[string]*localconfig.Consortium{
"MyConsortium": &localconfig.Consortium{Organizations: pOrg},
"MyConsortium": {Organizations: pOrg},
},
Capabilities: map[string]bool{"V1_1": true},
}
......@@ -308,7 +308,7 @@ var _ = Describe("Config", func() {
Capabilities: map[string]bool{"V1_2": true}},
Orderer: orderer,
Consortiums: map[string]*localconfig.Consortium{
"MyConsortium": &localconfig.Consortium{
"MyConsortium": {
Organizations: append(oOrg, pOrg...),
},
},
......