Skip to content

Commit

Permalink
Merge pull request #1002 from iov-one/allow_empty_req_fee_1001
Browse files Browse the repository at this point in the history
Let AntispamFeeDecorator handle empty product fee
  • Loading branch information
alpe authored Sep 26, 2019
2 parents 140a9b2 + cf5c922 commit de864ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## HEAD

## 0.21.1
- Let AntispamFeeDecorator handle empty product fee.
## 0.21.0
- `x/batch`: increase maximum number of messages to 15
- `cmd/bnscli`: a new command `mnemonic` was added for generating a random
Expand Down
3 changes: 2 additions & 1 deletion x/msgfee/antispam_fee_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func (d *AntispamFeeDecorator) Check(ctx weave.Context, store weave.KVStore, tx
return nil, err
}
if res.RequiredFee.IsZero() {
return nil, errors.Wrap(errors.ErrEmpty, "required must not be zero")
res.RequiredFee = d.fee
return res, nil
}
if !res.RequiredFee.SameType(d.fee) {
return nil, errors.Wrapf(errors.ErrCurrency,
Expand Down
7 changes: 7 additions & 0 deletions x/msgfee/antispam_fee_decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ func TestNewAntispamFeeDecorator(t *testing.T) {
AntiSpamFee: coin.NewCoin(0, 1235, "GATO"),
WantCheckErr: errors.ErrCurrency,
},
"Product fee can be empty": {
ReqFee: coin.Coin{},
Handler: &weavetest.Handler{},
Tx: &weavetest.Tx{Msg: &weavetest.Msg{RoutePath: "foo/bar"}},
AntiSpamFee: coin.NewCoin(0, 1, "DOGE"),
WantCheckFee: coin.NewCoin(0, 1, "DOGE"),
},
"deliver err propagates": {
ReqFee: coin.NewCoin(0, 1234, "DOGE"),
Handler: &weavetest.Handler{},
Expand Down

0 comments on commit de864ca

Please sign in to comment.