Skip to content

Commit

Permalink
update msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Mar 27, 2024
1 parent 8b8158f commit 3f5d854
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions util/coin/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const umee = appparams.BondDenom
var (
// the uToken denom "u/uumee"
UumeeDenom = ToUTokenDenom(umee)
UmeeDenom = umee
// 1uumee Coin
Umee1 = New(umee, 1)
// 10_000uumee Coin
Expand Down
8 changes: 7 additions & 1 deletion x/auction/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"errors"

sdk "github.com/cosmos/cosmos-sdk/types"

appparams "github.com/umee-network/umee/v6/app/params"
"github.com/umee-network/umee/v6/util/checkers"
)

Expand Down Expand Up @@ -43,7 +45,11 @@ func (msg *MsgGovSetRewardsParams) GetSignBytes() []byte {
func (msg *MsgRewardsBid) ValidateBasic() error {
errs := checkers.ValidateAddr(msg.Sender, "sender")
errs = errors.Join(errs, checkers.NumberPositive(msg.Id, "auction ID"))
return errors.Join(errs, checkers.BigNumPositive(msg.Amount, "bid_amount"))
errs = errors.Join(errs, checkers.BigNumPositive(msg.Amount.Amount, "bid_amount"))
if msg.Amount.Denom != appparams.BondDenom {
errs = errors.Join(errs, errors.New("bid amount must be in "+appparams.BondDenom))
}
return errs
}

func (msg *MsgRewardsBid) GetSigners() []sdk.AccAddress {
Expand Down
15 changes: 10 additions & 5 deletions x/auction/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/umee-network/umee/v6/tests/accs"
"github.com/umee-network/umee/v6/tests/tcheckers"
"github.com/umee-network/umee/v6/util/checkers"
"github.com/umee-network/umee/v6/util/coin"
)

func TestMsgGovSetRewardsParams(t *testing.T) {
Expand Down Expand Up @@ -46,16 +47,19 @@ func TestMsgRewardsBid(t *testing.T) {
validMsg := MsgRewardsBid{
Sender: accs.Alice.String(),
Id: 12,
Amount: sdk.NewInt(123),
Amount: coin.Umee10k,
}

invalid := validMsg
invalid.Sender = "not a valid acc"
invalid.Id = 0
invalid.Amount = sdk.ZeroInt()
invalid.Amount.Amount = sdk.ZeroInt()

invalidAmount := validMsg
invalidAmount.Amount = sdk.NewInt(-100)
invalidAmount1 := validMsg
invalidAmount1.Amount.Amount = sdk.NewInt(-100)

invalidDenom := validMsg
invalidDenom.Amount.Denom = "other"

tcs := []struct {
name string
Expand All @@ -66,7 +70,8 @@ func TestMsgRewardsBid(t *testing.T) {
{"invalid sender", invalid, "sender"},
{"invalid ID", invalid, "auction ID"},
{"amount zero", invalid, "bid_amount: must be positive"},
{"amount negative", invalidAmount, "bid_amount: must be positive"},
{"amount negative", invalidAmount1, "bid_amount: must be positive"},
{"wrong denom", invalidDenom, "bid amount must be in " + coin.UmeeDenom},
}
for _, tc := range tcs {
tcheckers.ErrorContains(t, tc.msg.ValidateBasic(), tc.errMsg, tc.name)
Expand Down

0 comments on commit 3f5d854

Please sign in to comment.