Skip to content

Commit

Permalink
[FAB-7802] Automatic format fix using gofmt
Browse files Browse the repository at this point in the history
gofmt -w -s

Many developers have integrated `gofmt`  auto-formatting. S
Some code changes can automatically cause other changes caused through
`gofmt` integration, not related to the intent of the task.

For clarity in future pull-requests, the gofmt issues should be solved
once and for all.

This change doesn't break the code, because it uses official `gofmt` to do
the auto code formatting.

Change-Id: Ife1c2e112dc4f188fb6a90916587af453a133099
Signed-off-by: Robert Zaremba <robert.zaremba@scale-it.pl>
  • Loading branch information
robert-zaremba committed Jan 18, 2018
1 parent 2c8a82a commit e14f208
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 68 deletions.
2 changes: 1 addition & 1 deletion common/capabilities/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestApplicationV10(t *testing.T) {

func TestApplicationV11(t *testing.T) {
op := NewApplicationProvider(map[string]*cb.Capability{
ApplicationV1_1: &cb.Capability{},
ApplicationV1_1: {},
})
assert.NoError(t, op.Supported())
assert.True(t, op.ForbidDuplicateTXIdInBlock())
Expand Down
2 changes: 1 addition & 1 deletion common/capabilities/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestSatisfied(t *testing.T) {

func TestNotSatisfied(t *testing.T) {
capsMap := map[string]*cb.Capability{
"FakeCapability": &cb.Capability{},
"FakeCapability": {},
}
for _, provider := range []*registry{
NewChannelProvider(capsMap).registry,
Expand Down
2 changes: 1 addition & 1 deletion common/capabilities/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestChannelV10(t *testing.T) {

func TestChannelV11(t *testing.T) {
op := NewChannelProvider(map[string]*cb.Capability{
ChannelV1_1: &cb.Capability{},
ChannelV1_1: {},
})
assert.NoError(t, op.Supported())
assert.True(t, op.MSPVersion() == msp.MSPv1_1)
Expand Down
2 changes: 1 addition & 1 deletion common/capabilities/orderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestOrdererV10(t *testing.T) {

func TestOrdererV11(t *testing.T) {
op := NewOrdererProvider(map[string]*cb.Capability{
OrdererV1_1: &cb.Capability{},
OrdererV1_1: {},
})
assert.NoError(t, op.Supported())
assert.True(t, op.SetChannelModPolicyDuringCreate())
Expand Down
20 changes: 10 additions & 10 deletions common/channelconfig/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ func TestPrevalidation(t *testing.T) {
err := preValidate(&cb.Config{
ChannelGroup: &cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
OrdererGroupKey: &cb.ConfigGroup{},
OrdererGroupKey: {},
},
Values: map[string]*cb.ConfigValue{
CapabilitiesKey: &cb.ConfigValue{},
CapabilitiesKey: {},
},
},
})
Expand All @@ -237,12 +237,12 @@ func TestPrevalidation(t *testing.T) {
err := preValidate(&cb.Config{
ChannelGroup: &cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
ApplicationGroupKey: &cb.ConfigGroup{
ApplicationGroupKey: {
Values: map[string]*cb.ConfigValue{
CapabilitiesKey: &cb.ConfigValue{},
CapabilitiesKey: {},
},
},
OrdererGroupKey: &cb.ConfigGroup{},
OrdererGroupKey: {},
},
},
})
Expand All @@ -255,19 +255,19 @@ func TestPrevalidation(t *testing.T) {
err := preValidate(&cb.Config{
ChannelGroup: &cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
ApplicationGroupKey: &cb.ConfigGroup{
ApplicationGroupKey: {
Values: map[string]*cb.ConfigValue{
CapabilitiesKey: &cb.ConfigValue{},
CapabilitiesKey: {},
},
},
OrdererGroupKey: &cb.ConfigGroup{
OrdererGroupKey: {
Values: map[string]*cb.ConfigValue{
CapabilitiesKey: &cb.ConfigValue{},
CapabilitiesKey: {},
},
},
},
Values: map[string]*cb.ConfigValue{
CapabilitiesKey: &cb.ConfigValue{},
CapabilitiesKey: {},
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion common/channelconfig/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ func TestUtilsBasic(t *testing.T) {
basicTest(t, KafkaBrokersValue([]string{"foo:1", "bar:2"}))
basicTest(t, MSPValue(&mspprotos.MSPConfig{}))
basicTest(t, CapabilitiesValue(map[string]bool{"foo": true, "bar": false}))
basicTest(t, AnchorPeersValue([]*pb.AnchorPeer{&pb.AnchorPeer{}, &pb.AnchorPeer{}}))
basicTest(t, AnchorPeersValue([]*pb.AnchorPeer{{}, {}}))
basicTest(t, ChannelCreationPolicyValue(&cb.Policy{}))
}
2 changes: 1 addition & 1 deletion common/configtx/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestPolicyForItem(t *testing.T) {
pm: &mockpolicies.Manager{
Policy: rootPolicy,
SubManagersMap: map[string]*mockpolicies.Manager{
"foo": &mockpolicies.Manager{
"foo": {
Policy: fooPolicy,
},
},
Expand Down
6 changes: 3 additions & 3 deletions common/resourcesconfig/apis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const (

var sampleAPIsGroup = &cb.ConfigGroup{
Values: map[string]*cb.ConfigValue{
sampleAPI1Name: &cb.ConfigValue{
sampleAPI1Name: {
Value: utils.MarshalOrPanic(&pb.APIResource{
PolicyRef: sampleAPI1PolicyRef,
}),
},
sampleAPI2Name: &cb.ConfigValue{
sampleAPI2Name: {
Value: utils.MarshalOrPanic(&pb.APIResource{
PolicyRef: sampleAPI2PolicyRef,
}),
Expand All @@ -57,7 +57,7 @@ func TestGreenAPIsPath(t *testing.T) {
func TestBadSubgroupsAPIsGroup(t *testing.T) {
ccg, err := newAPIsGroup(&cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
"subGroup": &cb.ConfigGroup{},
"subGroup": {},
},
})

Expand Down
2 changes: 1 addition & 1 deletion common/resourcesconfig/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestBundleFailure(t *testing.T) {
Config: &cb.Config{
ChannelGroup: &cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
"badsubgroup": &cb.ConfigGroup{},
"badsubgroup": {},
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions common/resourcesconfig/chaincode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ var (

var sampleChaincodeGroup = &cb.ConfigGroup{
Values: map[string]*cb.ConfigValue{
"ChaincodeIdentifier": &cb.ConfigValue{
"ChaincodeIdentifier": {
Value: utils.MarshalOrPanic(&pb.ChaincodeIdentifier{
Version: sampleChaincodeVersion,
Hash: sampleChaincodeHash,
}),
},
"ChaincodeValidation": &cb.ConfigValue{
"ChaincodeValidation": {
Value: utils.MarshalOrPanic(&pb.ChaincodeValidation{
Name: sampleChaincodeValidationName,
Argument: sampleChaincodeValidationArg,
}),
},
"ChaincodeEndorsement": &cb.ConfigValue{
"ChaincodeEndorsement": {
Value: utils.MarshalOrPanic(&pb.ChaincodeEndorsement{
Name: sampleChaincodeEndorsementName,
}),
Expand All @@ -68,7 +68,7 @@ func TestGreenChaincodePath(t *testing.T) {
func TestBadSubgroupsChaincodeGroup(t *testing.T) {
ccg, err := newChaincodeGroup("bar", &cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
"subGroup": &cb.ConfigGroup{},
"subGroup": {},
},
})

Expand Down
2 changes: 1 addition & 1 deletion common/resourcesconfig/chaincodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestGreenChaincodesPath(t *testing.T) {
func TestChaincodesWithValues(t *testing.T) {
ccsg, err := newChaincodesGroup(&cb.ConfigGroup{
Values: map[string]*cb.ConfigValue{
"foo": &cb.ConfigValue{},
"foo": {},
},
})

Expand Down
6 changes: 3 additions & 3 deletions common/resourcesconfig/peerpolicies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
"bar": dummyPolicy,
},
Groups: map[string]*cb.ConfigGroup{
"subGroup": &cb.ConfigGroup{
"subGroup": {
Policies: map[string]*cb.ConfigPolicy{
"other": dummyPolicy,
},
Expand All @@ -48,9 +48,9 @@ func TestGreenPeerPoliciesPath(t *testing.T) {
func TestPeerPolicieesWithValues(t *testing.T) {
_, err := newPeerPoliciesGroup(&cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
"bar": &cb.ConfigGroup{
"bar": {
Values: map[string]*cb.ConfigValue{
"foo": &cb.ConfigValue{},
"foo": {},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions common/resourcesconfig/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestBadPathResourceGroup(t *testing.T) {
t.Run("BadValues", func(t *testing.T) {
rg, err := newResourceGroup(&cb.ConfigGroup{
Values: map[string]*cb.ConfigValue{
"foo": &cb.ConfigValue{},
"foo": {},
},
})
assert.Nil(t, rg)
Expand All @@ -48,7 +48,7 @@ func TestBadPathResourceGroup(t *testing.T) {
t.Run("BadSubGroup", func(t *testing.T) {
rg, err := newResourceGroup(&cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
"bar": &cb.ConfigGroup{},
"bar": {},
},
})
assert.Nil(t, rg)
Expand Down
8 changes: 4 additions & 4 deletions common/tools/configtxgen/encoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ func NewChannelCreateConfigUpdate(channelID string, orderingSystemChannelGroup *
Type: int32(cb.ConfigType_RESOURCE),
ChannelGroup: &cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
resourcesconfig.ChaincodesGroupKey: &cb.ConfigGroup{
resourcesconfig.ChaincodesGroupKey: {
ModPolicy: defaultModPolicy,
},
resourcesconfig.PeerPoliciesGroupKey: &cb.ConfigGroup{
resourcesconfig.PeerPoliciesGroupKey: {
ModPolicy: defaultModPolicy,
},
resourcesconfig.APIsGroupKey: &cb.ConfigGroup{
resourcesconfig.APIsGroupKey: {
ModPolicy: defaultModPolicy,
},
},
Expand Down Expand Up @@ -415,7 +415,7 @@ func MakeChannelCreationTransaction(channelID string, signer crypto.LocalSigner,
return nil, errors.Wrap(err, "creating signature header failed")
}

newConfigUpdateEnv.Signatures = []*cb.ConfigSignature{&cb.ConfigSignature{
newConfigUpdateEnv.Signatures = []*cb.ConfigSignature{{
SignatureHeader: utils.MarshalOrPanic(sigHeader),
}}

Expand Down
6 changes: 3 additions & 3 deletions common/tools/configtxgen/encoder/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,23 @@ func TestNewChannelGroup(t *testing.T) {

t.Run("Add application unknown MSP", func(t *testing.T) {
config := genesisconfig.Load(genesisconfig.SampleDevModeSoloProfile)
config.Application = &genesisconfig.Application{Organizations: []*genesisconfig.Organization{&genesisconfig.Organization{Name: "FakeOrg"}}}
config.Application = &genesisconfig.Application{Organizations: []*genesisconfig.Organization{{Name: "FakeOrg"}}}
group, err := NewChannelGroup(config)
assert.Error(t, err)
assert.Nil(t, group)
})

t.Run("Add consortiums unknown MSP", func(t *testing.T) {
config := genesisconfig.Load(genesisconfig.SampleDevModeSoloProfile)
config.Consortiums["fakeorg"] = &genesisconfig.Consortium{Organizations: []*genesisconfig.Organization{&genesisconfig.Organization{Name: "FakeOrg"}}}
config.Consortiums["fakeorg"] = &genesisconfig.Consortium{Organizations: []*genesisconfig.Organization{{Name: "FakeOrg"}}}
group, err := NewChannelGroup(config)
assert.Error(t, err)
assert.Nil(t, group)
})

t.Run("Add orderer unknown MSP", func(t *testing.T) {
config := genesisconfig.Load(genesisconfig.SampleDevModeSoloProfile)
config.Orderer = &genesisconfig.Orderer{Organizations: []*genesisconfig.Organization{&genesisconfig.Organization{Name: "FakeOrg"}}}
config.Orderer = &genesisconfig.Orderer{Organizations: []*genesisconfig.Organization{{Name: "FakeOrg"}}}
group, err := NewChannelGroup(config)
assert.Error(t, err)
assert.Nil(t, group)
Expand Down
18 changes: 9 additions & 9 deletions common/tools/protolator/blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ func TestResourcesConfig(t *testing.T) {
Type: int32(cb.ConfigType_RESOURCE),
ChannelGroup: &cb.ConfigGroup{
Groups: map[string]*cb.ConfigGroup{
"Chaincodes": &cb.ConfigGroup{
"Chaincodes": {
Groups: map[string]*cb.ConfigGroup{
"cc1": &cb.ConfigGroup{
"cc1": {
Values: map[string]*cb.ConfigValue{
"ChaincodeIdentifier": &cb.ConfigValue{
"ChaincodeIdentifier": {
Value: utils.MarshalOrPanic(&pb.ChaincodeIdentifier{
Hash: []byte("somehashvalue"),
Version: "aversionstring",
}),
},
"ChaincodeValidation": &cb.ConfigValue{
"ChaincodeValidation": {
Value: utils.MarshalOrPanic(
&pb.ChaincodeValidation{
Name: "vscc",
Expand All @@ -98,7 +98,7 @@ func TestResourcesConfig(t *testing.T) {
}),
}),
},
"ChaincodeEndorsement": &cb.ConfigValue{
"ChaincodeEndorsement": {
Value: utils.MarshalOrPanic(&pb.ChaincodeEndorsement{
Name: "escc",
}),
Expand All @@ -107,17 +107,17 @@ func TestResourcesConfig(t *testing.T) {
},
},
},
"APIs": &cb.ConfigGroup{
"APIs": {
Values: map[string]*cb.ConfigValue{
"Test": &cb.ConfigValue{
"Test": {
Value: utils.MarshalOrPanic(&pb.APIResource{PolicyRef: "Foo"}),
},
"Another": &cb.ConfigValue{
"Another": {
Value: utils.MarshalOrPanic(&pb.APIResource{PolicyRef: "Bar"}),
},
},
},
"PeerPolicies": &cb.ConfigGroup{},
"PeerPolicies": {},
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions core/handlers/library/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

func TestInitRegistry(t *testing.T) {
r := InitRegistry(Config{
AuthFilters: []*HandlerConfig{&HandlerConfig{Name: "DefaultAuth"}},
Decorators: []*HandlerConfig{&HandlerConfig{Name: "DefaultDecorator"}},
AuthFilters: []*HandlerConfig{{Name: "DefaultAuth"}},
Decorators: []*HandlerConfig{{Name: "DefaultDecorator"}},
})
assert.NotNil(t, r)
authHandlers := r.Lookup(Auth)
Expand Down
2 changes: 1 addition & 1 deletion core/ledger/cceventmgmt/mgmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestLSCCListener(t *testing.T) {
sampleChaincodeDataBytes, err := proto.Marshal(sampleChaincodeData)
assert.NoError(t, err, "")
lsccStateListener.HandleStateUpdates(channelName, []*kvrwset.KVWrite{
&kvrwset.KVWrite{Key: cc1Def.Name, Value: sampleChaincodeDataBytes},
{Key: cc1Def.Name, Value: sampleChaincodeDataBytes},
})
assert.Contains(t, handler1.eventsRecieved, &mockEvent{cc1Def, cc1DBArtifactsTar})
}
Expand Down
2 changes: 1 addition & 1 deletion core/ledger/kvledger/state_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestStateListener(t *testing.T) {
assert.NoError(t, lgr.CommitWithPvtData(&ledger.BlockAndPvtData{Block: blk3}))
assert.Equal(t, channelid, mockListener.channelName)
assert.Equal(t, []*kvrwset.KVWrite{
&kvrwset.KVWrite{Key: "key4", Value: []byte("value4")},
{Key: "key4", Value: []byte("value4")},
}, mockListener.kvWrites)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ func (vdb *VersionedDB) LoadCommittedVersions(keys []*statedb.CompositeKey) erro
// Call the batch retrieve if there is one or more keys to retrieve
if len(missingKeys) > 0 {

for namespace, _ := range missingKeys {
for namespace := range missingKeys {
// TODO: For each namespace, we need to parallely load missing keys into the cache
// The following codes need be moved to goroutine and introduce RWlock for cache.

Expand Down
4 changes: 2 additions & 2 deletions core/ledger/kvledger/txmgmt/validator/valimpl/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestPreprocessProtoBlock(t *testing.T) {
assert.NoError(t, err)
// bad envelope
gb = testutil.ConstructTestBlock(t, 11, 1, 1)
gb.Data = &common.BlockData{Data: [][]byte{[]byte{123}}}
gb.Data = &common.BlockData{Data: [][]byte{{123}}}
gb.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] =
lutils.NewTxValidationFlags(len(gb.Data.Data))
_, err = preprocessProtoBlock(nil, gb, false)
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestPreprocessProtoBlock(t *testing.T) {
var blockNum uint64 = 15
txid := "testtxid1234"
gb = testutil.ConstructBlockWithTxid(t, blockNum, []byte{123},
[][]byte{[]byte{123}}, []string{txid}, false)
[][]byte{{123}}, []string{txid}, false)
flags = lutils.NewTxValidationFlags(len(gb.Data.Data))
flags.SetFlag(0, peer.TxValidationCode_BAD_HEADER_EXTENSION)
gb.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER] = flags
Expand Down
4 changes: 2 additions & 2 deletions core/peer/configtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (h *testHelper) sampleResourceConfig(version uint64, entries ...string) *co
ChannelGroup: &common.ConfigGroup{
Version: version,
Groups: map[string]*common.ConfigGroup{
resourcesconfig.ChaincodesGroupKey: &common.ConfigGroup{
resourcesconfig.ChaincodesGroupKey: {
Groups: ccGroups,
ModPolicy: modPolicy,
},
Expand Down Expand Up @@ -295,7 +295,7 @@ func (h *testHelper) computeDeltaResConfTx(t *testing.T, chainid string, source,
sigHeader, err := localmsp.NewSigner().NewSignatureHeader()
assert.NoError(t, err)

confUpdateEnv.Signatures = []*common.ConfigSignature{&common.ConfigSignature{
confUpdateEnv.Signatures = []*common.ConfigSignature{{
SignatureHeader: utils.MarshalOrPanic(sigHeader)}}

sigs, err := localmsp.NewSigner().Sign(util.ConcatenateBytes(confUpdateEnv.Signatures[0].SignatureHeader, confUpdateEnv.ConfigUpdate))
Expand Down
Loading

0 comments on commit e14f208

Please sign in to comment.