Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into robert/auction-msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Mar 28, 2024
2 parents 3f5d854 + 1be3ed5 commit aceead9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
with:
fetch-depth: 0
# lint only changed files
- uses: tj-actions/changed-files@v43
- uses: tj-actions/changed-files@v44
id: changed-files
with:
files: "**/*.md"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
if: env.GIT_DIFF
run: |
EXPERIMENTAL=true make test-unit-cover
- uses: codecov/[email protected].0
- uses: codecov/[email protected].1
if: env.GIT_DIFF
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
10 changes: 7 additions & 3 deletions util/coin/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import (
const umee = appparams.BondDenom

// common coins used in tests
//
//revive:disable:var-naming
var (
// the uToken denom "u/uumee"
UumeeDenom = ToUTokenDenom(umee)
UmeeDenom = umee
// the uToken denom "u/uumee"
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 @@ -38,6 +40,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 aceead9

Please sign in to comment.