diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-16 17:03:07 -0400 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2020-07-16 17:03:07 -0400 |
commit | 6c04f551883da165fa90ae830ebd56642abca361 (patch) | |
tree | 694e835ff494786fa778a6534d70671ce1309f3c | |
parent | 90adbb36f71224fe4ae8ebace1bc091c4651734f (diff) |
fix #6430
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders-ID.c | 11 | ||||
-rw-r--r-- | src/testing/test_merchant_api.c | 4 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_post_orders.c | 56 |
3 files changed, 33 insertions, 38 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index 87408fe5..de5cb980 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -825,6 +825,14 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, hc->infix, &gorc->contract_terms, &gorc->order_serial); + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + /* We don't have contract terms, but the order may still exist. */ + qs = TMH_db->lookup_order (TMH_db->cls, + hc->instance->settings.id, + hc->infix, + &gorc->contract_terms); + } if (0 > qs) { /* single, read-only SQL statements should never cause @@ -906,7 +914,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, gorc->session_id, &paid, &wired); - if (0 >= qs) + if (0 > qs) { /* single, read-only SQL statements should never cause serialization problems, and the entry should exist as per above */ @@ -916,6 +924,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, TALER_EC_GET_ORDERS_DB_FETCH_PAYMENT_STATUS, "DB error fetching payment status"); } + /* qs == 0: the order hasn't been claimed, but this is okay. */ if ((! paid) && (NULL != gorc->session_id)) { diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 2d9e9266..1a074240 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -189,6 +189,10 @@ run (void *cls, false, false, MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_purge_instance ("purge-default", + merchant_url, + "default", + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_end () }; diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c index 8ae0babc..6195d99c 100644 --- a/src/testing/testing_api_cmd_post_orders.c +++ b/src/testing/testing_api_cmd_post_orders.c @@ -119,7 +119,6 @@ struct OrdersState }; - /** * Offer internal data to other commands. * @@ -538,46 +537,29 @@ make_order_json (const char *order_id, const char *amount, char **order) { - struct GNUNET_TIME_Absolute refund_deadline_round = refund_deadline; - char rd_str[64]; - - struct GNUNET_TIME_Absolute pay_deadline_round = pay_deadline; - char pd_str[64]; + struct GNUNET_TIME_Absolute refund = refund_deadline; + struct GNUNET_TIME_Absolute pay = pay_deadline; - GNUNET_TIME_round_abs (&refund_deadline_round); - GNUNET_TIME_round_abs (&pay_deadline_round); + json_t *contract_terms; - GNUNET_snprintf (rd_str, - 64, - "{\"t_ms\":%llu}", - refund_deadline_round.abs_value_us / 1000LL); - if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == pay_deadline.abs_value_us) - { - GNUNET_snprintf (pd_str, - 64, - "{\"t_ms\":\"never\"}"); - } - else - { - GNUNET_snprintf (pd_str, - 64, - "{\"t_ms\":%llu}", - pay_deadline_round.abs_value_us / 1000LL); - } - GNUNET_asprintf (order, - "{\"max_fee\":\"EUR:0.5\",\ - \"order_id\":\"%s\",\ - \"refund_deadline\":%s,\ - \"pay_deadline\":%s,\ - \"amount\":\"%s\",\ - \"summary\":\"merchant-lib testcase\",\ - \"fulfillment_url\":\"https://example.com/\"}", - order_id, - rd_str, - pd_str, - amount); + GNUNET_TIME_round_abs (&refund); + GNUNET_TIME_round_abs (&pay); + + contract_terms = json_pack ( + "{s:s, s:s, s:s, s:s, s:o, s:o}", + "summary", "merchant-lib testcase", + "order_id", order_id, + "amount", amount, + "fulfillment_url", "https://example.com", + "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), + "pay_deadline", GNUNET_JSON_from_time_abs (pay_deadline) + ); + + *order = json_dumps (contract_terms, 0); + json_decref (contract_terms); } + /** * Make the "proposal" command AVOIDING claiming the order. * |