Skip to content

Commit

Permalink
Switch to back to "stake" denomination (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejfitzgerald authored May 22, 2020
1 parent 6125544 commit 30cfd3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions types/dec_coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ func (coin DecCoin) IsValid() bool {
// DecCoins defines a slice of coins with decimal values
type DecCoins []DecCoin

func CollectDecCoins(coins ... DecCoin) (output DecCoins) {
for _, coin := range coins {
output = append(output, coin)
}
output.Sort()
return
}

// NewDecCoins constructs a new coin set with decimal values
// from regular Coins.
func NewDecCoins(coins Coins) DecCoins {
Expand Down
2 changes: 1 addition & 1 deletion types/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
const (

// default bond denomination
DefaultBondDenom = "ufet"
DefaultBondDenom = "stake"

// Delay, in blocks, between when validator updates are returned to the
// consensus-engine and when they are applied. For example, if
Expand Down
8 changes: 4 additions & 4 deletions x/distribution/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ func TestSetWithdrawAddr(t *testing.T) {
func TestWithdrawValidatorCommission(t *testing.T) {
ctx, ak, keeper, _, _ := CreateTestInputDefault(t, false, 1000)

valCommission := sdk.DecCoins{
valCommission := sdk.CollectDecCoins(
sdk.NewDecCoinFromDec("mytoken", sdk.NewDec(5).Quo(sdk.NewDec(4))),
sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(3).Quo(sdk.NewDec(2))),
}
)

// set module account coins
distrAcc := keeper.GetDistributionAccount(ctx)
Expand Down Expand Up @@ -65,10 +65,10 @@ func TestWithdrawValidatorCommission(t *testing.T) {

// check remainder
remainder := keeper.GetValidatorAccumulatedCommission(ctx, valOpAddr3)
require.Equal(t, sdk.DecCoins{
require.Equal(t, sdk.CollectDecCoins(
sdk.NewDecCoinFromDec("mytoken", sdk.NewDec(1).Quo(sdk.NewDec(4))),
sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(1).Quo(sdk.NewDec(2))),
}, remainder)
), remainder)

require.True(t, true)
}
Expand Down

0 comments on commit 30cfd3d

Please sign in to comment.