Skip to content

Commit

Permalink
chore(coin): update u/umee sample coin names
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Mar 28, 2024
1 parent 920b379 commit 98a83c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
8 changes: 6 additions & 2 deletions util/coin/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import (
const umee = appparams.BondDenom

// common coins used in tests
//
//revive:disable:var-naming
var (
// the uToken denom "u/uumee"
UumeeDenom = ToUTokenDenom(umee)
U_umee = ToUTokenDenom(umee) //nolint:stylecheck
// 1uumee Coin
Umee1 = New(umee, 1)
// 10_000uumee Coin
Umee10k = New(umee, 10_000)
// 1u/uumee Coin
UUmee1 = Utoken(umee, 1)
U_umee1 = Utoken(umee, 1) //nolint:stylecheck

// Xuumee DecCoin
Umee0dec = DecF(umee, 0)
Expand All @@ -37,6 +39,8 @@ var (
Dollar = "dollar"
)

//revive:enable:var-naming

// UmeeCoins creates an Umee (uumee) sdk.Coins with given amount
func UmeeCoins(amount int64) sdk.Coins {
return sdk.NewCoins(sdk.NewInt64Coin(umee, amount))
Expand Down
32 changes: 16 additions & 16 deletions x/incentive/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestValidateGenesis(t *testing.T) {

rt := RewardTracker{
Account: validAddr,
UToken: coin.UumeeDenom,
UToken: coin.U_umee,
Rewards: sdk.NewDecCoins(),
}
duplicateRewardTracker := DefaultGenesis()
Expand All @@ -50,15 +50,15 @@ func TestValidateGenesis(t *testing.T) {
assert.ErrorContains(t, invalidRewardAccumulator.Validate(), "invalid denom")

ra := RewardAccumulator{
UToken: coin.UumeeDenom,
UToken: coin.U_umee,
Rewards: sdk.NewDecCoins(),
}
duplicateRewardAccumulator := DefaultGenesis()
duplicateRewardAccumulator.RewardAccumulators = []RewardAccumulator{ra, ra}
assert.ErrorContains(t, duplicateRewardAccumulator.Validate(), "duplicate reward accumulators")

invalidProgram := IncentiveProgram{}
validProgram := NewIncentiveProgram(1, 1, 1, coin.UumeeDenom, coin.Umee1, coin.Zero(uumee), false)
validProgram := NewIncentiveProgram(1, 1, 1, coin.U_umee, coin.Umee1, coin.Zero(uumee), false)

invalidUpcomingProgram := DefaultGenesis()
invalidUpcomingProgram.UpcomingPrograms = []IncentiveProgram{invalidProgram}
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestValidateGenesis(t *testing.T) {

b := Bond{
Account: validAddr,
UToken: sdk.NewInt64Coin(coin.UumeeDenom, 1),
UToken: sdk.NewInt64Coin(coin.U_umee, 1),
}

duplicateBond := DefaultGenesis()
Expand All @@ -105,7 +105,7 @@ func TestValidateGenesis(t *testing.T) {

au := AccountUnbondings{
Account: validAddr,
UToken: coin.UumeeDenom,
UToken: coin.U_umee,
Unbondings: []Unbonding{},
}
duplicateAccountUnbonding := DefaultGenesis()
Expand All @@ -116,7 +116,7 @@ func TestValidateGenesis(t *testing.T) {
func TestValidateIncentiveProgram(t *testing.T) {
t.Parallel()

validProgram := NewIncentiveProgram(1, 1, 1, coin.UumeeDenom, coin.Umee1, coin.Zero(uumee), false)
validProgram := NewIncentiveProgram(1, 1, 1, coin.U_umee, coin.Umee1, coin.Zero(uumee), false)
assert.NilError(t, validProgram.Validate())

invalidUToken := validProgram
Expand All @@ -130,7 +130,7 @@ func TestValidateIncentiveProgram(t *testing.T) {
invalidTotalRewards.TotalRewards = sdk.Coin{}
assert.ErrorContains(t, invalidTotalRewards.Validate(), "invalid denom")

invalidTotalRewards.TotalRewards = coin.New(coin.UumeeDenom, 100)
invalidTotalRewards.TotalRewards = coin.New(coin.U_umee, 100)
assert.ErrorIs(t, invalidTotalRewards.Validate(), leveragetypes.ErrUToken)

invalidTotalRewards.TotalRewards = coin.Zero(uumee)
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestValidateIncentiveProgram(t *testing.T) {

func TestValidateStructs(t *testing.T) {
validAddr := "umee1s84d29zk3k20xk9f0hvczkax90l9t94g72n6wm"
validBond := NewBond(validAddr, coin.New(coin.UumeeDenom, 1))
validBond := NewBond(validAddr, coin.New(coin.U_umee, 1))
assert.NilError(t, validBond.Validate())

invalidBond := validBond
Expand All @@ -196,7 +196,7 @@ func TestValidateStructs(t *testing.T) {
invalidBond.UToken.Denom = uumee
assert.ErrorIs(t, invalidBond.Validate(), leveragetypes.ErrNotUToken)

validTracker := NewRewardTracker(validAddr, coin.UumeeDenom, sdk.NewDecCoins(
validTracker := NewRewardTracker(validAddr, coin.U_umee, sdk.NewDecCoins(
sdk.NewDecCoin(uumee, sdk.OneInt()),
))
assert.NilError(t, validTracker.Validate())
Expand All @@ -217,10 +217,10 @@ func TestValidateStructs(t *testing.T) {
assert.ErrorContains(t, invalidTracker.Validate(), "invalid denom")

invalidTracker = validTracker
invalidTracker.Rewards[0].Denom = coin.UumeeDenom
invalidTracker.Rewards[0].Denom = coin.U_umee
assert.ErrorIs(t, invalidTracker.Validate(), leveragetypes.ErrUToken)

validAccumulator := NewRewardAccumulator(coin.UumeeDenom, 6, sdk.NewDecCoins(
validAccumulator := NewRewardAccumulator(coin.U_umee, 6, sdk.NewDecCoins(
sdk.NewDecCoin(uumee, sdk.OneInt()),
))
assert.NilError(t, validAccumulator.Validate())
Expand All @@ -237,10 +237,10 @@ func TestValidateStructs(t *testing.T) {
assert.ErrorContains(t, invalidAccumulator.Validate(), "invalid denom")

invalidAccumulator = validAccumulator
invalidAccumulator.Rewards[0].Denom = coin.UumeeDenom
invalidAccumulator.Rewards[0].Denom = coin.U_umee
assert.ErrorIs(t, invalidAccumulator.Validate(), leveragetypes.ErrUToken)

validUnbonding := NewUnbonding(1, 1, coin.New(coin.UumeeDenom, 1))
validUnbonding := NewUnbonding(1, 1, coin.New(coin.U_umee, 1))
assert.NilError(t, validUnbonding.Validate())

invalidUnbonding := validUnbonding
Expand All @@ -252,10 +252,10 @@ func TestValidateStructs(t *testing.T) {
assert.ErrorIs(t, invalidUnbonding.Validate(), leveragetypes.ErrNotUToken)

invalidUnbonding = validUnbonding
invalidUnbonding.UToken = sdk.Coin{Denom: coin.UumeeDenom, Amount: sdk.NewInt(-1)}
invalidUnbonding.UToken = sdk.Coin{Denom: coin.U_umee, Amount: sdk.NewInt(-1)}
assert.ErrorContains(t, invalidUnbonding.Validate(), "negative coin amount")

validAccountUnbondings := NewAccountUnbondings(validAddr, coin.UumeeDenom, []Unbonding{validUnbonding})
validAccountUnbondings := NewAccountUnbondings(validAddr, coin.U_umee, []Unbonding{validUnbonding})
assert.NilError(t, validAccountUnbondings.Validate())

invalidAccountUnbondings := validAccountUnbondings
Expand All @@ -280,6 +280,6 @@ func TestValidateStructs(t *testing.T) {
invalidAccountUnbondings.Unbondings[0] = validUnbonding // the value in validAccountUnbondings was modified

invalidAccountUnbondings = validAccountUnbondings
invalidAccountUnbondings.Unbondings[0].UToken = sdk.Coin{Denom: coin.UumeeDenom, Amount: sdk.NewInt(-1)}
invalidAccountUnbondings.Unbondings[0].UToken = sdk.Coin{Denom: coin.U_umee, Amount: sdk.NewInt(-1)}
assert.ErrorContains(t, invalidAccountUnbondings.Validate(), "negative coin amount")
}
2 changes: 1 addition & 1 deletion x/incentive/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (

var (
testAddr, _ = sdk.AccAddressFromBech32("umee1s84d29zk3k20xk9f0hvczkax90l9t94g72n6wm")
uToken = sdk.NewInt64Coin(coin.UumeeDenom, 10)
uToken = sdk.NewInt64Coin(coin.U_umee, 10)
token = sdk.NewInt64Coin(uumee, 10)
program = incentive.NewIncentiveProgram(0, 4, 5, uToken.Denom, token, coin.Zero(token.Denom), false)
)
Expand Down

0 comments on commit 98a83c4

Please sign in to comment.