Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add fee test with wrong denom order #3493

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/e2e/e2e_bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,47 @@
s.Require().Nil(txWithExt)
})
}

func (s *IntegrationTestSuite) testFeeWithWrongDenomOrder() {
s.Run("test_fee_with_wrong_denom_order", func() {
// Get the first validator
val1 := s.chainA.validators[0]
valAddr, err := val1.keyInfo.GetAddress()
s.Require().NoError(err)

// Create transaction with fees in wrong denom order
fees := sdk.NewCoins(
sdk.NewCoin(stakeDenom, math.NewInt(1000)),
sdk.NewCoin(uatomDenom, math.NewInt(100)),
)

msg := banktypes.NewMsgSend(
valAddr,
valAddr,
sdk.NewCoins(sdk.NewCoin(uatomDenom, math.NewInt(1))),
)

// Build and sign transaction
txBuilder := s.chainA.clientCtx.TxConfig.NewTxBuilder()

Check failure on line 241 in tests/e2e/e2e_bank_test.go

View workflow job for this annotation

GitHub Actions / Analyze

s.chainA.clientCtx undefined (type *chain has no field or method clientCtx)

Check failure on line 241 in tests/e2e/e2e_bank_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

s.chainA.clientCtx undefined (type *chain has no field or method clientCtx)

Check failure on line 241 in tests/e2e/e2e_bank_test.go

View workflow job for this annotation

GitHub Actions / test-e2e

s.chainA.clientCtx undefined (type *chain has no field or method clientCtx)
err = txBuilder.SetMsgs(msg)
s.Require().NoError(err)

txBuilder.SetFeeAmount(fees)
txBuilder.SetGasLimit(200000)

// Verify that transaction is accepted and processed correctly
// despite fees being in wrong denom order
s.Require().Eventually(
func() bool {
tx, err := s.chainA.SignAndBroadcastTx(val1.keyInfo, txBuilder)

Check failure on line 252 in tests/e2e/e2e_bank_test.go

View workflow job for this annotation

GitHub Actions / Analyze

s.chainA.SignAndBroadcastTx undefined (type *chain has no field or method SignAndBroadcastTx)

Check failure on line 252 in tests/e2e/e2e_bank_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

s.chainA.SignAndBroadcastTx undefined (type *chain has no field or method SignAndBroadcastTx)

Check failure on line 252 in tests/e2e/e2e_bank_test.go

View workflow job for this annotation

GitHub Actions / test-e2e

s.chainA.SignAndBroadcastTx undefined (type *chain has no field or method SignAndBroadcastTx)
if err != nil {
return false
}
return tx.Code == uint32(0)
},
10*time.Second,
5*time.Second,
"Transaction with wrong denom order should succeed",
)
})
}
9 changes: 7 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package e2e

import "fmt"
import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"

Check failure on line 6 in tests/e2e/e2e_test.go

View workflow job for this annotation

GitHub Actions / Analyze

"github.com/cosmos/cosmos-sdk/types" imported as sdk and not used

Check failure on line 6 in tests/e2e/e2e_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

"github.com/cosmos/cosmos-sdk/types" imported as sdk and not used

Check failure on line 6 in tests/e2e/e2e_test.go

View workflow job for this annotation

GitHub Actions / test-e2e

"github.com/cosmos/cosmos-sdk/types" imported as sdk and not used
"github.com/cosmos/cosmos-sdk/x/bank/types"

Check failure on line 7 in tests/e2e/e2e_test.go

View workflow job for this annotation

GitHub Actions / Analyze

"github.com/cosmos/cosmos-sdk/x/bank/types" imported and not used (typecheck)

Check failure on line 7 in tests/e2e/e2e_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

"github.com/cosmos/cosmos-sdk/x/bank/types" imported and not used (typecheck)

Check failure on line 7 in tests/e2e/e2e_test.go

View workflow job for this annotation

GitHub Actions / test-e2e

"github.com/cosmos/cosmos-sdk/x/bank/types" imported and not used
)

var (
runBankTest = true
Expand Down Expand Up @@ -30,6 +35,7 @@
s.T().Skip()
}
s.testBankTokenTransfer()
s.testFeeWithWrongDenomOrder()
}

func (s *IntegrationTestSuite) TestEncode() {
Expand Down Expand Up @@ -86,7 +92,6 @@
s.testSlashing(chainAPI)
}

// todo add fee test with wrong denom order
func (s *IntegrationTestSuite) TestStakingAndDistribution() {
if !runStakingAndDistributionTest {
s.T().Skip()
Expand Down
Loading