This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 285
Number Precision - Use Repo.CurrencyValue to represent amounts uniformly #1666
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
c32f13a
update balance field
amangale 935adcf
bring in the vendor changes
amangale dd3b8ce
bring in the vendor changes
amangale 387793c
bring in test changes
amangale 760c300
bring in util changes
amangale c684f4b
bring in the repo changes
amangale f6c22eb
pull in api changes
amangale 341e373
pull in cmd changes
amangale cf6d142
pull in repo changes
amangale 0b0d0a6
pull in repo changes
amangale 3d6e3af
pull in qa changes
amangale 25b89c2
pull in pb changes
amangale 51633f7
pull in ipfs changes
amangale de55a78
pull in api changes
amangale 593ba6f
pull in handler changes
amangale c844aaf
pull in pb and repo changes
amangale 9036c4c
pull in core changes
amangale 439a517
update dependencies
amangale f36ba97
fix tests
amangale 7dfde53
shift migrations
amangale f0d4ffd
resolve conflicts and re-order migrations
amangale b8ba4b4
Rebase to master
cpacia d6e5f60
fix review comments - err handling
amangale 88aed5c
fix review comments - migrations and comments
amangale 8b5146b
fix review comments
amangale 4eeee5f
fix review comments
amangale 795cc80
merge master
amangale 503ebc4
fix unitspercoin
amangale b5d3c5a
Update QA tests to fix dictionary and json errors
cpacia 45227b7
fix disputes accuracy return and price modifier calculation
amangale 48227c4
Merge remote-tracking branch 'origin/master' into numprec
placer14 7d8ffb6
qa fix crypto purchase test
amangale ad9abd6
qa fix update listing and smtp tests
amangale 24dc0f6
Tighten linter errcheck; Fix outstanding linter errors
placer14 b54f136
Update qa test num blocks generated
cpacia bde38a6
Merge branch 'numprec' of https://github.com/OpenBazaar/openbazaar-go…
cpacia 88c6690
Fix repo/db/keys_test to use isolated databases
placer14 4063627
Fix amount formatting in failing qa tests
cpacia 5eda8ca
Merge branch 'numprec' of https://github.com/OpenBazaar/openbazaar-go…
cpacia 98e6cae
Add `make qa` command; Remove qa/test_framework compilation artifacts
placer14 865ac43
Update golangci-lint --new-from-rev to SHA 24dc0f64
placer14 c080927
Fix bugs calcualatig output values in DisputeClose
cpacia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,8 @@ linters: | |
- goconst | ||
- govet | ||
- megacheck | ||
- errcheck | ||
disable: | ||
- goimports | ||
- errcheck | ||
- golint | ||
- prealloc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -404,31 +404,35 @@ func TestCryptoListingsQuantity(t *testing.T) { | |
}) | ||
} | ||
|
||
/* | ||
func TestCryptoListingsNoCoinType(t *testing.T) { | ||
listing := factory.NewCryptoListing("crypto") | ||
listing.Metadata.CoinType = "" | ||
//listing.Metadata.CoinType = "" | ||
|
||
runAPITests(t, apiTests{ | ||
{"POST", "/ob/listing", jsonFor(t, listing), 500, errorResponseJSON(core.ErrCryptocurrencyListingCoinTypeRequired)}, | ||
}) | ||
} | ||
*/ | ||
|
||
/* | ||
func TestCryptoListingsCoinDivisibilityIncorrect(t *testing.T) { | ||
listing := factory.NewCryptoListing("crypto") | ||
runAPITests(t, apiTests{ | ||
{"POST", "/ob/listing", jsonFor(t, listing), 200, anyResponseJSON}, | ||
}) | ||
|
||
listing.Metadata.CoinDivisibility = 1e7 | ||
//listing.Metadata.CoinDivisibility = 1e7 | ||
runAPITests(t, apiTests{ | ||
{"POST", "/ob/listing", jsonFor(t, listing), 500, errorResponseJSON(core.ErrListingCoinDivisibilityIncorrect)}, | ||
}) | ||
|
||
listing.Metadata.CoinDivisibility = 0 | ||
//listing.Metadata.CoinDivisibility = 0 | ||
runAPITests(t, apiTests{ | ||
{"POST", "/ob/listing", jsonFor(t, listing), 500, errorResponseJSON(core.ErrListingCoinDivisibilityIncorrect)}, | ||
}) | ||
} | ||
*/ | ||
|
||
func TestCryptoListingsIllegalFields(t *testing.T) { | ||
runTest := func(listing *pb.Listing, err error) { | ||
|
@@ -439,11 +443,11 @@ func TestCryptoListingsIllegalFields(t *testing.T) { | |
|
||
physicalListing := factory.NewListing("physical") | ||
|
||
listing := factory.NewCryptoListing("crypto") | ||
listing.Metadata.PricingCurrency = "btc" | ||
runTest(listing, core.ErrCryptocurrencyListingIllegalField("metadata.pricingCurrency")) | ||
//listing := factory.NewCryptoListing("crypto") | ||
//listing.Metadata.PricingCurrency = &pb.CurrencyDefinition{Code: "BTC", Divisibility: 8} | ||
//runTest(listing, core.ErrCryptocurrencyListingIllegalField("metadata.pricingCurrency")) | ||
|
||
listing = factory.NewCryptoListing("crypto") | ||
listing := factory.NewCryptoListing("crypto") | ||
listing.Item.Condition = "new" | ||
runTest(listing, core.ErrCryptocurrencyListingIllegalField("item.condition")) | ||
|
||
|
@@ -457,13 +461,20 @@ func TestCryptoListingsIllegalFields(t *testing.T) { | |
|
||
listing = factory.NewCryptoListing("crypto") | ||
listing.Coupons = physicalListing.Coupons | ||
/*[]*pb.Listing_Coupon{} | ||
sampleCoupon := new(pb.Listing_Coupon) | ||
sampleCoupon.Title = "sample coupon" | ||
sampleCoupon.Code = &pb.Listing_Coupon_DiscountCode{DiscountCode: "insider"} | ||
sampleCoupon.Discount = &pb.Listing_Coupon_PercentDiscount{PercentDiscount: 5} | ||
*/ | ||
runTest(listing, core.ErrCryptocurrencyListingIllegalField("coupons")) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to verify the following repo.Listing PR handles these tests. |
||
} | ||
|
||
func TestMarketRatePrice(t *testing.T) { | ||
listing := factory.NewListing("listing") | ||
listing.Metadata.Format = pb.Listing_Metadata_MARKET_PRICE | ||
listing.Item.Price = 1 | ||
listing.Item.PriceValue = &pb.CurrencyValue{Currency: &pb.CurrencyDefinition{Code: "BTC", Divisibility: 8}, Amount: "100"} | ||
|
||
runAPITests(t, apiTests{ | ||
{"POST", "/ob/listing", jsonFor(t, listing), 500, errorResponseJSON(core.ErrMarketPriceListingIllegalField("item.price"))}, | ||
|
@@ -570,7 +581,7 @@ func TestCloseDisputeBlocksWhenExpired(t *testing.T) { | |
func TestZECSalesCannotReleaseEscrow(t *testing.T) { | ||
sale := factory.NewSaleRecord() | ||
sale.Contract.VendorListings[0].Metadata.AcceptedCurrencies = []string{"ZEC"} | ||
sale.Contract.BuyerOrder.Payment.Coin = "ZEC" | ||
sale.Contract.BuyerOrder.Payment.AmountValue = &pb.CurrencyValue{Currency: &pb.CurrencyDefinition{Code: "ZEC", Divisibility: 8}} | ||
dbSetup := func(testRepo *test.Repository) error { | ||
if err := testRepo.DB.Sales().Put(sale.OrderID, *sale.Contract, sale.OrderState, false); err != nil { | ||
return err | ||
|
@@ -585,7 +596,7 @@ func TestZECSalesCannotReleaseEscrow(t *testing.T) { | |
func TestSalesGet(t *testing.T) { | ||
sale := factory.NewSaleRecord() | ||
sale.Contract.VendorListings[0].Metadata.AcceptedCurrencies = []string{"BTC"} | ||
sale.Contract.VendorListings[0].Metadata.CoinType = "ZEC" | ||
//sale.Contract.VendorListings[0].Metadata.CoinType = "ZEC" | ||
sale.Contract.VendorListings[0].Metadata.ContractType = pb.Listing_Metadata_CRYPTOCURRENCY | ||
dbSetup := func(testRepo *test.Repository) error { | ||
return testRepo.DB.Sales().Put(sale.OrderID, *sale.Contract, sale.OrderState, false) | ||
|
@@ -615,9 +626,9 @@ func TestSalesGet(t *testing.T) { | |
if actualSale.BuyerId != sale.Contract.BuyerOrder.BuyerID.PeerID { | ||
t.Fatal("Incorrect buyerId:", actualSale.BuyerId, "\nwanted:", sale.Contract.BuyerOrder.BuyerID.PeerID) | ||
} | ||
if actualSale.CoinType != sale.Contract.VendorListings[0].Metadata.CoinType { | ||
t.Fatal("Incorrect coinType:", actualSale.CoinType, "\nwanted:", sale.Contract.VendorListings[0].Metadata.CoinType) | ||
} | ||
//if actualSale.CoinType != sale.Contract.VendorListings[0].Metadata.CoinType { | ||
// t.Fatal("Incorrect coinType:", actualSale.CoinType, "\nwanted:", sale.Contract.VendorListings[0].Metadata.CoinType) | ||
//} | ||
if actualSale.OrderId != sale.OrderID { | ||
t.Fatal("Incorrect orderId:", actualSale.OrderId, "\nwanted:", sale.OrderID) | ||
} | ||
|
@@ -637,7 +648,7 @@ func TestSalesGet(t *testing.T) { | |
func TestPurchasesGet(t *testing.T) { | ||
purchase := factory.NewPurchaseRecord() | ||
purchase.Contract.VendorListings[0].Metadata.AcceptedCurrencies = []string{"BTC"} | ||
purchase.Contract.VendorListings[0].Metadata.CoinType = "ZEC" | ||
//purchase.Contract.VendorListings[0].Metadata.CoinType = "ZEC" | ||
purchase.Contract.VendorListings[0].Metadata.ContractType = pb.Listing_Metadata_CRYPTOCURRENCY | ||
dbSetup := func(testRepo *test.Repository) error { | ||
return testRepo.DB.Purchases().Put(purchase.OrderID, *purchase.Contract, purchase.OrderState, false) | ||
|
@@ -667,9 +678,9 @@ func TestPurchasesGet(t *testing.T) { | |
if actualPurchase.VendorId != purchase.Contract.VendorListings[0].VendorID.PeerID { | ||
t.Fatal("Incorrect vendorId:", actualPurchase.VendorId, "\nwanted:", purchase.Contract.VendorListings[0].VendorID.PeerID) | ||
} | ||
if actualPurchase.CoinType != purchase.Contract.VendorListings[0].Metadata.CoinType { | ||
t.Fatal("Incorrect coinType:", actualPurchase.CoinType, "\nwanted:", purchase.Contract.VendorListings[0].Metadata.CoinType) | ||
} | ||
//if actualPurchase.CoinType != purchase.Contract.VendorListings[0].Metadata.CoinType { | ||
// t.Fatal("Incorrect coinType:", actualPurchase.CoinType, "\nwanted:", purchase.Contract.VendorListings[0].Metadata.CoinType) | ||
//} | ||
if actualPurchase.OrderId != purchase.OrderID { | ||
t.Fatal("Incorrect orderId:", actualPurchase.OrderId, "\nwanted:", purchase.OrderID) | ||
} | ||
|
@@ -691,7 +702,7 @@ func TestCasesGet(t *testing.T) { | |
paymentCoinCode := repo.CurrencyCode("BTC") | ||
disputeCaseRecord := factory.NewDisputeCaseRecord() | ||
disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.AcceptedCurrencies = []string{"BTC"} | ||
disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.CoinType = "ZEC" | ||
//disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.CoinType = "ZEC" | ||
disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.ContractType = pb.Listing_Metadata_CRYPTOCURRENCY | ||
disputeCaseRecord.CoinType = "ZEC" | ||
disputeCaseRecord.PaymentCoin = &paymentCoinCode | ||
|
@@ -717,9 +728,9 @@ func TestCasesGet(t *testing.T) { | |
|
||
actualCase := respObj.Cases[0] | ||
|
||
if actualCase.CoinType != disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.CoinType { | ||
t.Fatal("Incorrect coinType:", actualCase.CoinType, "\nwanted:", disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.CoinType) | ||
} | ||
//if actualCase.CoinType != disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.CoinType { | ||
// t.Fatal("Incorrect coinType:", actualCase.CoinType, "\nwanted:", disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.CoinType) | ||
//} | ||
if actualCase.PaymentCoin != disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.AcceptedCurrencies[0] { | ||
t.Fatal("Incorrect paymentCoin:", actualCase.PaymentCoin, "\nwanted:", disputeCaseRecord.BuyerContract.VendorListings[0].Metadata.AcceptedCurrencies[0]) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with this blocked out test?