Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
phamminh0811 committed Jul 25, 2024
1 parent 29ac9ad commit c98c617
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
4 changes: 1 addition & 3 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ func (s *IntegrationTestSuite) TestFeeTaxGrant() {
s.Require().NoError(err)
balanceTest2TerraBalance, err := node.QuerySpecificBalance(test2Addr, initialization.TerraDenom)
s.Require().NoError(err)
balanceTest2UsdBalance, err := node.QuerySpecificBalance(test2Addr, initialization.UsdDenom)
s.Require().NoError(err)

node.BankSendFeeGrantWithWallet(transferTerraCoin2.String(), test1Addr, validatorAddr, test2Addr, "test1", gasLimit, sdk.NewCoins(transferUsdCoin2, feeCoinTerraDenom))

Expand All @@ -285,7 +283,7 @@ func (s *IntegrationTestSuite) TestFeeTaxGrant() {
s.Require().NoError(err)
newBalanceTest2TerraBalance, err := node.QuerySpecificBalance(test2Addr, initialization.TerraDenom)
s.Require().NoError(err)
balanceTest2UsdBalance, err = node.QuerySpecificBalance(test2Addr, initialization.UsdDenom)
balanceTest2UsdBalance, err := node.QuerySpecificBalance(test2Addr, initialization.UsdDenom)
s.Require().NoError(err)
// The fee grant msg only support to pay by one denom, so only uusd balance will change
s.Require().Equal(newValidatorTerraBalance, validatorTerraBalance.Add(transferTerraCoin2))
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/initialization/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ func updateDistrGenesis(distrGenState *distrtypes.GenesisState) {
distrGenState.Params.CommunityTax = sdk.NewDecWithPrec(2, 2)
distrGenState.Params.WithdrawAddrEnabled = true
}

func updateTreasuryGenesis(treasuryGenState *treasurytypes.GenesisState) {
treasuryGenState.TaxRate = TaxRate
treasuryGenState.Params.TaxPolicy = treasurytypes.PolicyConstraints{
Expand Down
9 changes: 0 additions & 9 deletions x/tax2gas/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expFail: false,
},
{

name: "Fail: Authz exec",
simulation: false,
checkTx: true,
Expand All @@ -279,7 +278,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expFail: false,
},
{

name: "Bypass: ibc MsgRecvPacket",
simulation: false,
checkTx: true,
Expand All @@ -298,7 +296,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expFail: false,
},
{

name: "Not Bypass: ibc MsgRecvPacket",
simulation: false,
checkTx: true,
Expand All @@ -318,7 +315,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expErrMsg: "can't find coin",
},
{

name: "Bypass: ibc MsgAcknowledgement",
simulation: false,
checkTx: true,
Expand All @@ -338,7 +334,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expFail: false,
},
{

name: "Bypass: ibc MsgUpdateClient",
simulation: false,
checkTx: true,
Expand All @@ -358,7 +353,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expFail: false,
},
{

name: "Bypass: ibc MsgTimeout",
simulation: false,
checkTx: true,
Expand All @@ -378,7 +372,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expFail: false,
},
{

name: "Bypass: ibc MsgTimeoutOnClose",
simulation: false,
checkTx: true,
Expand All @@ -399,7 +392,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expFail: false,
},
{

name: "Other msgs must pay gas fee",
simulation: false,
checkTx: true,
Expand All @@ -418,7 +410,6 @@ func (s *AnteTestSuite) TestDeductFeeDecorator() {
expErrMsg: "can't find coin",
},
{

name: "Oracle zero fee",
simulation: false,
checkTx: true,
Expand Down
2 changes: 1 addition & 1 deletion x/tax2gas/types/expected_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package types
import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

// TreasuryKeeper for tax charging & recording
Expand Down
15 changes: 7 additions & 8 deletions x/tax2gas/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ func CalculateTaxesAndPayableFee(gasPrices sdk.DecCoins, feeCoins sdk.Coins, tax
case feeCoin.IsGTE(totalFeeRequired):
taxes = taxes.Add(taxFeeRequired)
payableFees = payableFees.Add(totalFeeRequired)
taxGasRemaining = 0
gasRemaining = 0
return
return taxes, payableFees, gasRemaining
case feeCoin.IsGTE(taxFeeRequired):
taxes = taxes.Add(taxFeeRequired)
taxGasRemaining = 0
Expand All @@ -105,21 +104,21 @@ func CalculateTaxesAndPayableFee(gasPrices sdk.DecCoins, feeCoins sdk.Coins, tax
payableFees = payableFees.Add(feeCoin)
taxFeeRemaining := sdk.NewDecCoinFromCoin(taxFeeRequired.Sub(feeCoin))
taxGasRemaining = uint64(taxFeeRemaining.Amount.Quo(gasPrice).Ceil().RoundInt64())
gasRemaining = gasRemaining - (taxGas - taxGasRemaining)
gasRemaining -= taxGas - taxGasRemaining
}
case gasRemaining > 0:
if feeCoin.IsGTE(totalFeeRequired) {
payableFees = payableFees.Add(totalFeeRequired)
gasRemaining = 0
return
return taxes, payableFees, gasRemaining
} else {

Check warning on line 114 in x/tax2gas/utils/utils.go

View workflow job for this annotation

GitHub Actions / golangci-lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
payableFees = payableFees.Add(feeCoin)
totalFeeRemaining := sdk.NewDecCoinFromCoin(totalFeeRequired.Sub(feeCoin))
gasRemaining = uint64(totalFeeRemaining.Amount.Quo(gasPrice).Ceil().RoundInt64())
totalFeeRemaining := sdk.NewDecCoinFromCoin(totalFeeRequired.Sub(feeCoin))
gasRemaining = uint64(totalFeeRemaining.Amount.Quo(gasPrice).Ceil().RoundInt64())
}
default:
return
return taxes, payableFees, gasRemaining
}
}
return
return taxes, payableFees, gasRemaining
}

0 comments on commit c98c617

Please sign in to comment.