Skip to content

Commit

Permalink
fix comment and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 committed Nov 12, 2024
1 parent 3f99312 commit c183c94
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
116 changes: 58 additions & 58 deletions x/incentives/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,103 +29,103 @@ func (suite *KeeperTestSuite) TestCreateGauge() {
}{
{
name: "user creates a non-perpetual gauge and fills gauge with all remaining tokens",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(60)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(6)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))),
},
{
name: "user creates a non-perpetual gauge and fills gauge with some remaining tokens",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(70)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))),
},
{
name: "user with multiple denoms creates a non-perpetual gauge and fills gauge with some remaining tokens",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(70))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(7)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))),
},
{
name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees",
name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees - 1",
accountBalanceToFund: sdk.NewCoins(
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(40))), // 40 >= 20 (adym) + 10 (creation fee) + 10 (for every denom) = 40
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(40))), // 40 >= 2 (adym) + 1 (creation fee) + 1 (for every denom) = 4
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))),
),
gaugeAddition: sdk.NewCoins(
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))),
),
},
{
name: "module account creates a perpetual gauge and fills gauge with some remaining tokens",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(70))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))),
isPerpetual: true,
isModuleAccount: true,
},
{
name: "user with multiple denoms creates a perpetual gauge and fills gauge with some remaining tokens",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(70))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))),
isPerpetual: true,
},
{
name: "user tries to create a non-perpetual gauge but does not have enough funds to pay for the create gauge fee",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(5)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(5))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1))),
expectErr: true,
},
{
name: "user tries to create a non-perpetual gauge but does not have the correct fee denom",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(60)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(10)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(6)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(1)))),
expectErr: true,
},
{
name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees",
name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees - 2",
accountBalanceToFund: sdk.NewCoins(
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(39))), // 39 < 20 (adym) + 10 (creation fee) + 10 (for every denom) = 40
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(3))), // 3 < 2 (adym) + 1 (creation fee) + 1 (for every denom) = 4
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))),
),
gaugeAddition: sdk.NewCoins(
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))),
sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))),
sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))),
),
expectErr: true,
},
{
name: "one user tries to create a gauge, has enough funds to pay for the create gauge fee but not enough to fill the gauge",
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(20)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(30)))),
accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(2)))),
gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(3)))),
expectErr: true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion x/incentives/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var (
// DYM represents 1 DYM
DYM = math.NewIntWithDecimal(1, 18)

DefaultCreateGaugeFee = DYM.MulRaw(1) // 10 DYM
DefaultCreateGaugeFee = DYM.MulRaw(1) // 1 DYM
DefaultAddToGaugeFee = math.ZeroInt() // 0 DYM
DefaultAddDenomFee = DYM // 1 DYM
)
Expand Down

0 comments on commit c183c94

Please sign in to comment.