Merge PR #3522: get rid of double negatives: IsNotNegative -> IsAnyNegative
This commit is contained in:
parent
17c84ab34a
commit
b63b6254c8
2
Makefile
2
Makefile
|
@ -198,7 +198,7 @@ test_sim_gaia_profile:
|
|||
-SimulationEnabled=true -SimulationNumBlocks=$(SIM_NUM_BLOCKS) -SimulationBlockSize=$(SIM_BLOCK_SIZE) -SimulationCommit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out
|
||||
|
||||
test_cover:
|
||||
@export VERSION=$(VERSION); bash tests/test_cover.sh
|
||||
@export VERSION=$(VERSION); bash -x tests/test_cover.sh
|
||||
|
||||
test_lint:
|
||||
gometalinter --config=tools/gometalinter.json ./...
|
||||
|
|
|
@ -30,6 +30,7 @@ BREAKING CHANGES
|
|||
* [\#3514](https://github.com/cosmos/cosmos-sdk/pull/3514) Various clean ups:
|
||||
- Replace all GetKeyBase* functions family in favor of NewKeyBaseFromDir and NewKeyBaseFromHomeFlag.
|
||||
- Remove Get prefix from all TxBuilder's getters.
|
||||
* [\#3522](https://github.com/cosmos/cosmos-sdk/pull/3522) Get rid of double negatives: Coins.IsNotNegative() -> Coins.IsAnyNegative().
|
||||
|
||||
* Tendermint
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ func handleFrom(store sdk.KVStore, from sdk.AccAddress, amt sdk.Coins) sdk.Resul
|
|||
senderCoins := acc.Coins.Minus(amt)
|
||||
|
||||
// If any coin has negative amount, return insufficient coins error.
|
||||
if !senderCoins.IsNotNegative() {
|
||||
if senderCoins.IsAnyNegative() {
|
||||
return sdk.ErrInsufficientCoins("Insufficient coins in account").Result()
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ PKGS=$(go list ./... | grep -v /vendor/ | grep -v github.com/cosmos/cosmos-sdk/c
|
|||
|
||||
set -e
|
||||
echo "mode: atomic" > coverage.txt
|
||||
for pkg in ${PKGS[@]}; do
|
||||
for pkg in ${PKGS}; do
|
||||
go test -v -timeout 30m -race -coverprofile=profile.out -covermode=atomic "$pkg"
|
||||
if [ -f profile.out ]; then
|
||||
tail -n +2 profile.out >> coverage.txt;
|
||||
|
|
|
@ -262,7 +262,7 @@ func (coins Coins) Minus(coinsB Coins) Coins {
|
|||
// negative coin amount was returned.
|
||||
func (coins Coins) SafeMinus(coinsB Coins) (Coins, bool) {
|
||||
diff := coins.safePlus(coinsB.negative())
|
||||
return diff, !diff.IsNotNegative()
|
||||
return diff, diff.IsAnyNegative()
|
||||
}
|
||||
|
||||
// IsAllGT returns true if for every denom in coins, the denom is present at a
|
||||
|
@ -284,7 +284,7 @@ func (coins Coins) IsAllGTE(coinsB Coins) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
return diff.IsNotNegative()
|
||||
return !diff.IsAnyNegative()
|
||||
}
|
||||
|
||||
// IsAllLT returns True iff for every denom in coins, the denom is present at
|
||||
|
@ -380,22 +380,22 @@ func (coins Coins) IsPositive() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// IsNotNegative returns true if there is no coin amount with a negative value
|
||||
// (even no coins is true here).
|
||||
//
|
||||
// IsAnyNegative returns true if there is at least one coin whose amount
|
||||
// is negative; returns false otherwise. It returns false if the coin set
|
||||
// is empty too.
|
||||
// TODO: Remove once unsigned integers are used.
|
||||
func (coins Coins) IsNotNegative() bool {
|
||||
func (coins Coins) IsAnyNegative() bool {
|
||||
if len(coins) == 0 {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
for _, coin := range coins {
|
||||
if coin.IsNegative() {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
// negative returns a set of coins with all amount negative.
|
||||
|
|
|
@ -46,7 +46,7 @@ func (tx StdTx) ValidateBasic() sdk.Error {
|
|||
if tx.Fee.Gas > maxGasWanted {
|
||||
return sdk.ErrGasOverflow(fmt.Sprintf("invalid gas supplied; %d > %d", tx.Fee.Gas, maxGasWanted))
|
||||
}
|
||||
if !tx.Fee.Amount.IsNotNegative() {
|
||||
if tx.Fee.Amount.IsAnyNegative() {
|
||||
return sdk.ErrInsufficientFee(fmt.Sprintf("invalid fee %s amount provided", tx.Fee.Amount))
|
||||
}
|
||||
if len(stdSigs) == 0 {
|
||||
|
|
|
@ -258,7 +258,7 @@ func addCoins(ctx sdk.Context, am auth.AccountKeeper, addr sdk.AccAddress, amt s
|
|||
oldCoins := getCoins(ctx, am, addr)
|
||||
newCoins := oldCoins.Plus(amt)
|
||||
|
||||
if !newCoins.IsNotNegative() {
|
||||
if newCoins.IsAnyNegative() {
|
||||
return amt, nil, sdk.ErrInsufficientCoins(fmt.Sprintf("%s < %s", oldCoins, amt))
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ func NonnegativeBalanceInvariant(mapper auth.AccountKeeper) simulation.Invariant
|
|||
accts := mock.GetAllAccounts(mapper, ctx)
|
||||
for _, acc := range accts {
|
||||
coins := acc.GetCoins()
|
||||
if !coins.IsNotNegative() {
|
||||
if coins.IsAnyNegative() {
|
||||
return fmt.Errorf("%s has a negative denomination of %s",
|
||||
acc.GetAddress().String(),
|
||||
coins.String())
|
||||
|
|
|
@ -65,7 +65,7 @@ func (msg MsgSubmitProposal) ValidateBasic() sdk.Error {
|
|||
if !msg.InitialDeposit.IsValid() {
|
||||
return sdk.ErrInvalidCoins(msg.InitialDeposit.String())
|
||||
}
|
||||
if !msg.InitialDeposit.IsNotNegative() {
|
||||
if msg.InitialDeposit.IsAnyNegative() {
|
||||
return sdk.ErrInvalidCoins(msg.InitialDeposit.String())
|
||||
}
|
||||
return nil
|
||||
|
@ -120,7 +120,7 @@ func (msg MsgDeposit) ValidateBasic() sdk.Error {
|
|||
if !msg.Amount.IsValid() {
|
||||
return sdk.ErrInvalidCoins(msg.Amount.String())
|
||||
}
|
||||
if !msg.Amount.IsNotNegative() {
|
||||
if msg.Amount.IsAnyNegative() {
|
||||
return sdk.ErrInvalidCoins(msg.Amount.String())
|
||||
}
|
||||
if msg.ProposalID < 0 {
|
||||
|
|
Loading…
Reference in New Issue