Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit d76213e

Browse files
authored
Merge pull request #1852 from OpenBazaar/zeroquantity
(#1844) Allow crypto currency listings with quantity of zero
2 parents 6b229b9 + 938b8bc commit d76213e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

api/jsonapi_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ func TestCryptoListingsQuantity(t *testing.T) {
512512
"POST", "/ob/listing", jsonFor(t, listing), 200, `{"slug": "crypto"}`,
513513
})
514514

515-
listing.Item.Skus[0].BigQuantity = "0"
515+
listing.Item.Skus[0].BigQuantity = "-1"
516516
runAPITest(t, apiTest{
517517
"POST", "/ob/listing", jsonFor(t, listing), 500, errorResponseJSON(repo.ErrCryptocurrencySkuQuantityInvalid),
518518
})

repo/listing.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,10 +2204,10 @@ func validateCryptocurrencyQuantity(listing *pb.Listing) error {
22042204
return fmt.Errorf("cannot validate nil sku")
22052205
}
22062206
if s.BigQuantity == "" {
2207-
return fmt.Errorf("sku bigQuantity empty")
2207+
return fmt.Errorf("sku quantity empty")
22082208
}
2209-
if ba, ok := new(big.Int).SetString(s.BigQuantity, 10); ok && ba.Cmp(big.NewInt(0)) <= 0 {
2210-
return fmt.Errorf("sku bigQuantity zero or less")
2209+
if ba, ok := new(big.Int).SetString(s.BigQuantity, 10); ok && ba.Cmp(big.NewInt(0)) < 0 {
2210+
return fmt.Errorf("sku quantity cannot be negative")
22112211
}
22122212
return nil
22132213
}

0 commit comments

Comments
 (0)