-
Notifications
You must be signed in to change notification settings - Fork 340
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
feat(incentives): rollapp gauges upgrade handler and burn creation fee #1113
Merged
omritoptix
merged 10 commits into
main
from
mtsitrin/1083-possible-unused-code-in-incentives-module
Sep 23, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
159b822
rollapp gauges upgrade habdler
mtsitrin 60cd13d
refactored fee charge. minor UT cleanup
mtsitrin c76aee1
cleanup. fixed ut
mtsitrin ac6c7bc
Merge branch 'main' into mtsitrin/1083-possible-unused-code-in-incent…
mtsitrin 438d4a4
Merge branch 'main' into mtsitrin/1083-possible-unused-code-in-incent…
mtsitrin 1d50576
pr comments
mtsitrin 5edb098
more linter
mtsitrin 9669ebd
linter
mtsitrin ea9acc8
Merge branch 'main' into mtsitrin/1083-possible-unused-code-in-incent…
mtsitrin 4eb4fb6
fixed UT
mtsitrin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/dymensionxyz/dymension/v3/app/apptesting" | ||
"github.com/dymensionxyz/dymension/v3/x/incentives/types" | ||
lockuptypes "github.com/dymensionxyz/dymension/v3/x/lockup/types" | ||
) | ||
|
@@ -225,99 +224,3 @@ func (suite *KeeperTestSuite) TestGaugeOperations() { | |
} | ||
} | ||
} | ||
|
||
func (suite *KeeperTestSuite) TestChargeFeeIfSufficientFeeDenomBalance() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to msg_server_test.go |
||
const baseFee = int64(100) | ||
|
||
testcases := map[string]struct { | ||
accountBalanceToFund sdk.Coin | ||
feeToCharge int64 | ||
gaugeCoins sdk.Coins | ||
|
||
expectError bool | ||
}{ | ||
"fee + base denom gauge coin == acount balance, success": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(baseFee)), | ||
feeToCharge: baseFee / 2, | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(baseFee/2))), | ||
}, | ||
"fee + base denom gauge coin < acount balance, success": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(baseFee)), | ||
feeToCharge: baseFee/2 - 1, | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(baseFee/2))), | ||
}, | ||
"fee + base denom gauge coin > acount balance, error": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(baseFee)), | ||
feeToCharge: baseFee/2 + 1, | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(baseFee/2))), | ||
expectError: true, | ||
}, | ||
"fee + base denom gauge coin < acount balance, custom values, success": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(11793193112)), | ||
feeToCharge: 55, | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(328812))), | ||
}, | ||
"account funded with coins other than base denom, error": { | ||
accountBalanceToFund: sdk.NewCoin("usdc", sdk.NewInt(baseFee)), | ||
feeToCharge: baseFee, | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(baseFee/2))), | ||
expectError: true, | ||
}, | ||
"fee == account balance, no gauge coins, success": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(baseFee)), | ||
feeToCharge: baseFee, | ||
}, | ||
"gauge coins == account balance, no fee, success": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(baseFee)), | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(baseFee))), | ||
}, | ||
"fee == account balance, gauge coins in denom other than base, success": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(baseFee)), | ||
feeToCharge: baseFee, | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(baseFee*2))), | ||
}, | ||
"fee + gauge coins == account balance, multiple gauge coins, one in denom other than base, success": { | ||
accountBalanceToFund: sdk.NewCoin("adym", sdk.NewInt(baseFee)), | ||
feeToCharge: baseFee / 2, | ||
gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(baseFee*2)), sdk.NewCoin("adym", sdk.NewInt(baseFee/2))), | ||
}, | ||
} | ||
|
||
for name, tc := range testcases { | ||
suite.Run(name, func() { | ||
suite.SetupTest() | ||
|
||
err := suite.App.TxFeesKeeper.SetBaseDenom(suite.Ctx, "adym") | ||
suite.Require().NoError(err) | ||
|
||
testAccount := apptesting.CreateRandomAccounts(1)[0] | ||
ctx := suite.Ctx | ||
incentivesKeepers := suite.App.IncentivesKeeper | ||
bankKeeper := suite.App.BankKeeper | ||
|
||
// Pre-fund account. | ||
// suite.FundAcc(testAccount, testutil.DefaultAcctFunds) | ||
suite.FundAcc(testAccount, sdk.NewCoins(tc.accountBalanceToFund)) | ||
|
||
oldBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, "adym").Amount | ||
|
||
// System under test. | ||
err = incentivesKeepers.ChargeFeeIfSufficientFeeDenomBalance(ctx, testAccount, sdk.NewInt(tc.feeToCharge), tc.gaugeCoins) | ||
|
||
// Assertions. | ||
newBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, "adym").Amount | ||
if tc.expectError { | ||
suite.Require().Error(err) | ||
|
||
// check account balance unchanged | ||
suite.Require().Equal(oldBalanceAmount, newBalanceAmount) | ||
} else { | ||
suite.Require().NoError(err) | ||
|
||
// check account balance changed. | ||
expectedNewBalanceAmount := oldBalanceAmount.Sub(sdk.NewInt(tc.feeToCharge)) | ||
suite.Require().Equal(expectedNewBalanceAmount.String(), newBalanceAmount.String()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we not skip frozen rollapps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer not.
It doesn't really matter, as this gaguge won't be active for frozen rollapp, but it breaks the assumption of
rollapp gauge for each rollapp