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

Commit c151a27

Browse files
committed
Merge branch 'master' into erc20
2 parents 06256e9 + ce1c135 commit c151a27

36 files changed

+270
-214
lines changed

core/order.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ func (n *OpenBazaarNode) CalculateOrderTotal(contract *pb.RicardianContract) (*b
997997
// calculate base amount
998998
if nrl.GetContractType() == pb.Listing_Metadata_CRYPTOCURRENCY.String() &&
999999
nrl.GetFormat() == pb.Listing_Metadata_MARKET_PRICE.String() {
1000-
var originDef = repo.NewUnknownCryptoDefinition(nrl.GetCryptoCurrencyCode(), 0)
1000+
var originDef = repo.NewUnknownCryptoDefinition(nrl.GetCryptoCurrencyCode(), uint(nrl.GetCryptoDivisibility()))
10011001
itemOriginAmt = repo.NewCurrencyValueFromBigInt(GetOrderQuantity(nrl.GetProtobuf(), item), originDef)
10021002

10031003
if priceModifier := nrl.GetPriceModifier(); priceModifier != 0 {

core/order_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ func TestOpenBazaarNode_CalculateOrderTotal(t *testing.T) {
167167
}
168168
contract.VendorListings[0].Coupons = []*pb.Listing_Coupon{
169169
{
170-
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
171-
Title: "coup",
172-
PercentDiscount: 10,
170+
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
171+
Title: "coup",
172+
Discount: &pb.Listing_Coupon_PercentDiscount{PercentDiscount: 10},
173173
},
174174
}
175175

@@ -198,9 +198,9 @@ func TestOpenBazaarNode_CalculateOrderTotal(t *testing.T) {
198198
}
199199
contract.VendorListings[0].Coupons = []*pb.Listing_Coupon{
200200
{
201-
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
202-
Title: "coup",
203-
BigPriceDiscount: "6000",
201+
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
202+
Title: "coup",
203+
Discount: &pb.Listing_Coupon_BigPriceDiscount{BigPriceDiscount: "6000"},
204204
},
205205
}
206206

@@ -452,9 +452,9 @@ func TestOpenBazaarNode_CalculateOrderTotalWithV4Schema(t *testing.T) {
452452
}
453453
v4Contract.VendorListings[0].Coupons = []*pb.Listing_Coupon{
454454
{
455-
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
456-
Title: "coup",
457-
PercentDiscount: 10,
455+
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
456+
Title: "coup",
457+
Discount: &pb.Listing_Coupon_PercentDiscount{PercentDiscount: 10},
458458
},
459459
}
460460

@@ -483,9 +483,9 @@ func TestOpenBazaarNode_CalculateOrderTotalWithV4Schema(t *testing.T) {
483483
}
484484
v4Contract.VendorListings[0].Coupons = []*pb.Listing_Coupon{
485485
{
486-
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
487-
Title: "coup",
488-
PriceDiscount: 6000,
486+
Code: &pb.Listing_Coupon_Hash{Hash: couponHash.B58String()},
487+
Title: "coup",
488+
Discount: &pb.Listing_Coupon_BigPriceDiscount{BigPriceDiscount: "6000"},
489489
},
490490
}
491491

@@ -503,8 +503,8 @@ func TestOpenBazaarNode_CalculateOrderTotalWithV4Schema(t *testing.T) {
503503
if err != nil {
504504
t.Error(err)
505505
}
506-
if total.Int64() != 69000 {
507-
t.Errorf("Calculated wrong order total. Wanted 69000, got %d", total.Int64())
506+
if total.Int64() != 75000 {
507+
t.Errorf("Calculated wrong order total. Wanted 75000, got %d", total.Int64())
508508
}
509509

510510
// Test with tax no tax shipping
@@ -529,8 +529,8 @@ func TestOpenBazaarNode_CalculateOrderTotalWithV4Schema(t *testing.T) {
529529
if err != nil {
530530
t.Error(err)
531531
}
532-
if total.Int64() != 71200 {
533-
t.Errorf("Calculated wrong order total. Wanted 71200, got %d", total.Int64())
532+
if total.Int64() != 77500 {
533+
t.Errorf("Calculated wrong order total. Wanted 77500, got %d", total.Int64())
534534
}
535535

536536
// Test with tax with tax shipping
@@ -555,8 +555,8 @@ func TestOpenBazaarNode_CalculateOrderTotalWithV4Schema(t *testing.T) {
555555
if err != nil {
556556
t.Error(err)
557557
}
558-
if total.Int64() != 72450 {
559-
t.Fatalf("Calculated wrong order total. Wanted 72450, got %d", total.Int64())
558+
if total.Int64() != 78750 {
559+
t.Fatalf("Calculated wrong order total. Wanted 78750, got %d", total.Int64())
560560
}
561561

562562
// Test local pickup
@@ -575,8 +575,8 @@ func TestOpenBazaarNode_CalculateOrderTotalWithV4Schema(t *testing.T) {
575575
if err != nil {
576576
t.Error(err)
577577
}
578-
if total.Int64() != 46200 {
579-
t.Errorf("Calculated wrong order total. Wanted 46200, got %d", total.Int64())
578+
if total.Int64() != 52500 {
579+
t.Errorf("Calculated wrong order total. Wanted 52500, got %d", total.Int64())
580580
}
581581
}
582582

qa/eth_cancel_direct_offline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def run_test(self):
2929
time.sleep(20)
3030

3131
# post profile for alice
32-
with open('testdata/profile.json') as profile_file:
32+
with open('testdata/v5/profile.json') as profile_file:
3333
profile_json = json.load(profile_file, object_pairs_hook=OrderedDict)
3434
api_url = alice["gateway_url"] + "ob/profile"
3535
requests.post(api_url, data=json.dumps(profile_json, indent=4))
3636

3737
# post listing to alice
38-
with open('testdata/eth_listing.json') as listing_file:
38+
with open('testdata/v5/eth_listing.json') as listing_file:
3939
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
4040
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
4141
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
@@ -66,7 +66,7 @@ def run_test(self):
6666
time.sleep(4)
6767

6868
# bob send order
69-
with open('testdata/order_direct.json') as order_file:
69+
with open('testdata/v5/order_direct.json') as order_file:
7070
order_json = json.load(order_file, object_pairs_hook=OrderedDict)
7171
order_json["items"][0]["listingHash"] = listingId
7272
order_json["paymentCoin"] = "T" + self.cointype

qa/eth_complete_direct_online.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ def run_test(self):
3232
time.sleep(20)
3333

3434
# post profile for alice
35-
with open('testdata/profile.json') as profile_file:
35+
with open('testdata/v5/profile.json') as profile_file:
3636
profile_json = json.load(profile_file, object_pairs_hook=OrderedDict)
3737
api_url = alice["gateway_url"] + "ob/profile"
3838
requests.post(api_url, data=json.dumps(profile_json, indent=4))
3939

4040
# post listing to alice
41-
with open('testdata/eth_listing.json') as listing_file:
41+
with open('testdata/v5/eth_listing.json') as listing_file:
4242
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
4343
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
4444
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
@@ -67,7 +67,7 @@ def run_test(self):
6767
time.sleep(36000)
6868

6969
# bob send order
70-
with open('testdata/order_direct.json') as order_file:
70+
with open('testdata/v5/order_direct.json') as order_file:
7171
order_json = json.load(order_file, object_pairs_hook=OrderedDict)
7272
order_json["items"][0]["listingHash"] = listingId
7373
order_json["paymentCoin"] = "T" + self.cointype
@@ -149,7 +149,7 @@ def run_test(self):
149149
raise TestFailure("EthCompleteDirectOnlineTest - FAIL: Alice incorrectly saved as unfunded")
150150

151151
# alice send order fulfillment
152-
with open('testdata/fulfillment.json') as fulfillment_file:
152+
with open('testdata/v5/fulfillment.json') as fulfillment_file:
153153
fulfillment_json = json.load(fulfillment_file, object_pairs_hook=OrderedDict)
154154
fulfillment_json["orderId"] = orderId
155155
fulfillment_json["slug"] = slug

qa/eth_complete_disputed.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_test(self):
4141
time.sleep(4)
4242

4343
# make charlie a moderator
44-
with open('testdata/moderation.json') as listing_file:
44+
with open('testdata/v5/moderation.json') as listing_file:
4545
moderation_json = json.load(listing_file, object_pairs_hook=OrderedDict)
4646
api_url = charlie["gateway_url"] + "ob/moderator"
4747
r = requests.put(api_url, data=json.dumps(moderation_json, indent=4))
@@ -54,13 +54,13 @@ def run_test(self):
5454
time.sleep(4)
5555

5656
# post profile for alice
57-
with open('testdata/profile.json') as profile_file:
57+
with open('testdata/v5/profile.json') as profile_file:
5858
profile_json = json.load(profile_file, object_pairs_hook=OrderedDict)
5959
api_url = alice["gateway_url"] + "ob/profile"
6060
requests.post(api_url, data=json.dumps(profile_json, indent=4))
6161

6262
# post listing to alice
63-
with open('testdata/eth_listing.json') as listing_file:
63+
with open('testdata/v5/eth_listing.json') as listing_file:
6464
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
6565
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
6666
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
@@ -85,7 +85,7 @@ def run_test(self):
8585
listingId = resp[0]["hash"]
8686

8787
# bob send order
88-
with open('testdata/order_direct.json') as order_file:
88+
with open('testdata/v5/order_direct.json') as order_file:
8989
order_json = json.load(order_file, object_pairs_hook=OrderedDict)
9090
order_json["items"][0]["listingHash"] = listingId
9191
order_json["moderator"] = moderatorId
@@ -166,7 +166,7 @@ def run_test(self):
166166
raise TestFailure("EthCompleteDisputedTest - FAIL: Alice incorrectly saved as unfunded")
167167

168168
# alice send order fulfillment
169-
with open('testdata/fulfillment.json') as fulfillment_file:
169+
with open('testdata/v5/fulfillment.json') as fulfillment_file:
170170
fulfillment_json = json.load(fulfillment_file, object_pairs_hook=OrderedDict)
171171
fulfillment_json["orderId"] = orderId
172172
fulfillment_json["slug"] = slug

qa/eth_complete_moderated_online.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_test(self):
4141
time.sleep(4)
4242

4343
# make charlie a moderator
44-
with open('testdata/moderation.json') as listing_file:
44+
with open('testdata/v5/moderation.json') as listing_file:
4545
moderation_json = json.load(listing_file, object_pairs_hook=OrderedDict)
4646
api_url = charlie["gateway_url"] + "ob/moderator"
4747
r = requests.put(api_url, data=json.dumps(moderation_json, indent=4))
@@ -54,13 +54,13 @@ def run_test(self):
5454
time.sleep(4)
5555

5656
# post profile for alice
57-
with open('testdata/profile.json') as profile_file:
57+
with open('testdata/v5/profile.json') as profile_file:
5858
profile_json = json.load(profile_file, object_pairs_hook=OrderedDict)
5959
api_url = alice["gateway_url"] + "ob/profile"
6060
requests.post(api_url, data=json.dumps(profile_json, indent=4))
6161

6262
# post listing to alice
63-
with open('testdata/eth_listing.json') as listing_file:
63+
with open('testdata/v5/eth_listing.json') as listing_file:
6464
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
6565
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
6666
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
@@ -86,7 +86,7 @@ def run_test(self):
8686
listingId = resp[0]["hash"]
8787

8888
# bob send order
89-
with open('testdata/order_direct.json') as order_file:
89+
with open('testdata/v5/order_direct.json') as order_file:
9090
order_json = json.load(order_file, object_pairs_hook=OrderedDict)
9191
order_json["items"][0]["listingHash"] = listingId
9292
order_json["moderator"] = moderatorId
@@ -167,7 +167,7 @@ def run_test(self):
167167
raise TestFailure("EthCompleteModeratedOnlineTest - FAIL: Alice incorrectly saved as unfunded")
168168

169169
# alice send order fulfillment
170-
with open('testdata/fulfillment.json') as fulfillment_file:
170+
with open('testdata/v5/fulfillment.json') as fulfillment_file:
171171
fulfillment_json = json.load(fulfillment_file, object_pairs_hook=OrderedDict)
172172
fulfillment_json["slug"] = slug
173173
fulfillment_json["orderId"] = orderId
@@ -199,7 +199,7 @@ def run_test(self):
199199
raise TestFailure("EthCompleteModeratedOnlineTest - FAIL: Alice failed to order fulfillment")
200200

201201
# bob send order completion
202-
with open('testdata/completion.json') as completion_file:
202+
with open('testdata/v5/completion.json') as completion_file:
203203
completion_json = json.load(completion_file, object_pairs_hook=OrderedDict)
204204
completion_json["orderId"] = orderId
205205
completion_json["ratings"][0]["slug"] = slug

qa/eth_complete_moderated_with_timeout.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_test(self):
4141
time.sleep(4)
4242

4343
# make charlie a moderator
44-
with open('testdata/moderation.json') as listing_file:
44+
with open('testdata/v5/moderation.json') as listing_file:
4545
moderation_json = json.load(listing_file, object_pairs_hook=OrderedDict)
4646
api_url = charlie["gateway_url"] + "ob/moderator"
4747
r = requests.put(api_url, data=json.dumps(moderation_json, indent=4))
@@ -54,13 +54,13 @@ def run_test(self):
5454
time.sleep(4)
5555

5656
# post profile for alice
57-
with open('testdata/profile.json') as profile_file:
57+
with open('testdata/v5/profile.json') as profile_file:
5858
profile_json = json.load(profile_file, object_pairs_hook=OrderedDict)
5959
api_url = alice["gateway_url"] + "ob/profile"
6060
requests.post(api_url, data=json.dumps(profile_json, indent=4))
6161

6262
# post listing to alice
63-
with open('testdata/eth_listing.json') as listing_file:
63+
with open('testdata/v5/eth_listing.json') as listing_file:
6464
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
6565
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
6666
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
@@ -87,7 +87,7 @@ def run_test(self):
8787
listingId = resp[0]["hash"]
8888

8989
# bob send order
90-
with open('testdata/order_direct.json') as order_file:
90+
with open('testdata/v5/order_direct.json') as order_file:
9191
order_json = json.load(order_file, object_pairs_hook=OrderedDict)
9292
order_json["items"][0]["listingHash"] = listingId
9393
order_json["moderator"] = moderatorId
@@ -168,7 +168,7 @@ def run_test(self):
168168
raise TestFailure("EthCompleteModeratedWithTimeout - FAIL: Alice incorrectly saved as unfunded")
169169

170170
# alice send order fulfillment
171-
with open('testdata/fulfillment.json') as fulfillment_file:
171+
with open('testdata/v5/fulfillment.json') as fulfillment_file:
172172
fulfillment_json = json.load(fulfillment_file, object_pairs_hook=OrderedDict)
173173
fulfillment_json["slug"] = slug
174174
fulfillment_json["orderId"] = orderId
@@ -200,7 +200,7 @@ def run_test(self):
200200
raise TestFailure("EthCompleteModeratedWithTimeout - FAIL: Alice failed to order fulfillment")
201201

202202
# bob send order completion
203-
with open('testdata/completion.json') as completion_file:
203+
with open('testdata/v5/completion.json') as completion_file:
204204
completion_json = json.load(completion_file, object_pairs_hook=OrderedDict)
205205
completion_json["orderId"] = orderId
206206
completion_json["ratings"][0]["slug"] = slug

qa/eth_dispute_close_buyer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def run_test(self):
3939
time.sleep(4)
4040

4141
# make charlie a moderator
42-
with open('testdata/moderation.json') as listing_file:
42+
with open('testdata/v5/moderation.json') as listing_file:
4343
moderation_json = json.load(listing_file, object_pairs_hook=OrderedDict)
4444
api_url = charlie["gateway_url"] + "ob/moderator"
4545
r = requests.put(api_url, data=json.dumps(moderation_json, indent=4))
@@ -52,13 +52,13 @@ def run_test(self):
5252
time.sleep(4)
5353

5454
# post profile for alice
55-
with open('testdata/profile.json') as profile_file:
55+
with open('testdata/v5/profile.json') as profile_file:
5656
profile_json = json.load(profile_file, object_pairs_hook=OrderedDict)
5757
api_url = alice["gateway_url"] + "ob/profile"
5858
requests.post(api_url, data=json.dumps(profile_json, indent=4))
5959

6060
# post listing to alice
61-
with open('testdata/eth_listing.json') as listing_file:
61+
with open('testdata/v5/eth_listing.json') as listing_file:
6262
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
6363
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
6464
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
@@ -82,7 +82,7 @@ def run_test(self):
8282
listingId = resp[0]["hash"]
8383

8484
# bob send order
85-
with open('testdata/order_direct.json') as order_file:
85+
with open('testdata/v5/order_direct.json') as order_file:
8686
order_json = json.load(order_file, object_pairs_hook=OrderedDict)
8787
order_json["items"][0]["listingHash"] = listingId
8888
order_json["moderator"] = moderatorId

qa/eth_dispute_close_split.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run_test(self):
4242
time.sleep(4)
4343

4444
# make charlie a moderator
45-
with open('testdata/moderation.json') as listing_file:
45+
with open('testdata/v5/moderation.json') as listing_file:
4646
moderation_json = json.load(listing_file, object_pairs_hook=OrderedDict)
4747
api_url = charlie["gateway_url"] + "ob/moderator"
4848
r = requests.put(api_url, data=json.dumps(moderation_json, indent=4))
@@ -55,13 +55,13 @@ def run_test(self):
5555
time.sleep(40)
5656

5757
# post profile for alice
58-
with open('testdata/profile.json') as profile_file:
58+
with open('testdata/v5/profile.json') as profile_file:
5959
profile_json = json.load(profile_file, object_pairs_hook=OrderedDict)
6060
api_url = alice["gateway_url"] + "ob/profile"
6161
requests.post(api_url, data=json.dumps(profile_json, indent=4))
6262

6363
# post listing to alice
64-
with open('testdata/eth_listing.json') as listing_file:
64+
with open('testdata/v5/eth_listing.json') as listing_file:
6565
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
6666
listing_json["item"]["priceCurrency"]["code"] = "T" + self.cointype
6767
listing_json["metadata"]["acceptedCurrencies"] = ["T" + self.cointype]
@@ -85,7 +85,7 @@ def run_test(self):
8585
listingId = resp[0]["hash"]
8686

8787
# bob send order
88-
with open('testdata/order_direct.json') as order_file:
88+
with open('testdata/v5/order_direct.json') as order_file:
8989
order_json = json.load(order_file, object_pairs_hook=OrderedDict)
9090
order_json["items"][0]["listingHash"] = listingId
9191
order_json["moderator"] = moderatorId

0 commit comments

Comments
 (0)