style: gofumpt everything (#15518)

This commit is contained in:
Facundo Medica 2023-03-22 17:20:46 -03:00 committed by GitHub
parent 4db99fc1a5
commit 370acbb659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 44 additions and 38 deletions

View File

@ -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"

View File

@ -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"
@ -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 {
@ -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
}},

View File

@ -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"
@ -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 {

View File

@ -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) {

View File

@ -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

View File

@ -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"
@ -127,7 +128,6 @@ func TestMsgOutputFormat(t *testing.T) {
)
assert.Assert(t, strings.Contains(conn.out.String(), "positional1: 5"))
}
func TestMsgOptionsError(t *testing.T) {
@ -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) {
@ -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) {
@ -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 {

View File

@ -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)
@ -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) {

View File

@ -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"
)

View File

@ -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,

View File

@ -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"

View File

@ -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
}

View File

@ -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{} {
@ -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

View File

@ -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": {
@ -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}},
@ -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
@ -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,
@ -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{}},

View File

@ -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)),
}

View File

@ -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()
},

View File

@ -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 {

View File

@ -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)

View File

@ -2,10 +2,11 @@ package aminojson
import (
"fmt"
"google.golang.org/protobuf/reflect/protoreflect"
"io"
"math"
"time"
"google.golang.org/protobuf/reflect/protoreflect"
)
const (

View File

@ -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)

View File

@ -108,7 +108,6 @@ func TestGetSigners(t *testing.T) {
require.NoError(t, err)
}
require.Equal(t, test.want, signers)
})
}
}