summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_post_orders.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_post_orders.c')
-rw-r--r--src/testing/testing_api_cmd_post_orders.c56
1 files changed, 19 insertions, 37 deletions
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.
*