Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Jul 1, 2024
1 parent aafeaec commit d636396
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 88 deletions.
14 changes: 7 additions & 7 deletions e2e/farm/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ func (s *QueryTestSuite) setup() {
clientCtx := val.ClientCtx

from := val.Address
symbol := "kitty"
name := "Kitty Token"
minUnit := "kitty"
scale := uint32(0)
initialSupply := uint64(100000000)
maxSupply := uint64(200000000)
mintable := true
const symbol = "kitty"
const name = "Kitty Token"
const minUnit = "kitty"
const scale = uint32(0)
const initialSupply = uint64(100000000)
const maxSupply = uint64(200000000)
const mintable = true

// issue token
msgIssueToken := &tokentypes.MsgIssueToken{
Expand Down
33 changes: 16 additions & 17 deletions e2e/nft/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,32 @@ import (
nfttypes "mods.irisnet.org/modules/nft/types"
)

const (
tokenName = "Kitty Token"
uri = "uri"
uriHash = "uriHash"
description = "description"
data = "{\"key1\":\"value1\",\"key2\":\"value2\"}"
tokenID = "kitty"
// owner := "owner"
denomName = "name"
denomID = "denom"
schema = "schema"
symbol = "symbol"
mintRestricted = true
updateRestricted = false
)

// QueryTestSuite is a suite of end-to-end tests for the nft module
type QueryTestSuite struct {
e2e.TestSuite
}

// TestQueryCmd tests all query command in the nft module
func (s *QueryTestSuite) TestQueryCmd() {
// s.SetupSuite()

val := s.Network.Validators[0]
clientCtx := val.ClientCtx
// ---------------------------------------------------------------------------

from := val.Address
tokenName := "Kitty Token"
uri := "uri"
uriHash := "uriHash"
description := "description"
data := "{\"key1\":\"value1\",\"key2\":\"value2\"}"
tokenID := "kitty"
// owner := "owner"
denomName := "name"
denomID := "denom"
schema := "schema"
symbol := "symbol"
mintRestricted := true
updateRestricted := false
baseURL := val.APIAddress

//------test GetCmdIssueDenom()-------------
Expand Down
4 changes: 2 additions & 2 deletions e2e/random/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ func (s *QueryTestSuite) TestQueryCmd() {
s.Require().Len(qrrResp.Requests, 1)

// ------get service request-------------
requestHeight ++
requestHeight++
_, err = s.Network.WaitForHeightWithTimeout(
requestHeight,
time.Duration(int64(blockInterval+2)*int64(s.Network.TimeoutCommit)),
)
if err != nil {
s.Network.WaitForNBlock(2)
s.Require().NoError(s.Network.WaitForNBlock(2))
}

blockResult, err := val.RPCClient.BlockResults(context.Background(), &requestHeight)
Expand Down
2 changes: 1 addition & 1 deletion e2e/random/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (s *TxTestSuite) TestTxCmd() {
s.Require().Len(qrrResp.Requests, 1)

// ------get service request-------------
requestHeight ++
requestHeight++
_, err := s.WaitForHeightWithTimeout(
requestHeight,
time.Duration(int64(blockInterval+5)*int64(s.TimeoutCommit)),
Expand Down
12 changes: 6 additions & 6 deletions e2e/service/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func (s *QueryTestSuite) TestQueryCmd() {
s.Require().NoError(err)

reqServiceFee := fmt.Sprintf("50%s", serviceDenom)
reqInput := `{"header":{},"body":{}}`
respResult := `{"code":200,"message":""}`
respOutput := `{"header":{},"body":{}}`
const reqInput = `{"header":{},"body":{}}`
const respResult = `{"code":200,"message":""}`
const respOutput = `{"header":{},"body":{}}`
timeout := qos

expectedEarnedFees := fmt.Sprintf("48%s", serviceDenom)
Expand Down Expand Up @@ -307,11 +307,11 @@ func (s *QueryTestSuite) TestQueryCmd() {
var requests []servicetypes.CompactRequest
var requestsBz []byte
for _, attribute := range event.Attributes {
if string(attribute.Key) == servicetypes.AttributeKeyRequests {
if attribute.Key == servicetypes.AttributeKeyRequests {
requestsBz = []byte(attribute.Value)
}
if string(attribute.Key) == servicetypes.AttributeKeyRequestContextID &&
string(attribute.GetValue()) == requestContextId {
if attribute.Key == servicetypes.AttributeKeyRequestContextID &&
attribute.GetValue() == requestContextId {
found = true
}
}
Expand Down
9 changes: 0 additions & 9 deletions e2e/token/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ type QueryTestSuite struct {
func (s *QueryTestSuite) TestQueryCmd() {
val := s.Network.Validators[0]
clientCtx := val.ClientCtx
// ---------------------------------------------------------------------------

from := val.Address
symbol := "kitty"
name := "Kitty Token"
minUnit := "kitty"
scale := 0
initialSupply := int64(100000000)
maxSupply := int64(200000000)
mintable := true
baseURL := val.APIAddress

//------test GetCmdIssueToken()-------------
Expand Down
19 changes: 10 additions & 9 deletions e2e/token/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ import (
"mods.irisnet.org/simapp"
)

const (
symbol = "kitty"
name = "Kitty Token"
minUnit = "kitty"
scale = 0
initialSupply = int64(100000000)
maxSupply = int64(200000000)
mintable = true
)

// TxTestSuite is a suite of end-to-end tests for the nft module
type TxTestSuite struct {
e2e.TestSuite
Expand All @@ -23,16 +33,7 @@ type TxTestSuite struct {
func (s *TxTestSuite) TestTxCmd() {
val := s.Network.Validators[0]
clientCtx := val.ClientCtx
// ---------------------------------------------------------------------------

from := val.Address
symbol := "kitty"
name := "Kitty Token"
minUnit := "kitty"
scale := 0
initialSupply := int64(100000000)
maxSupply := int64(200000000)
mintable := true

//------test GetCmdIssueToken()-------------
args := []string{
Expand Down
3 changes: 2 additions & 1 deletion modules/coinswap/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
k.SetStandardDenom(ctx, genState.StandardDenom)
k.setSequence(ctx, genState.Sequence)
for _, pool := range genState.Pool {
k.setPool(ctx, &pool)
poolCopy := pool // Create a copy of the pool variable
k.setPool(ctx, &poolCopy)
}
}

Expand Down
5 changes: 1 addition & 4 deletions modules/htlc/client/cli/flags.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// nolint
package cli

import (
Expand All @@ -17,9 +16,7 @@ const (
FlagTransfer = "transfer"
)

var (
FsCreateHTLC = flag.NewFlagSet("", flag.ContinueOnError)
)
var FsCreateHTLC = flag.NewFlagSet("", flag.ContinueOnError)

func init() {
FsCreateHTLC.String(FlagTo, "", "Bech32 encoding address to receive tokens")
Expand Down
4 changes: 3 additions & 1 deletion modules/htlc/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) {
}

k.SetPreviousBlockTime(ctx, data.PreviousBlockTime)
k.SetParams(ctx, data.Params)
if err := k.SetParams(ctx, data.Params); err != nil {
panic(err.Error())
}
for _, supply := range data.Supplies {
k.SetAssetSupply(ctx, supply, supply.CurrentSupply.Denom)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/htlc/keeper/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func (suite *AssetTestSuite) TestUpdateTimeBasedSupplyLimits() {
MaxBlockLock: MaxTimeLock,
}},
}
suite.keeper.SetParams(suite.ctx, newParams)
suite.Require().NoError(suite.keeper.SetParams(suite.ctx, newParams), "SetParams should not panic")
suite.ctx = suite.ctx.WithBlockTime(suite.ctx.BlockTime().Add(tc.args.duration))
suite.NotPanics(
func() {
Expand Down
2 changes: 1 addition & 1 deletion modules/mt/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func GetCmdTransferMT() *cobra.Command {
if err := cmd.Flags().Set(flags.FlagFrom, args[0]); err != nil {
return err
}

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions modules/mt/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (msg MsgIssueDenom) Type() string { return TypeMsgIssueDenom }

// ValidateBasic Implements Msg.
func (msg MsgIssueDenom) ValidateBasic() error {
if len(strings.TrimSpace(msg.Name)) <= 0 {
if len(strings.TrimSpace(msg.Name)) == 0 {
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "name is required")
}

Expand Down Expand Up @@ -201,7 +201,7 @@ func (msg MsgMintMT) Type() string { return TypeMsgMintMT }

// ValidateBasic Implements Msg.
func (msg MsgMintMT) ValidateBasic() error {
if len(strings.TrimSpace(msg.DenomId)) <= 0 {
if len(strings.TrimSpace(msg.DenomId)) == 0 {
return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "denom id is required")
}

Expand Down
2 changes: 1 addition & 1 deletion modules/oracle/simulation/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func GenServiceBindingsAndProviders(
providers = append(providers, provider.Address.String())
}
}
return
return providers
}

func GenFeed(k keeper.Keeper, r *rand.Rand, ctx sdk.Context) types.Feed {
Expand Down
2 changes: 1 addition & 1 deletion modules/service/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
suite.app = app

suite.NoError(suite.keeper.SetParams(suite.ctx, types.DefaultParams()),"set params failed")
suite.NoError(suite.keeper.SetParams(suite.ctx, types.DefaultParams()), "set params failed")
suite.setTestAddrs()
}

Expand Down
2 changes: 1 addition & 1 deletion modules/service/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (

// -------------

invalidName = "invalid/service/name"
invalidName = "invalid/service/name"
invalidRequestContextID = "invalid-request-context-id"
)

Expand Down
13 changes: 6 additions & 7 deletions modules/token/contracts/erc20.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package contracts

import (
_ "embed" //embed

_ "embed" // embed
"encoding/json"

"mods.irisnet.org/modules/token/types"
Expand All @@ -12,15 +11,15 @@ const (
// EventSwapToNative is the name of the event emitted when swapping to native
EventSwapToNative = "SwapToNative"
// MethodMint is the name of the method mint of the ERC20 contract
MethodMint = "mint"
MethodMint = "mint"
// MethodBurn is the name of the method burn of the ERC20 contract
MethodBurn = "burn"
MethodBurn = "burn"
// MethodBalanceOf is the name of the method balanceOf of the ERC20 contract
MethodBalanceOf = "balanceOf"
MethodBalanceOf = "balanceOf"
// MethodInitialize is the name of the method initialize of the ERC20 contract
MethodInitialize = "initialize"
MethodInitialize = "initialize"
// MethodUpgradeTo is the name of the method upgradeTo of the Beacon contract
MethodUpgradeTo = "upgradeTo"
MethodUpgradeTo = "upgradeTo"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion modules/token/keeper/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,4 @@ func (k Keeper) assertTokenValid(ctx sdk.Context, token v1.Token) error {
)
}
return nil
}
}
2 changes: 1 addition & 1 deletion modules/token/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ var (
ErrUnsupportedKey = errorsmod.Register(ModuleName, 24, "evm not supported public key")
ErrInvalidContract = errorsmod.Register(ModuleName, 25, "invalid contract")
ErrERC20Disabled = errorsmod.Register(ModuleName, 26, "erc20 swap is disabled")
ErrBeaconNotSet = errorsmod.Register(ModuleName, 27, "beacon contract not set")
ErrBeaconNotSet = errorsmod.Register(ModuleName, 27, "beacon contract not set")
)
3 changes: 1 addition & 2 deletions modules/token/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"strconv"

"cosmossdk.io/math"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down Expand Up @@ -76,7 +75,7 @@ func ParseBool(v string) (Bool, error) {
// ratio: swap rate
// inputScale: the decimal scale of input amount
// outputScale: the decimal scale of output amount
func LossLessSwap(input math.Int, ratio sdk.Dec, inputScale, outputScale uint32) (math.Int, math.Int) {
func LossLessSwap(input sdkmath.Int, ratio sdk.Dec, inputScale, outputScale uint32) (sdkmath.Int, sdkmath.Int) {
inputDec := sdk.NewDecFromInt(input)
scaleFactor := int64(inputScale) - int64(outputScale)
var scaleMultipler, scaleReverseMultipler sdk.Dec
Expand Down
12 changes: 6 additions & 6 deletions simapp/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func SetupNetwork(t *testing.T, depInjectOptions DepinjectOptions) Network {
}

func SetupNetworkWithConfig(t *testing.T, cfg network.Config) Network {
t.Helper()
t.Helper()
network, err := network.New(t, t.TempDir(), cfg)
require.NoError(t, err, "SetupNetwork failed")

Expand All @@ -67,7 +67,7 @@ func (n Network) ExecTxCmdWithResult(t *testing.T,
cmd *cobra.Command,
extraArgs []string,
) *ResponseTx {
t.Helper()
t.Helper()
buf, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, extraArgs)
require.NoError(t, err, "ExecTestCLICmd failed")

Expand All @@ -87,7 +87,7 @@ func (n Network) ExecQueryCmd(t *testing.T,
extraArgs []string,
resp proto.Message,
) {
t.Helper()
t.Helper()
buf, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, extraArgs)
require.NoError(t, err, "ExecTestCLICmd failed")
require.NoError(t, clientCtx.Codec.UnmarshalJSON(buf.Bytes(), resp), buf.String())
Expand All @@ -111,7 +111,7 @@ func (n Network) QueryTx(t *testing.T,
clientCtx client.Context,
txHash string,
) *ResponseTx {
t.Helper()
t.Helper()
var (
result *coretypes.ResultTx
err error
Expand Down Expand Up @@ -151,7 +151,7 @@ func (n Network) SendMsgs(
t *testing.T,
msgs ...sdk.Msg,
) *sdk.TxResponse {
t.Helper()
t.Helper()
val := n.Validators[0]
client := val.ClientCtx.WithBroadcastMode(flags.BroadcastSync)

Expand Down Expand Up @@ -185,7 +185,7 @@ func (n Network) SendMsgs(
func (n Network) BlockSendMsgs(t *testing.T,
msgs ...sdk.Msg,
) *ResponseTx {
t.Helper()
t.Helper()
response := n.SendMsgs(t, msgs...)
return n.QueryTx(t, n.Validators[0].ClientCtx, response.TxHash)
}
Loading

0 comments on commit d636396

Please sign in to comment.