Skip to content

Commit

Permalink
fixed linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
miladz68 committed Nov 20, 2024
1 parent de4cf81 commit 8dac023
Show file tree
Hide file tree
Showing 68 changed files with 175 additions and 242 deletions.
3 changes: 1 addition & 2 deletions app/amino_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app_test

import (
"fmt"
"reflect"
"testing"
_ "unsafe"
Expand Down Expand Up @@ -129,7 +128,7 @@ func TestLegacyAmino_ExpectedMessages(t *testing.T) {
}

_, expectedNonAmino := expectedNonAminoMsgURLs[messageURL]
require.True(t, expectedNonAmino, fmt.Sprintf("Unexpected non-amino message:%s", messageURL))
require.True(t, expectedNonAmino, "Unexpected non-amino message:%s", messageURL)
delete(expectedNonAminoMsgURLs, messageURL)
}

Expand Down
4 changes: 0 additions & 4 deletions build/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68 h1:Tb9avuSQW3smVGrUnDh/Y+ML4eK802UsvJNZHsBgOGg=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240321120602-0a9c50facc68/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/crust v0.0.0-20241119084204-806f2328b7f9 h1:b8hiKQL7ykNC6YdMkd0Diqst217W2hqT48Oyugr4wvw=
github.com/CoreumFoundation/crust v0.0.0-20241119084204-806f2328b7f9/go.mod h1:DC2Jq9oOJgDccdSqwxggqoFJ+EMn1wl8hMXAnnK4DSs=
github.com/CoreumFoundation/crust v0.0.0-20241119093707-e6aa58771681 h1:GNKt++3Il0GUD0jOvF5/vj5V9HFl/pHkEvRo4vi3vzQ=
github.com/CoreumFoundation/crust v0.0.0-20241119093707-e6aa58771681/go.mod h1:DC2Jq9oOJgDccdSqwxggqoFJ+EMn1wl8hMXAnnK4DSs=
github.com/CoreumFoundation/crust v0.0.0-20241119103533-4a2dd90bbd7c h1:WOM8Nu9APDJayYpF7vSO8ZUmossqXo0VQB92q8f7BU4=
github.com/CoreumFoundation/crust v0.0.0-20241119103533-4a2dd90bbd7c/go.mod h1:DC2Jq9oOJgDccdSqwxggqoFJ+EMn1wl8hMXAnnK4DSs=
github.com/CosmWasm/wasmd v0.53.0 h1:kdaoAi20bIb4VCsxw9pRaT2g5PpIp82Wqrr9DRVN9ao=
Expand Down
9 changes: 4 additions & 5 deletions cmd/cored/cosmoscmd/gas_price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,31 @@ func TestAutoGasPrices(t *testing.T) {
},
{
name: "specific gas prices are provided",
flags: []string{fmt.Sprintf("--gas-prices=0.1%s", denom), "--gas=115000"},
flags: []string{"--gas-prices=0.1" + denom, "--gas=115000"},
feeAssertion: func(t *testing.T, fee sdk.Coins) {
assert.True(t, fee.Equal(sdk.NewCoins(sdk.NewCoin(denom, sdkmath.NewInt(11500)))))
},
},
{
name: "specific fees are provided",
flags: []string{fmt.Sprintf("--fees=12345%s", denom)},
flags: []string{"--fees=12345" + denom},
feeAssertion: func(t *testing.T, fee sdk.Coins) {
assert.True(t, fee.Equal(sdk.NewCoins(sdk.NewCoin(denom, sdkmath.NewInt(12345)))))
},
},
{
name: "both gas prices and fees are provided",
flags: []string{fmt.Sprintf("--fees=12345%s", denom), "--gas-prices=auto"},
flags: []string{"--fees=12345" + denom, "--gas-prices=auto"},
expectError: true,
},
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
requireT := require.New(t)
recipient := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
args := append([]string{
"send", testNetwork.Validators[0].Address.String(), recipient.String(), fmt.Sprintf("100%s", denom),
"send", testNetwork.Validators[0].Address.String(), recipient.String(), "100" + denom,
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
}, tc.flags...)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cored/cosmoscmd/generate_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func GenerateGenesisCmd(basicManager module.BasicManager) *cobra.Command {

inputContent, err := os.ReadFile(inputPath)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("failed to read file %s", inputPath))
return errors.Wrap(err, "failed to read file "+inputPath)

Check warning on line 46 in cmd/cored/cosmoscmd/generate_network.go

View check run for this annotation

Codecov / codecov/patch

cmd/cored/cosmoscmd/generate_network.go#L46

Added line #L46 was not covered by tests
}

var genCfg config.GenesisInitConfig
Expand Down
3 changes: 1 addition & 2 deletions cmd/cored/cosmoscmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cosmoscmd

import (
"context"
"fmt"
"io"
"os"
"time"
Expand Down Expand Up @@ -177,7 +176,7 @@ func initAppConfig() (string, interface{}) {
// own app.toml to override, or use this default value.
//
// In app, we set the min gas prices to 0.
srvCfg.MinGasPrices = fmt.Sprintf("0.00000000000000001%s", app.ChosenNetwork.Denom())
srvCfg.MinGasPrices = "0.00000000000000001" + app.ChosenNetwork.Denom()

// WASMConfig defines configuration for the wasm module.
type WASMConfig struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/cored/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func main() {
cosmoscmd.OverwriteDefaultChainIDFlags(rootCmd)
rootCmd.PersistentFlags().String(flags.FlagChainID, string(app.DefaultChainID), "The network chain ID")
if err := svrcmd.Execute(rootCmd, coreumEnvPrefix, app.DefaultNodeHome); err != nil {
//nolint:errcheck // we are already exiting the app so we don't check error.

Check warning on line 29 in cmd/cored/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/cored/main.go#L29

Added line #L29 was not covered by tests
fmt.Fprintln(rootCmd.OutOrStderr(), err)
os.Exit(1)
}
Expand Down
2 changes: 0 additions & 2 deletions integration-tests/modules/assetft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func TestAssetFTIssue(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
issuer := chain.GenAccount()
Expand Down Expand Up @@ -5178,7 +5177,6 @@ func TestAssetFTFreeze_WithRates(t *testing.T) {
}

for _, tc := range testData {
tc := tc
t.Run(tc.description, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/modules/assetnft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestAssetNFTIssueClass(t *testing.T) {
var data2 assetnfttypes.DataBytes
requireT.NoError(proto.Unmarshal(assetNftClassRes.Class.Data.Value, &data2))

requireT.Equal(jsonData, data2.Data)
requireT.JSONEq(string(jsonData), string(data2.Data))

assetNftClassesRes, err := assetNftClient.Classes(ctx, &assetnfttypes.QueryClassesRequest{
Issuer: issuer.String(),
Expand Down Expand Up @@ -576,7 +576,7 @@ func TestAssetNFTMint(t *testing.T) {
var data2 assetnfttypes.DataBytes
requireT.NoError(proto.Unmarshal(nftRes.Nft.Data.Value, &data2))

requireT.Equal(jsonData, data2.Data)
requireT.JSONEq(string(jsonData), string(data2.Data))

// check the owner
ownerRes, err := nftClient.Owner(ctx, &nft.QueryOwnerRequest{
Expand Down
4 changes: 1 addition & 3 deletions integration-tests/modules/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func TestGasEstimation(t *testing.T) {
},
}
for _, tt := range testsDeterm {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -401,7 +400,6 @@ func TestGasEstimation(t *testing.T) {
},
}
for _, tt := range testsNonDeterm {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
_, estimatedGas, err := client.CalculateGas(
Expand All @@ -411,7 +409,7 @@ func TestGasEstimation(t *testing.T) {
tt.msgs...,
)
require.NoError(t, err)
require.Greater(t, int(estimatedGas), 0)
require.Positive(t, int(estimatedGas))
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/modules/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestBankSendDeterministicGas(t *testing.T) {

require.Equal(t, "cosmos.bank.v1beta1.MsgSend", gasEvents[0].MsgURL)
require.Equal(t, msgGas, gasEvents[0].DeterministicGas)
require.Greater(t, gasEvents[0].RealGas, uint64(0))
require.Positive(t, gasEvents[0].RealGas)
}

// TestBankSendDeterministicGasTwoBankSends checks that transfer takes the deterministic amount of gas.
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestBankSendDeterministicGasManyCoins(t *testing.T) {
amountToSend := sdkmath.NewInt(1000)

issueMsgs := make([]sdk.Msg, 0, numOfTokens)
for i := 0; i < numOfTokens; i++ {
for i := range numOfTokens {
issueMsgs = append(issueMsgs, &assetfttypes.MsgIssue{
Issuer: sender.String(),
Symbol: fmt.Sprintf("TOK%d", i),
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestBankMultiSendDeterministicGasManyCoins(t *testing.T) {
amountToSend := sdkmath.NewInt(1000)

issueMsgs := make([]sdk.Msg, 0, numOfTokens)
for i := 0; i < numOfTokens; i++ {
for i := range numOfTokens {
issueMsgs = append(issueMsgs, &assetfttypes.MsgIssue{
Issuer: sender.String(),
Symbol: fmt.Sprintf("TOK%d", i),
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/modules/feemodel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestFeeModelProposalParamChange(t *testing.T) {
feeModelParamsRes, err = feeModelClient.Params(ctx, &feemodeltypes.QueryParamsRequest{})
requireT.NoError(err)
assertT.Equal(feeModelParamsRes.Params.Model.MaxDiscount.String(), targetMaxDiscount.String())
assertT.Equal(feeModelParamsRes.Params.Model.String(), feeModelParamsRes.Params.Model.String())
assertT.Equal(newParams.Model.String(), feeModelParamsRes.Params.Model.String())
}

func getFeemodelParams(ctx context.Context, t *testing.T, clientCtx client.Context) feemodeltypes.ModelParams {
Expand Down
3 changes: 1 addition & 2 deletions integration-tests/modules/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package modules

import (
"context"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -501,7 +500,7 @@ func setUnbondingTimeViaGovernance(
ctx,
proposer,
[]sdk.Msg{msgUpdateParam},
fmt.Sprintf("Change the unbnunbondingdig time to %s", unbondingTime.String()),
"Change the unbnunbondingdig time to "+unbondingTime.String(),
"Changing unbonding time for the integration test",
"Changing unbonding time for the integration test",
false,
Expand Down
7 changes: 3 additions & 4 deletions integration-tests/modules/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func TestWASMBankSendContract(t *testing.T) {

require.Equal(t, "cosmos.bank.v1beta1.MsgSend", gasEvents[0].MsgURL)
require.Equal(t, msgGas, gasEvents[0].DeterministicGas)
require.Greater(t, gasEvents[0].RealGas, uint64(0))
require.Positive(t, gasEvents[0].RealGas)
}

// TestWASMGasBankSendAndBankSend checks that a message containing a deterministic and a
Expand Down Expand Up @@ -1949,7 +1949,7 @@ func TestWASMNonFungibleTokenInContract(t *testing.T) {

royaltyRate := "100000000000000000" // 1e18 = 10%
data := make([]byte, 256)
for i := 0; i < 256; i++ {
for i := range 256 {
data[i] = uint8(i)
}
encodedData := base64.StdEncoding.EncodeToString(data)
Expand Down Expand Up @@ -2537,7 +2537,7 @@ func TestWASMNonFungibleTokenInContractLegacy(t *testing.T) {

royaltyRate := sdkmath.LegacyMustNewDecFromStr("0.1")
data := make([]byte, 256)
for i := 0; i < 256; i++ {
for i := range 256 {
data[i] = uint8(i)
}
encodedData := base64.StdEncoding.EncodeToString(data)
Expand Down Expand Up @@ -3441,7 +3441,6 @@ func TestWASMContractInstantiationIsNotRejectedIfAccountExists(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()

Expand Down
10 changes: 5 additions & 5 deletions integration-tests/stress/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestBankMultiSendBatchOutputs(t *testing.T) {
fundedAccounts := make([]sdk.AccAddress, 0, numAccountsToFund)
coinToFund := sdk.NewCoin(denom, sdkmath.NewInt(10_000_000_000))

for i := 0; i < numAccountsToFund; i++ {
for range numAccountsToFund {
inputItem.Coins = inputItem.Coins.Add(coinToFund)
recipient := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
fundedAccounts = append(fundedAccounts, recipient)
Expand All @@ -63,7 +63,7 @@ func TestBankMultiSendBatchOutputs(t *testing.T) {
}
// prepare MultiSend messages
multiSendMsgs := make([]sdk.Msg, 0, iterationsToFund)
for i := 0; i < iterationsToFund; i++ {
for range iterationsToFund {
multiSendMsgs = append(multiSendMsgs, &banktypes.MsgMultiSend{
Inputs: []banktypes.Input{
inputItem,
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestBankSendBatchMsgs(t *testing.T) {
bankSendSendMsgs := make([]sdk.Msg, 0, numAccountsToFund)
coinToFund := sdk.NewCoin(denom, sdkmath.NewInt(10_000_000_000))
fundedAccounts := make([]sdk.AccAddress, 0, numAccountsToFund)
for i := 0; i < numAccountsToFund; i++ {
for range numAccountsToFund {
recipient := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
fundedAccounts = append(fundedAccounts, recipient)
bankSendSendMsgs = append(bankSendSendMsgs, &banktypes.MsgSend{
Expand All @@ -152,7 +152,7 @@ func TestBankSendBatchMsgs(t *testing.T) {

fundMsgs := make([]sdk.Msg, 0)
fundMsgs = append(fundMsgs, issueMsg)
for i := 0; i < iterationsToFund; i++ {
for range iterationsToFund {
fundMsgs = append(fundMsgs, bankSendSendMsgs...)
}
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Expand All @@ -171,7 +171,7 @@ func TestBankSendBatchMsgs(t *testing.T) {

// send coins in loop
start := time.Now()
for i := 0; i < iterationsToFund; i++ {
for range iterationsToFund {
res, err := client.BroadcastTx(
ctx,
chain.ClientContext.WithFromAddress(issuer),
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/stress/gas_estimation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestBankSendEstimation(t *testing.T) {
ToAddress: recipient1.String(),
}
initialAmount := sdkmath.NewInt(100_000_000_000)
for i := 0; i < nTokens; i++ {
for i := range nTokens {
subunit := fmt.Sprintf("tok%d", i)
denom := assetfttypes.BuildDenom(subunit, issuer)
deterministicMsgs = append(deterministicMsgs, &assetfttypes.MsgIssue{
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestBankSendEstimation(t *testing.T) {
ToAddress: recipient2.String(),
}

for i := 0; i < n; i++ {
for i := range n {
sendMsg.Amount = sendMsg.Amount.Add(sdk.NewCoin(tokens[i], sdkmath.NewInt(1_0000_000)))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func BuildTxForSimulation(
var signatureData signing.SignatureData
if multisigPubKey, ok := pubKey.(*multisig.LegacyAminoPubKey); ok {
multiSignatureData := make([]signing.SignatureData, 0, multisigPubKey.Threshold)
for i := uint32(0); i < multisigPubKey.Threshold; i++ {
for range multisigPubKey.Threshold {

Check warning on line 200 in pkg/client/tx.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/tx.go#L200

Added line #L200 was not covered by tests
multiSignatureData = append(multiSignatureData, &signing.SingleSignatureData{
SignMode: txf.SignMode(),
})
Expand Down
1 change: 0 additions & 1 deletion pkg/config/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func TestStaticConfigProviders(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
n, err := config.NetworkConfigByChainID(tt.chainID)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func unsafeConvertStr() []byte {
func (s *StringSuite) TestUnsafeStrToBytes() {
// we convert in other function to trigger GC. We want to check that
// the underlying array in []bytes is accessible after GC will finish swapping.
for i := 0; i < 5; i++ {
for range 5 {
b := unsafeConvertStr()
runtime.GC()
<-time.NewTimer(2 * time.Millisecond).C
Expand All @@ -39,7 +39,7 @@ func unsafeConvertBytes() string {
func (s *StringSuite) TestUnsafeBytesToStr() {
// we convert in other function to trigger GC. We want to check that
// the underlying array in []bytes is accessible after GC will finish swapping.
for i := 0; i < 5; i++ {
for range 5 {
str := unsafeConvertBytes()
runtime.GC()
<-time.NewTimer(2 * time.Millisecond).C
Expand Down
8 changes: 4 additions & 4 deletions testutil/cli/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func ExecQueryCmd(t *testing.T, clientCtx client.Context, cmd *cobra.Command, ex

extraArgs = append(extraArgs, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
buf, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, extraArgs)
require.NoError(t, err, fmt.Sprintf("can't execute, %s, err:%s", cmd.Use, err))
require.NoError(t, err, "can't execute, %s, err:%s", cmd.Use, err)

err = clientCtx.Codec.UnmarshalJSON(buf.Bytes(), msg)
require.NoError(t, err, fmt.Sprintf("can't decode response, %s, err:%s", buf.Bytes(), err))
require.NoError(t, err, "can't decode response, %s, err:%s", buf.Bytes(), err)
}

// ExecRootQueryCmd is a func to execute query cmd from root.
Expand All @@ -86,10 +86,10 @@ func ExecRootQueryCmd(t *testing.T, clientCtx client.Context, args []string, msg
require.NoError(t, autoCliOpts.EnhanceRootCommand(cmd))

buf, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
require.NoError(t, err, fmt.Sprintf("failed to execute, %v", args))
require.NoError(t, err, "failed to execute, %v", args)
require.NoError(
t,
clientCtx.LegacyAmino.UnmarshalJSON(buf.Bytes(), msg),
fmt.Sprintf("failed to decode response, %s", buf.Bytes()),
"failed to decode response, %s", buf.Bytes(),
)
}
4 changes: 2 additions & 2 deletions testutil/integration/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (c ChainContext) GenMultisigAccount(
) (*sdkmultisig.LegacyAminoPubKey, []string, error) {
keyNamesSet := []string{}
publicKeySet := make([]cryptotypes.PubKey, 0, signersCount)
for i := 0; i < signersCount; i++ {
for range signersCount {

Check warning on line 165 in testutil/integration/chain.go

View check run for this annotation

Codecov / codecov/patch

testutil/integration/chain.go#L165

Added line #L165 was not covered by tests
signerKeyInfo, err := c.ClientContext.Keyring().KeyByAddress(c.GenAccount())
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -373,7 +373,7 @@ func QueryChainSettings(ctx context.Context, grpcClient *grpc.ClientConn) ChainS

var addressPrefix string
for _, account := range accountsRes.Accounts {
if account != nil && account.TypeUrl == fmt.Sprintf("/%s", proto.MessageName(&authtypes.BaseAccount{})) {
if account != nil && account.TypeUrl == "/"+proto.MessageName(&authtypes.BaseAccount{}) {

Check warning on line 376 in testutil/integration/chain.go

View check run for this annotation

Codecov / codecov/patch

testutil/integration/chain.go#L376

Added line #L376 was not covered by tests
var acc authtypes.BaseAccount
if err := proto.Unmarshal(account.Value, &acc); err != nil {
panic(fmt.Sprintf("failed to unpack account, err: %s", err))
Expand Down
Loading

0 comments on commit 8dac023

Please sign in to comment.