Skip to content

Commit

Permalink
fix: make lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir committed Jun 23, 2022
1 parent 166edf0 commit 6c98177
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: make go.sum

- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2

- name: Run make
run: make
2 changes: 1 addition & 1 deletion ante/ante_sigs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/functionx/fx-core/tests"
)

func (suite AnteTestSuite) TestSignatures() {
func (suite *AnteTestSuite) TestSignatures() {
suite.SetupTest() // reset

addr, privKey := tests.NewAddrKey()
Expand Down
5 changes: 0 additions & 5 deletions ante/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -60,10 +59,6 @@ type EVMKeeper interface {
GetTxIndexTransient(ctx sdk.Context) uint64
}

type protoTxProvider interface {
GetProtoTx() *tx.Tx
}

// FeeMarketKeeper defines the expected keeper interface used on the AnteHandler
type FeeMarketKeeper interface {
GetParams(ctx sdk.Context) (params feemarkettypes.Params)
Expand Down
2 changes: 2 additions & 0 deletions app/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

// nolint
"github.com/cosmos/cosmos-sdk/types/bech32/legacybech32"

cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
Expand Down Expand Up @@ -290,6 +291,7 @@ $ %s debug pubkey '{"@type":"/cosmos.crypto.ed25519.PubKey","key":"eKlxn6Xoe9LNm
}
}
if err = clientCtx.Codec.UnmarshalInterfaceJSON([]byte(args[0]), &pubkey); err != nil {
// nolint
if pubkey, err = legacybech32.UnmarshalPubKey(legacybech32.ConsPK, args[0]); err == nil {
} else if pubkey, err = legacybech32.UnmarshalPubKey(legacybech32.AccPK, args[0]); err == nil {
} else if pubkey, err = legacybech32.UnmarshalPubKey(legacybech32.ValPK, args[0]); err == nil {
Expand Down
5 changes: 1 addition & 4 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ func ParseFunctionXChainID(_ string) (*big.Int, error) {
}

func ValidFunctionXChainID(chainID string) bool {
if fxtypes.ChainId() == chainID {
return true
}
return false
return fxtypes.ChainId() == chainID
}

func CalculateBaseFee(ctx sdk.Context, k feemarketkeeper.Keeper) *big.Int {
Expand Down
2 changes: 1 addition & 1 deletion tests/crosschain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (c *Client) BroadcastTx(msgList []sdk.Msg) string {
if err != nil {
c.t.Fatal(err)
}
c.t.Logf("msg index:[%d], type:[%s], data:[%+v]", i, fmt.Sprintf("%s", sdk.MsgTypeURL(msg)), string(marshalIndent))
c.t.Logf("msg index:[%d], type:[%s], data:[%+v]", i, sdk.MsgTypeURL(msg), string(marshalIndent))
}

txBodyBytes, txAuthInfoBytes := buildTxBodyAndTxAuthInfo(c, msgList, account.GetAccountNumber(), account.GetSequence())
Expand Down
2 changes: 2 additions & 0 deletions tests/evm/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/stretchr/testify/assert"

// nolint
"github.com/cosmos/cosmos-sdk/types/bech32/legacybech32"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
Expand Down Expand Up @@ -34,6 +35,7 @@ func Test_FxAddress(t *testing.T) {
bz, _ := hex.DecodeString(privateKey)
priKey := secp256k1.PrivKey{Key: bz}

// nolint
pubkey, err := legacybech32.MarshalPubKey(legacybech32.AccPK, priKey.PubKey())
require.NoError(t, err)
t.Log("fx pubkey", pubkey)
Expand Down
13 changes: 1 addition & 12 deletions tests/tron/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"math/big"
"sync"
"testing"

Expand Down Expand Up @@ -48,16 +47,6 @@ const (
//purseTokenChannelIBC = "transfer/channel-0"
defaultExternalWalletPrivateKey = "b3f8605873861602b62617993fda26c00c057776934931a9d8cfa5d2e78fdc4a"
chainName = trontypes.ModuleName
gravityId = "fx-" + chainName + "-local"
)

var (
oneInt = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil))

//purseDenom = types2.DenomTrace{
// Path: purseTokenChannelIBC,
// BaseDenom: fmt.Sprintf("%s%s", chainName, tusdTokenContract),
//}.IBCDenom()
)

var (
Expand Down Expand Up @@ -135,7 +124,7 @@ func (c *Client) BroadcastTx(msgList []sdk.Msg) string {
if err != nil {
c.t.Fatal(err)
}
c.t.Logf("msg index:[%d], type:[%s], data:[%+v]", i, fmt.Sprintf("%s", sdk.MsgTypeURL(msg)), string(marshalIndent))
c.t.Logf("msg index:[%d], type:[%s], data:[%+v]", i, sdk.MsgTypeURL(msg), string(marshalIndent))
}

txBodyBytes, txAuthInfoBytes := buildTxBodyAndTxAuthInfo(c, msgList, account.GetAccountNumber(), account.GetSequence())
Expand Down
15 changes: 9 additions & 6 deletions types/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ const (

// mainnet constant
const (
mainnetCrossChainSupportBscBlock = 1354000
mainnetCrossChainSupportTronAndPolygonBlock = 2062000
// gravity prune validator set
mainnetGravityPruneValsetAndAttestationBlock = 610000
// gravity not slash no set eth address validator
mainnetGravityValsetSlashBlock = 1685000

/*
mainnetCrossChainSupportBscBlock = 1354000
mainnetCrossChainSupportTronAndPolygonBlock = 2062000
// gravity prune validator set
mainnetGravityPruneValsetAndAttestationBlock = 610000
// gravity not slash no set eth address validator
mainnetGravityValsetSlashBlock = 1685000
*/

mainnetChainId = "fxcore"
mainnetEvmChainID = 1
Expand Down
2 changes: 2 additions & 0 deletions x/crosschain/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,11 @@ func (suite *IntegrationTestSuite) TestOracleDelete() {

oracleAddr, found = suite.Keeper().GetOracleAddressByBridgerKey(suite.ctx, bridger)
require.True(suite.T(), found)
require.Equal(suite.T(), oracleAddr, oracle)

oracleAddr, found = suite.Keeper().GetOracleByExternalAddress(suite.ctx, externalAddress)
require.True(suite.T(), found)
require.Equal(suite.T(), oracleAddr, oracle)

oracleData, found = suite.Keeper().GetOracle(suite.ctx, oracle)
require.True(suite.T(), found)
Expand Down
2 changes: 2 additions & 0 deletions x/crosschain/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func (suite *KeeperTestSuite) TestMsgSetOracleSetConfirm() {
})
require.EqualValues(suite.T(), fmt.Sprintf("fx-%s-bridge", suite.chainName), gravityId)
checkpoint, err := nonce1OracleSet.GetCheckpoint(gravityId)
require.NoError(suite.T(), err)

external1Signature, err := types.NewEthereumSignature(checkpoint, suite.externals[0])
require.NoError(suite.T(), err)
Expand Down Expand Up @@ -351,6 +352,7 @@ func (suite *KeeperTestSuite) TestClaimWithOracleOnline() {
})
require.EqualValues(suite.T(), fmt.Sprintf("fx-%s-bridge", suite.chainName), gravityId)
checkpoint, err := nonce1OracleSet.GetCheckpoint(gravityId)
require.NoError(suite.T(), err)

// oracle Online!!!
oracle, found := suite.Keeper().GetOracle(suite.ctx, suite.oracles[0])
Expand Down
9 changes: 5 additions & 4 deletions x/crosschain/legacy/v020/oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ import (
)

func TestMigrateOracle(t *testing.T) {
oracleAddr := make([]sdk.AccAddress, 20)
oracleNumber := 20
oracleAddr := make([]sdk.AccAddress, oracleNumber)
for i := 0; i < len(oracleAddr); i++ {
oracleAddr[i] = secp256k1.GenPrivKey().PubKey().Bytes()
}
bridgerAddr := make([]sdk.AccAddress, 20)
bridgerAddr := make([]sdk.AccAddress, oracleNumber)
for i := 0; i < len(oracleAddr); i++ {
bridgerAddr[i] = secp256k1.GenPrivKey().PubKey().Bytes()
}
externalAddr := make([]common.Address, 20)
externalAddr := make([]common.Address, oracleNumber)
for i := 0; i < len(oracleAddr); i++ {
key, _ := crypto.GenerateKey()
externalAddr[i] = crypto.PubkeyToAddress(key.PublicKey)
Expand Down Expand Up @@ -81,7 +82,7 @@ func TestMigrateOracle(t *testing.T) {
ctx := myApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
oraclesFromDB := myApp.BscKeeper.GetAllOracles(ctx, false)
sort.Slice(oraclesFromDB, func(i, j int) bool {
return oraclesFromDB[i].OracleAddress > oracles[j].OracleAddress
return oraclesFromDB[i].OracleAddress > oraclesFromDB[j].OracleAddress
})
require.Equal(t, len(oracles), len(oraclesFromDB))

Expand Down
3 changes: 3 additions & 0 deletions x/erc20/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ func (suite *KeeperTestSuite) BalanceOf(contract, account common.Address) interf
}

unpacked, err := erc20Config.ABI.Unpack("balanceOf", res.Ret)
if err != nil {
return err
}
if len(unpacked) == 0 {
return nil
}
Expand Down
19 changes: 8 additions & 11 deletions x/erc20/keeper/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ const (
)

const (
erc20Name = "Coin Token"
erc20Symbol = "CTKN"
erc20Decimals = uint8(18)
cosmosTokenBase = "acoin"
cosmosTokenDisplay = "coin"
cosmosDecimals = uint8(6)
defaultExponent = uint32(18)
zeroExponent = uint32(0)
erc20Name = "Coin Token"
erc20Symbol = "CTKN"
erc20Decimals = uint8(18)
cosmosTokenBase = "acoin"
defaultExponent = uint32(18)
)

func (suite *KeeperTestSuite) setupRegisterERC20Pair(contractType int) common.Address {
Expand Down Expand Up @@ -69,7 +66,7 @@ func (suite *KeeperTestSuite) setupRegisterCoin() (banktypes.Metadata, *types.To
return validMetadata, pair
}

func (suite KeeperTestSuite) TestRegisterCoin() {
func (suite *KeeperTestSuite) TestRegisterCoin() {
metadata := banktypes.Metadata{
Description: "description",
// NOTE: Denom units MUST be increasing
Expand Down Expand Up @@ -172,7 +169,7 @@ func (suite KeeperTestSuite) TestRegisterCoin() {
}
}

func (suite KeeperTestSuite) TestRegisterERC20() {
func (suite *KeeperTestSuite) TestRegisterERC20() {
var (
contractAddr common.Address
pair types.TokenPair
Expand Down Expand Up @@ -251,7 +248,7 @@ func (suite KeeperTestSuite) TestRegisterERC20() {
}
}

func (suite KeeperTestSuite) TestToggleRelay() {
func (suite *KeeperTestSuite) TestToggleRelay() {
var (
contractAddr common.Address
id []byte
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/applications/transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
cap := suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)

// Release channel capability
suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap)
_ = suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap)
amount = sdk.NewCoin(fxtypes.DefaultDenom, sdk.NewInt(100))
}, true, false},
}
Expand Down
5 changes: 2 additions & 3 deletions x/ibc/applications/transfer/simulation/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package simulation

import (
"fmt"
"math/rand"

simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
Expand All @@ -18,13 +17,13 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange {
simulation.NewSimParamChange(types.ModuleName, string(types.KeySendEnabled),
func(r *rand.Rand) string {
sendEnabled := RadomEnabled(r)
return fmt.Sprintf("%s", types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: sendEnabled}))
return string(types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: sendEnabled}))
},
),
simulation.NewSimParamChange(types.ModuleName, string(types.KeyReceiveEnabled),
func(r *rand.Rand) string {
receiveEnabled := RadomEnabled(r)
return fmt.Sprintf("%s", types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: receiveEnabled}))
return string(types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: receiveEnabled}))
},
),
}
Expand Down
11 changes: 6 additions & 5 deletions x/ibc/testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) {
chain.NextBlock()

// increment sequence for successful transaction execution
chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1)
err = chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1)
if err != nil {
return nil, err
}

chain.Coordinator.IncrementTime()

Expand Down Expand Up @@ -477,10 +480,8 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64,
Commit: commit.ToProto(),
}

if tmValSet != nil {
valSet, err = tmValSet.ToProto()
require.NoError(chain.T, err)
}
valSet, err = tmValSet.ToProto()
require.NoError(chain.T, err)

if tmTrustedVals != nil {
trustedVals, err = tmTrustedVals.ToProto()
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/testing/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
if ibcApp.PortID != "" && !am.portKeeper.IsBound(ctx, ibcApp.PortID) {
// bind mock portID
cap := am.portKeeper.BindPort(ctx, ibcApp.PortID)
ibcApp.ScopedKeeper.ClaimCapability(ctx, cap, host.PortPath(ibcApp.PortID))
_ = ibcApp.ScopedKeeper.ClaimCapability(ctx, cap, host.PortPath(ibcApp.PortID))
}
}

Expand Down
6 changes: 4 additions & 2 deletions x/ibc/testing/mock/privval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func TestSignVote(t *testing.T) {
pk, _ := pv.GetPubKey()

vote := &tmproto.Vote{Height: 2}
pv.SignVote(chainID, vote)
err := pv.SignVote(chainID, vote)
require.NoError(t, err)

msg := tmtypes.VoteSignBytes(chainID, vote)
ok := pk.VerifySignature(msg, vote.Signature)
Expand All @@ -36,7 +37,8 @@ func TestSignProposal(t *testing.T) {
pk, _ := pv.GetPubKey()

proposal := &tmproto.Proposal{Round: 2}
pv.SignProposal(chainID, proposal)
err := pv.SignProposal(chainID, proposal)
require.NoError(t, err)

msg := tmtypes.ProposalSignBytes(chainID, proposal)
ok := pk.VerifySignature(msg, proposal.Signature)
Expand Down
3 changes: 3 additions & 0 deletions x/migrate/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ func GetMigrateAccountCmd() *cobra.Command {

//migrate account
msg, err := getMigrateAccountMsg(cliCtx, fromAddress, hexAddress)
if err != nil {
return err
}
msgs = append(msgs, msg)
//sign and broadcast tx
return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msgs...)
Expand Down
2 changes: 1 addition & 1 deletion x/migrate/keeper/distr_staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (suite *KeeperTestSuite) TestMigrateStakingDelegate() {

//check eth acc delegate
_, found = suite.app.StakingKeeper.GetDelegation(suite.ctx, ethAcc.Bytes(), val1.GetOperator())
suite.Require().False(false)
suite.Require().False(found)

//commit block
suite.ctx = commitBlock(suite.T(), suite.ctx, suite.app)
Expand Down
2 changes: 2 additions & 0 deletions x/migrate/keeper/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (suite *KeeperTestSuite) TestMigrateGovActiveAndVote() {
//check acc vote
vote, found := suite.app.GovKeeper.GetVote(suite.ctx, proposal.ProposalId, acc)
suite.Require().True(found)
// nolint
suite.Require().Equal(vote.Option, govtypes.OptionYes)

//check to address deposit vote
Expand Down Expand Up @@ -179,6 +180,7 @@ func (suite *KeeperTestSuite) TestMigrateGovActiveAndVote() {

vote, found = suite.app.GovKeeper.GetVote(suite.ctx, proposal.ProposalId, toEthAcc.Bytes())
suite.Require().True(found)
// nolint
suite.Require().Equal(vote.Option, govtypes.OptionYes)

}

0 comments on commit 6c98177

Please sign in to comment.