Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: gofumpt everything #15518

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/v2/autocli/app.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package autocli

import (
"fmt"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"fmt"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
Expand Down
6 changes: 3 additions & 3 deletions client/v2/autocli/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package autocli
import (
"bytes"
"context"
"net"
"testing"

reflectionv2alpha1 "cosmossdk.io/api/cosmos/base/reflection/v2alpha1"
"cosmossdk.io/client/v2/autocli/flag"
"cosmossdk.io/client/v2/internal/testpb"
Expand All @@ -12,8 +15,6 @@ import (
"gotest.tools/v3/assert"

"google.golang.org/grpc/credentials/insecure"
"net"
"testing"
)

func testExecCommon(t *testing.T, buildModuleCommand func(string, *Builder) (*cobra.Command, error), args ...string) *testClientConn {
Expand Down Expand Up @@ -46,7 +47,6 @@ func testExecCommon(t *testing.T, buildModuleCommand func(string, *Builder) (*co
}
b := &Builder{
Builder: flag.Builder{

GetClientConn: func() (grpc.ClientConnInterface, error) {
return conn, nil
}},
Expand Down
2 changes: 1 addition & 1 deletion client/v2/autocli/flag/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flag

import (
"context"

reflectionv2alpha1 "cosmossdk.io/api/cosmos/base/reflection/v2alpha1"
"github.com/cosmos/cosmos-sdk/types"
"google.golang.org/protobuf/reflect/protoreflect"
Expand All @@ -10,7 +11,6 @@ import (
type addressStringType struct{}

func (a addressStringType) NewValue(ctx context.Context, b *Builder) Value {

if b.AddressPrefix == "" {
conn, err := b.GetClientConn()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion client/v2/autocli/flag/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func (b *Builder) init() {
b.scalarFlagTypes = map[string]Type{}
b.scalarFlagTypes["cosmos.AddressString"] = addressStringType{}
}

}

func (b *Builder) DefineMessageFlagType(messageName protoreflect.FullName, flagType Type) {
Expand Down
1 change: 0 additions & 1 deletion client/v2/autocli/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autoc
// validate that methods exist
if m := methods.ByName(methodName); m == nil {
return fmt.Errorf("rpc method %q not found for service %q", methodName, service.FullName())

}
rpcOptMap[methodName] = option

Expand Down
7 changes: 2 additions & 5 deletions client/v2/autocli/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package autocli

import (
"fmt"
"google.golang.org/protobuf/encoding/protojson"
"strings"
"testing"

"google.golang.org/protobuf/encoding/protojson"

"gotest.tools/v3/golden"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
Expand Down Expand Up @@ -127,7 +128,6 @@ func TestMsgOutputFormat(t *testing.T) {
)

assert.Assert(t, strings.Contains(conn.out.String(), "positional1: 5"))

}

func TestMsgOptionsError(t *testing.T) {
Expand All @@ -145,7 +145,6 @@ func TestMsgOptionsError(t *testing.T) {
"--u64", "abc",
)
assert.Assert(t, strings.Contains(conn.errorOut.String(), "invalid argument "))

}

func TestDeprecatedMsg(t *testing.T) {
Expand Down Expand Up @@ -325,7 +324,6 @@ func TestNotFoundErrorsMsg(t *testing.T) {
},
})
assert.ErrorContains(t, err, "can't find field un-existent-flag")

}

func TestEnhanceMessageCommand(t *testing.T) {
Expand Down Expand Up @@ -368,7 +366,6 @@ func TestEnhanceMessageCommand(t *testing.T) {
customCommands = map[string]*cobra.Command{}
err = b.enhanceCommandCommon(cmd, options, customCommands, enhanceMsg)
assert.NilError(t, err)

}

type testMessageServer struct {
Expand Down
2 changes: 0 additions & 2 deletions client/v2/autocli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
)

var buildModuleQueryCommand = func(moduleName string, b *Builder) (*cobra.Command, error) {

cmd := topLevelCmd(moduleName, fmt.Sprintf("Querying commands for the %s module", moduleName))

err := b.AddQueryServiceCommands(cmd, testCmdDesc)
Expand Down Expand Up @@ -194,7 +193,6 @@ func TestOutputFormat(t *testing.T) {
)
fmt.Println(conn.out.String())
assert.Assert(t, strings.Contains(conn.out.String(), " positional1: 1"))

}

func TestHelp(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion client/v2/autocli/util.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package autocli

import (
"google.golang.org/protobuf/reflect/protoreflect"
"strings"

"google.golang.org/protobuf/reflect/protoreflect"

"cosmossdk.io/client/v2/internal/strcase"
"github.com/spf13/cobra"
)
Expand Down
3 changes: 2 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ func NewSimApp(
// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
genesisModuleOrder := []string{authtypes.ModuleName, banktypes.ModuleName,
genesisModuleOrder := []string{
authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
Expand Down
3 changes: 2 additions & 1 deletion simapp/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package simapp

import (
"fmt"
"github.com/spf13/viper"
"os"
"testing"

"github.com/spf13/viper"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
flag "github.com/spf13/pflag"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion store/streaming/abci/examples/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (a *FilePlugin) writeToFile(file string, data []byte) error {
}

filename := fmt.Sprintf("%s/%s.txt", home, file)
f, err := os.OpenFile(filepath.Clean(filename), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
f, err := os.OpenFile(filepath.Clean(filename), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions store/streaming/streaming_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func TestPluginTestSuite(t *testing.T) {

func (s *PluginTestSuite) TestABCIGRPCPlugin() {
s.T().Run("Should successfully load streaming", func(t *testing.T) {

abciListeners := s.loggerCtx.StreamingManager().ABCIListeners
for _, abciListener := range abciListeners {
for i := range [50]int{} {
Expand Down Expand Up @@ -148,8 +147,10 @@ func (s *PluginTestSuite) updateHeight(n int64) {
s.loggerCtx = NewMockContext(header, s.loggerCtx.Logger(), s.loggerCtx.StreamingManager())
}

var _ context.Context = MockContext{}
var _ storetypes.Context = MockContext{}
var (
_ context.Context = MockContext{}
_ storetypes.Context = MockContext{}
)

type MockContext struct {
baseCtx context.Context
Expand Down
27 changes: 18 additions & 9 deletions tests/integration/aminojson/aminojson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,11 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
"auth/params": {gogo: &authtypes.Params{TxSigLimit: 10}, pulsar: &authapi.Params{TxSigLimit: 10}},
"auth/module_account": {
gogo: &authtypes.ModuleAccount{
BaseAccount: authtypes.NewBaseAccountWithAddress(addr1), Permissions: []string{}},
BaseAccount: authtypes.NewBaseAccountWithAddress(addr1), Permissions: []string{},
},
pulsar: &authapi.ModuleAccount{
BaseAccount: &authapi.BaseAccount{Address: addr1.String()}, Permissions: []string{}},
BaseAccount: &authapi.BaseAccount{Address: addr1.String()}, Permissions: []string{},
},
roundTripUnequal: true,
},
"auth/base_account": {
Expand All @@ -426,9 +428,11 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
},
"authz/msg_grant": {
gogo: &authztypes.MsgGrant{
Grant: authztypes.Grant{Expiration: &now, Authorization: genericAuth}},
Grant: authztypes.Grant{Expiration: &now, Authorization: genericAuth},
},
pulsar: &authzapi.MsgGrant{
Grant: &authzapi.Grant{Expiration: timestamppb.New(now), Authorization: genericAuthPulsar}},
Grant: &authzapi.Grant{Expiration: timestamppb.New(now), Authorization: genericAuthPulsar},
},
},
"authz/msg_update_params": {
gogo: &authtypes.MsgUpdateParams{Params: authtypes.Params{TxSigLimit: 10}},
Expand Down Expand Up @@ -482,12 +486,14 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
"consensus/evidence_params/big_duration": {
gogo: &gov_v1beta1_types.VotingParams{VotingPeriod: time.Duration(rapidproto.MaxDurationSeconds*1e9) + 999999999},
pulsar: &gov_v1beta1_api.VotingParams{VotingPeriod: &durationpb.Duration{
Seconds: rapidproto.MaxDurationSeconds, Nanos: 999999999}},
Seconds: rapidproto.MaxDurationSeconds, Nanos: 999999999,
}},
},
"consensus/evidence_params/too_big_duration": {
gogo: &gov_v1beta1_types.VotingParams{VotingPeriod: time.Duration(rapidproto.MaxDurationSeconds*1e9) + 999999999},
pulsar: &gov_v1beta1_api.VotingParams{VotingPeriod: &durationpb.Duration{
Seconds: rapidproto.MaxDurationSeconds + 1, Nanos: 999999999}},
Seconds: rapidproto.MaxDurationSeconds + 1, Nanos: 999999999,
}},
pulsarMarshalFails: true,
},
// amino.dont_omitempty + empty/nil lists produce some surprising results
Expand Down Expand Up @@ -521,7 +527,8 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
"slashing/params/dec": {
gogo: &slashingtypes.Params{
DowntimeJailDuration: 1e9 + 7,
MinSignedPerWindow: types.NewDec(10)},
MinSignedPerWindow: types.NewDec(10),
},
pulsar: &slashingapi.Params{
DowntimeJailDuration: &durationpb.Duration{Seconds: 1, Nanos: 7},
MinSignedPerWindow: dec10bz,
Expand All @@ -548,11 +555,13 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
gogo: &stakingtypes.StakeAuthorization{
Validators: &stakingtypes.StakeAuthorization_AllowList{
AllowList: &stakingtypes.StakeAuthorization_Validators{Address: []string{"foo"}},
}},
},
},
pulsar: &stakingapi.StakeAuthorization{
Validators: &stakingapi.StakeAuthorization_AllowList{
AllowList: &stakingapi.StakeAuthorization_Validators{Address: []string{"foo"}},
}},
},
},
},
"vesting/base_account_empty": {
gogo: &vestingtypes.BaseVestingAccount{BaseAccount: &authtypes.BaseAccount{}},
Expand Down
1 change: 0 additions & 1 deletion tests/integration/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ func TestInputOutputCoins(t *testing.T) {
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, balances))

insufficientInput := types.Input{

Address: addr1.String(),
Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100)),
}
Expand Down
3 changes: 2 additions & 1 deletion tools/hubl/internal/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func RemoteCommand(config *Config, configDir string) ([]*cobra.Command, error) {
FileResolver: chainInfo.ProtoFiles,
GetClientConn: func() (grpc.ClientConnInterface, error) {
return chainInfo.OpenClient()
}},
},
},
GetClientConn: func(command *cobra.Command) (grpc.ClientConnInterface, error) {
return chainInfo.OpenClient()
},
Expand Down
1 change: 0 additions & 1 deletion x/tx/signing/aminojson/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func keyFieldEncoder(_ *Encoder, msg protoreflect.Message, w io.Writer) error {

_, err := fmt.Fprintf(w, `"%s"`, base64.StdEncoding.EncodeToString(bz))
return err

}

type moduleAccountPretty struct {
Expand Down
1 change: 0 additions & 1 deletion x/tx/signing/aminojson/json_marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func marshalLegacy(msg proto.Message) ([]byte, error) {
}

func TestAminoJSON_EdgeCases(t *testing.T) {

cdc := amino.NewCodec()
cdc.RegisterConcrete(&testpb.ABitOfEverything{}, "ABitOfEverything", nil)
cdc.RegisterConcrete(&testpb.NestedMessage{}, "NestedMessage", nil)
Expand Down
3 changes: 2 additions & 1 deletion x/tx/signing/aminojson/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package aminojson

import (
"fmt"
"google.golang.org/protobuf/reflect/protoreflect"
"io"
"math"
"time"

"google.golang.org/protobuf/reflect/protoreflect"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions x/tx/signing/direct_aux/direct_aux.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (h SignModeHandler) getFirstSigner(txData signing.TxData) (string, error) {

// GetSignBytes implements signing.SignModeHandler.GetSignBytes.
func (h SignModeHandler) GetSignBytes(
_ context.Context, signerData signing.SignerData, txData signing.TxData) ([]byte, error) {

_ context.Context, signerData signing.SignerData, txData signing.TxData,
) ([]byte, error) {
feePayer := txData.AuthInfo.Fee.Payer
if feePayer == "" {
fp, err := h.getFirstSigner(txData)
Expand Down
1 change: 0 additions & 1 deletion x/tx/signing/get_signers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func TestGetSigners(t *testing.T) {
require.NoError(t, err)
}
require.Equal(t, test.want, signers)

})
}
}