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

Commit bd6707c

Browse files
committed
Update qa tests with v4 fixes
1 parent cffc9c8 commit bd6707c

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

core/order.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ func processOfflineDirectOrder(n *OpenBazaarNode, wal wallet.Wallet, contract *p
460460
}
461461

462462
func processOnlineModeratedOrder(resp *pb.Message, n *OpenBazaarNode, contract *pb.RicardianContract) (string, string, big.Int, bool, error) {
463+
v5Order, err := repo.ToV5Order(contract.BuyerOrder, nil)
464+
if err != nil {
465+
return "", "", *big.NewInt(0), false, err
466+
}
463467
// Vendor responded
464468
if resp.MessageType == pb.Message_ERROR {
465469
return "", "", *big.NewInt(0), false, extractErrorMessage(resp)
@@ -468,7 +472,7 @@ func processOnlineModeratedOrder(resp *pb.Message, n *OpenBazaarNode, contract *
468472
return "", "", *big.NewInt(0), false, errors.New("vendor responded to the order with an incorrect message type")
469473
}
470474
rc := new(pb.RicardianContract)
471-
err := proto.Unmarshal(resp.Payload.Value, rc)
475+
err = proto.Unmarshal(resp.Payload.Value, rc)
472476
if err != nil {
473477
return "", "", *big.NewInt(0), false, errors.New("error parsing the vendor's response")
474478
}
@@ -493,14 +497,18 @@ func processOnlineModeratedOrder(resp *pb.Message, n *OpenBazaarNode, contract *
493497
if err != nil {
494498
return "", "", *big.NewInt(0), false, err
495499
}
496-
total, ok := new(big.Int).SetString(contract.BuyerOrder.Payment.BigAmount, 10)
500+
total, ok := new(big.Int).SetString(v5Order.Payment.BigAmount, 10)
497501
if !ok {
498502
return "", "", *big.NewInt(0), false, errors.New("invalid payment amount")
499503
}
500504
return orderID, contract.VendorOrderConfirmation.PaymentAddress, *total, true, nil
501505
}
502506

503507
func processOfflineModeratedOrder(n *OpenBazaarNode, contract *pb.RicardianContract) (string, string, big.Int, error) {
508+
v5Order, err := repo.ToV5Order(contract.BuyerOrder, nil)
509+
if err != nil {
510+
return "", "", *big.NewInt(0), err
511+
}
504512
// Vendor offline
505513
// Send using offline messaging
506514
log.Warningf("Vendor %s is offline, sending offline order message", contract.VendorListings[0].VendorID.PeerID)
@@ -532,11 +540,11 @@ func processOfflineModeratedOrder(n *OpenBazaarNode, contract *pb.RicardianContr
532540
if err != nil {
533541
log.Error(err)
534542
}
535-
total, ok := new(big.Int).SetString(contract.BuyerOrder.Payment.BigAmount, 10)
543+
total, ok := new(big.Int).SetString(v5Order.Payment.BigAmount, 10)
536544
if !ok {
537545
return "", "", *big.NewInt(0), errors.New("invalid payment amount")
538546
}
539-
return orderID, contract.BuyerOrder.Payment.Address, *total, err
547+
return orderID, v5Order.Payment.Address, *total, err
540548
}
541549

542550
func extractErrorMessage(m *pb.Message) error {

qa/complete_moderated_online.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def run_test(self):
6363
# post listing to alice
6464
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
6565
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
66-
if self.vendor_version == 4:
66+
if self.vendor_version == "v4":
6767
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
6868
else:
6969
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
@@ -138,7 +138,7 @@ def run_test(self):
138138
"feeLevel": "NORMAL",
139139
"requireAssociateOrder": False
140140
}
141-
if self.buyer_version == 4:
141+
if self.buyer_version == "v4":
142142
spend["amount"] = payment_amount
143143
spend["wallet"] = "T" + self.cointype
144144

qa/listings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def run_test(self):
3535
# POST listing
3636
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
3737
ljson = json.load(listing_file, object_pairs_hook=OrderedDict)
38-
if self.vendor_version == 4:
38+
if self.vendor_version == "v4":
3939
ljson["metadata"]["priceCurrency"] = "t" + self.cointype
4040
else:
4141
ljson["item"]["priceCurrency"]["code"] = "t" + self.cointype

qa/reject_direct_offline.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def run_test(self):
3838
# post listing to alice
3939
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
4040
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
41-
if self.vendor_version == 4:
41+
if self.vendor_version == "v4":
4242
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
4343
else:
4444
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
@@ -108,7 +108,7 @@ def run_test(self):
108108
"feeLevel": "NORMAL",
109109
"requireAssociateOrder": False
110110
}
111-
if self.buyer_version == 4:
111+
if self.buyer_version == "v4":
112112
spend["amount"] = payment_amount
113113
spend["wallet"] = "T" + self.cointype
114114

@@ -149,10 +149,12 @@ def run_test(self):
149149
}
150150
r = requests.post(api_url, data=json.dumps(oc, indent=4))
151151
if r.status_code == 404:
152+
print(r.text, r.status_code)
152153
raise TestFailure("RejectDirectOfflineTest - FAIL: Order confirmation post endpoint not found")
153154
elif r.status_code != 200:
154155
resp = json.loads(r.text)
155156
raise TestFailure("RejectDirectOfflineTest - FAIL: OrderConfirmation POST failed. Reason: %s", resp["reason"])
157+
156158
time.sleep(20)
157159

158160
# alice check order rejected correctly

qa/smtp_notification.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ def run_test(self):
7979
# post listing to alice
8080
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
8181
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
82-
if self.vendor_version == 4:
82+
if self.vendor_version == "v4":
8383
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
8484
else:
8585
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
86+
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
8687

8788
api_url = alice["gateway_url"] + "ob/listing"
8889
r = requests.post(api_url, data=json.dumps(listing_json, indent=4))
@@ -126,7 +127,7 @@ def run_test(self):
126127
"feeLevel": "NORMAL",
127128
"requireAssociateOrder": False
128129
}
129-
if self.buyer_version == 4:
130+
if self.buyer_version == "v4":
130131
spend["amount"] = payment_amount
131132
spend["wallet"] = "T" + self.cointype
132133

qa/upload_listing.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ def setup_network(self):
1616
def run_test(self):
1717
with open('testdata/'+ self.vendor_version +'/listing.json') as listing_file:
1818
listing_json = json.load(listing_file, object_pairs_hook=OrderedDict)
19-
if self.vendor_version == 4:
19+
if self.vendor_version == "v4":
2020
listing_json["metadata"]["priceCurrency"] = "t" + self.cointype
2121
else:
2222
listing_json["item"]["priceCurrency"]["code"] = "t" + self.cointype
23-
listing_json["item"]["priceCurrency"]["divisibility"] = 8
23+
listing_json["item"]["priceCurrency"]["divisibility"] = 8
24+
listing_json["metadata"]["acceptedCurrencies"] = ["t" + self.cointype]
2425
api_url = self.nodes[1]["gateway_url"] + "ob/listing"
2526
r = requests.post(api_url, data=json.dumps(listing_json, indent=4))
2627
if r.status_code == 404:
@@ -35,7 +36,7 @@ def run_test(self):
3536
inv = resp["ron-swanson-tshirt"]
3637
if inv == None:
3738
raise TestFailure("UploadListingTest - FAIL: Did not return inventory for listing")
38-
if inv["inventory"] != "213":
39+
if int(inv["inventory"]) != 213:
3940
raise TestFailure("UploadListingTest - FAIL: Returned incorrect amount of inventory: %d", inv["inventory"])
4041
elif r.status_code == 404:
4142
raise TestFailure("UploadListingTest - FAIL: Listing post endpoint not found")

0 commit comments

Comments
 (0)