style: general linting (#15756)
This commit is contained in:
parent
2b3fee5a29
commit
00e1f85eca
@ -162,7 +162,7 @@ func (k keeper) addBalance(ctx context.Context, acct, denom string, amount uint6
|
||||
Amount: amount,
|
||||
}
|
||||
} else {
|
||||
balance.Amount = balance.Amount + amount
|
||||
balance.Amount += amount
|
||||
}
|
||||
|
||||
return k.store.BalanceTable().Save(ctx, balance)
|
||||
@ -179,7 +179,7 @@ func (k keeper) safeSubBalance(ctx context.Context, acct, denom string, amount u
|
||||
return fmt.Errorf("insufficient funds")
|
||||
}
|
||||
|
||||
balance.Amount = balance.Amount - amount
|
||||
balance.Amount -= amount
|
||||
|
||||
if balance.Amount == 0 {
|
||||
return balanceStore.Delete(ctx, balance)
|
||||
|
||||
@ -12,6 +12,7 @@ func IsNotFound(err error) bool {
|
||||
return errors.IsOf(err, NotFound)
|
||||
}
|
||||
|
||||
// nolint: revive // avoid break API
|
||||
var (
|
||||
InvalidTableId = errors.New(codespace, 1, "invalid or missing table or single id, need a non-zero value")
|
||||
MissingPrimaryKey = errors.New(codespace, 2, "table is missing primary key")
|
||||
|
||||
@ -20,6 +20,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const memdb = "memdb"
|
||||
|
||||
// A single comet server in a network runs an RPC server successfully.
|
||||
func TestCometRPC_SingleRPCServer(t *testing.T) {
|
||||
const nVals = 2
|
||||
@ -55,7 +57,7 @@ func TestCometRPC_SingleRPCServer(t *testing.T) {
|
||||
)
|
||||
|
||||
cfg := cmtcfg.DefaultConfig()
|
||||
cfg.BaseConfig.DBBackend = "memdb"
|
||||
cfg.BaseConfig.DBBackend = memdb
|
||||
|
||||
cs := testnet.NewCometStarter(
|
||||
app,
|
||||
@ -146,7 +148,7 @@ func TestCometRPC_MultipleRPCError(t *testing.T) {
|
||||
)
|
||||
|
||||
cfg := cmtcfg.DefaultConfig()
|
||||
cfg.BaseConfig.DBBackend = "memdb"
|
||||
cfg.BaseConfig.DBBackend = memdb
|
||||
|
||||
return testnet.NewCometStarter(
|
||||
app,
|
||||
|
||||
@ -47,7 +47,7 @@ type CometStarter struct {
|
||||
// NewCometStarter accepts a minimal set of arguments to start comet with an ABCI app.
|
||||
// For further configuration, chain other CometStarter methods before calling Start:
|
||||
//
|
||||
// NewCometStarter(...).Logger(...).Start()
|
||||
// NewCometStarter(...).Logger(...).Start()
|
||||
func NewCometStarter(
|
||||
app abcitypes.Application,
|
||||
cfg *cmtcfg.Config,
|
||||
@ -169,7 +169,6 @@ func (s *CometStarter) Start() (n *node.Node, err error) {
|
||||
node.DefaultMetricsProvider(s.cfg.Instrumentation),
|
||||
servercmtlog.CometZeroLogWrapper{Logger: s.logger},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create comet node: %w", err)
|
||||
}
|
||||
@ -207,7 +206,7 @@ func (s *CometStarter) initDisk() (cmttypes.PrivValidator, *p2p.NodeKey, error)
|
||||
fpv := privval.NewFilePV(s.valPrivKey, s.cfg.PrivValidatorKeyFile(), s.cfg.PrivValidatorStateFile())
|
||||
fpv.Save()
|
||||
|
||||
if err := os.WriteFile(s.cfg.GenesisFile(), s.genesis, 0600); err != nil {
|
||||
if err := os.WriteFile(s.cfg.GenesisFile(), s.genesis, 0o600); err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to write genesis file: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
@ -110,18 +110,16 @@ func (b *GenesisBuilder) GenTx(privVal secp256k1.PrivKey, val cmttypes.GenesisVa
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress)
|
||||
_, err = sdk.ValAddressFromBech32(msg.ValidatorAddress)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
msg.DelegatorAddress = sdk.AccAddress(valAddr).String()
|
||||
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
txConf := authtx.NewTxConfig(b.codec, tx.DefaultSignModes)
|
||||
txConf := authtx.NewTxConfig(b.codec, authtx.DefaultSignModes)
|
||||
|
||||
txb := txConf.NewTxBuilder()
|
||||
if err := txb.SetMsgs(msg); err != nil {
|
||||
@ -456,13 +454,13 @@ func (b *GenesisBuilder) DefaultDistribution() *GenesisBuilder {
|
||||
// JSON returns the map of the genesis after applying some final transformations.
|
||||
func (b *GenesisBuilder) JSON() map[string]json.RawMessage {
|
||||
gentxGenesisState := genutiltypes.NewGenesisStateFromTx(
|
||||
authtx.NewTxConfig(b.codec, tx.DefaultSignModes).TxJSONEncoder(),
|
||||
authtx.NewTxConfig(b.codec, authtx.DefaultSignModes).TxJSONEncoder(),
|
||||
b.gentxs,
|
||||
)
|
||||
|
||||
if err := genutiltypes.ValidateGenesis(
|
||||
gentxGenesisState,
|
||||
authtx.NewTxConfig(b.codec, tx.DefaultSignModes).TxJSONDecoder(),
|
||||
authtx.NewTxConfig(b.codec, authtx.DefaultSignModes).TxJSONDecoder(),
|
||||
genutiltypes.DefaultMessageValidator,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -3,7 +3,6 @@ package testnet_test
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -83,7 +82,6 @@ func TestGenesisBuilder_ChainID(t *testing.T) {
|
||||
_, ok := m["chain_id"]
|
||||
require.False(t, ok)
|
||||
|
||||
m = gb.ChainID("my-chain").JSON()
|
||||
var id string
|
||||
require.NoError(
|
||||
t,
|
||||
@ -98,8 +96,6 @@ func TestGenesisBuilder_ChainID(t *testing.T) {
|
||||
// Use known keys and addresses to assert that correct validator and delegator keys
|
||||
// occur in the expected locations (i.e. we didn't mistakenly swap the keys anywhere).
|
||||
func TestGenesisBuilder_GentxAddresses(t *testing.T) {
|
||||
const chainID = "simapp-chain"
|
||||
|
||||
const valSecret0 = "val-secret-0"
|
||||
const valAddr0 = "3F3B076353767F046477A6E0982F808C24D1870A"
|
||||
const valPubKey0 = "ZhVhrOUHnUwYw/GlBSBrw/0X6A261gchCRYkAxGF2jk="
|
||||
@ -206,14 +202,6 @@ func TestGenesisBuilder_GentxAddresses(t *testing.T) {
|
||||
require.Equal(t, gentxs[0].Body.Messages[0].PubKey.Key, valPubKey0)
|
||||
require.Equal(t, gentxs[0].AuthInfo.SignerInfos[0].PublicKey.Key, delPubKey0)
|
||||
|
||||
// Delegator is derived from the secp256k1 key, not the ed25519 key.
|
||||
require.Equal(t, gentxs[0].Body.Messages[0].DelegatorAddress, delAccAddr0)
|
||||
|
||||
// The validator address must match the delegator address.
|
||||
_, parsedValAddr, err := bech32.DecodeAndConvert(gentxs[0].Body.Messages[0].DelegatorAddress)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, fmt.Sprintf("%X", parsedValAddr), delAddr0)
|
||||
|
||||
// The only base account in this genesis, matches the secp256k1 key.
|
||||
acct := g.AppState.Auth.Accounts[0]
|
||||
require.Equal(t, acct.Address, delAccAddr0)
|
||||
|
||||
@ -360,7 +360,8 @@ func (suite *TestSuite) TestExec() {
|
||||
Amount: sdk.NewCoins(sdk.NewInt64Coin("steak", 2)),
|
||||
FromAddress: "invalid_from_address",
|
||||
ToAddress: grantee.String(),
|
||||
}})
|
||||
},
|
||||
})
|
||||
},
|
||||
expErr: true,
|
||||
errMsg: "invalid from address",
|
||||
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
sdkmath "cosmossdk.io/math"
|
||||
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
|
||||
}
|
||||
|
||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module.
|
||||
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
||||
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
||||
if err := v1.RegisterQueryHandlerClient(context.Background(), mux, v1.NewQueryClient(clientCtx)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -96,8 +96,8 @@ func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux
|
||||
}
|
||||
|
||||
// GetTxCmd returns the root tx command for the gov module.
|
||||
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
legacyProposalCLIHandlers := getProposalCLIHandlers(a.legacyProposalHandlers)
|
||||
func (ab AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
legacyProposalCLIHandlers := getProposalCLIHandlers(ab.legacyProposalHandlers)
|
||||
|
||||
return cli.NewTxCmd(legacyProposalCLIHandlers)
|
||||
}
|
||||
@ -116,7 +116,7 @@ func (ab AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
// RegisterInterfaces implements InterfaceModule.RegisterInterfaces
|
||||
func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
v1.RegisterInterfaces(registry)
|
||||
v1beta1.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user