From 6c04f551883da165fa90ae830ebd56642abca361 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Thu, 16 Jul 2020 17:03:07 -0400 Subject: fix #6430 --- src/testing/test_merchant_api.c | 4 +++ src/testing/testing_api_cmd_post_orders.c | 56 +++++++++++-------------------- 2 files changed, 23 insertions(+), 37 deletions(-) (limited to 'src/testing') 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. * -- cgit v1.2.3