gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: clean up testing post orders cmd


From: gnunet
Subject: [taler-merchant] branch master updated: clean up testing post orders cmd
Date: Sun, 12 Jul 2020 01:56:56 +0200

This is an automated email from the git hooks/post-receive script.

jonathan-buchanan pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new ecb3a2a  clean up testing post orders cmd
ecb3a2a is described below

commit ecb3a2afa27257816b34e4e959d98424ef123033
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Sat Jul 11 19:55:28 2020 -0400

    clean up testing post orders cmd
---
 src/include/taler_merchant_testing_lib.h      |  25 ++++-
 src/merchant-tools/taler-merchant-benchmark.c |  75 +++-----------
 src/testing/test_merchant_api.c               | 143 ++++++++------------------
 src/testing/test_merchant_api_twisted.c       |  50 +++------
 src/testing/testing_api_cmd_post_orders.c     | 101 ++++++++++++++++--
 5 files changed, 187 insertions(+), 207 deletions(-)

diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index 89f4530..d545306 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -474,15 +474,22 @@ TALER_TESTING_cmd_merchant_delete_product (const char 
*label,
  * @param merchant_url base URL of the merchant serving
  *        the proposal request.
  * @param http_status expected HTTP status.
- * @param order the order to PUT to the merchant.
- *
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
  * @return the command
  */
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_merchant_post_orders (const char *label,
                                         const char *merchant_url,
                                         unsigned int http_status,
-                                        const char *order);
+                                        const char *order_id,
+                                        struct GNUNET_TIME_Absolute
+                                        refund_deadline,
+                                        struct GNUNET_TIME_Absolute
+                                        pay_deadline,
+                                        const char *amount);
 
 
 /**
@@ -492,7 +499,10 @@ TALER_TESTING_cmd_merchant_post_orders (const char *label,
  * @param merchant_url base URL of the merchant serving
  *        the proposal request.
  * @param http_status expected HTTP status.
- * @param order the order to PUT to the merchant.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
  * @param payment_target payment target for the order.
  * @param products a string indicating the products this order will be
  *        purchasing. Should be formatted as
@@ -505,7 +515,12 @@ struct TALER_TESTING_Command
 TALER_TESTING_cmd_merchant_post_orders2 (const char *label,
                                          const char *merchant_url,
                                          unsigned int http_status,
-                                         const char *order,
+                                         const char *order_id,
+                                         struct GNUNET_TIME_Absolute
+                                         refund_deadline,
+                                         struct GNUNET_TIME_Absolute
+                                         pay_deadline,
+                                         const char *amount,
                                          const char *payment_target,
                                          const char *products,
                                          const char *locks);
diff --git a/src/merchant-tools/taler-merchant-benchmark.c 
b/src/merchant-tools/taler-merchant-benchmark.c
index e410927..b86f78a 100644
--- a/src/merchant-tools/taler-merchant-benchmark.c
+++ b/src/merchant-tools/taler-merchant-benchmark.c
@@ -141,10 +141,6 @@ run (void *cls,
   char CURRENCY_4_99[MAX_AMOUNT_LEN];
   char CURRENCY_0_02[MAX_AMOUNT_LEN];
   char CURRENCY_0_01[MAX_AMOUNT_LEN];
-  char order_worth_5[MAX_ORDER_LEN];
-  char order_worth_5_track[MAX_ORDER_LEN];
-  char order_worth_5_unaggregated[MAX_ORDER_LEN];
-  char order_worth_10_2coins[MAX_ORDER_LEN];
 
   GNUNET_snprintf (CURRENCY_10_02,
                    sizeof (CURRENCY_10_02),
@@ -178,57 +174,6 @@ run (void *cls,
                    sizeof (CURRENCY_0_01),
                    "%s:0.01",
                    currency);
-  GNUNET_snprintf (order_worth_5,
-                   sizeof (order_worth_5),
-                   "{\"max_fee\": {\"currency\":\"%s\", \"value\":0, 
\"fraction\":50000000},"
-                   "\"refund_deadline\":\"\\/Date(0)\\/\","
-                   "\"pay_deadline\":\"\\/Date(99999999999)\\/\","
-                   "\"amount\": {\"currency\":\"%s\", \"value\":5, 
\"fraction\":0},"
-                   "\"summary\": \"merchant-lib testcase\","
-                   "\"fulfillment_url\": \"https://example.com/\",";
-                   "\"products\": [ {\"description\":\"ice cream\", 
\"value\":\"{%s:5}\"} ] }",
-                   currency,
-                   currency,
-                   currency);
-  GNUNET_snprintf (order_worth_5_track,
-                   sizeof (order_worth_5_track),
-                   "{\"max_fee\": {\"currency\":\"%s\", \"value\":0, 
\"fraction\":50000000},"
-                   "\"refund_deadline\":\"\\/Date(0)\\/\","
-                   "\"pay_deadline\":\"\\/Date(99999999999)\\/\","
-                   "\"amount\": {\"currency\":\"%s\", \"value\":5, 
\"fraction\":0},"
-                   "\"summary\": \"ice track cream!\","
-                   "\"fulfillment_url\": \"https://example.com/\",";
-                   "\"products\": [ {\"description\":\"ice track cream\", 
\"value\":\"{%s:5}\"} ] }",
-                   currency,
-                   currency,
-                   currency);
-  GNUNET_snprintf (order_worth_5_unaggregated,
-                   sizeof (order_worth_5_unaggregated),
-                   "{\"max_fee\": {\"currency\":\"%s\", \"value\":0, 
\"fraction\":50000000},"
-                   "\"wire_transfer_delay\":\"\\/Delay(30000)\\/\","
-                   "\"refund_deadline\":\"\\/Date(22)\\/\","
-                   "\"pay_deadline\":\"\\/Date(1)\\/\","
-                   "\"amount\": {\"currency\":\"%s\", \"value\":5, 
\"fraction\":0},"
-                   "\"summary\": \"unaggregated deposit!\","
-                   "\"fulfillment_url\": \"https://example.com/\",";
-                   "\"products\": [ {\"description\":\"unaggregated cream\","
-                   "\"value\":\"{%s:5}\"} ] }",
-                   currency,
-                   currency,
-                   currency);
-  GNUNET_snprintf (order_worth_10_2coins,
-                   sizeof (order_worth_10_2coins),
-                   "{\"max_fee\": {\"currency\":\"%s\", \"value\":0, 
\"fraction\":50000000},"
-                   "\"refund_deadline\":\"\\/Date(0)\\/\","
-                   "\"pay_deadline\":\"\\/Date(99999999999)\\/\","
-                   "\"amount\": {\"currency\":\"%s\",\"value\":10, 
\"fraction\":0},"
-                   "\"summary\": \"2-coins payment\","
-                   "\"fulfillment_url\": \"https://example.com/\",";
-                   "\"products\": [ {\"description\":\"2-coins payment\","
-                   "\"value\":\"{%s:10}\"} ] }",
-                   currency,
-                   currency,
-                   currency);
 
   if (NULL != apikey)
   {
@@ -264,7 +209,10 @@ run (void *cls,
       TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1",
                                               merchant_url,
                                               MHD_HTTP_OK,
-                                              order_worth_5),
+                                              "order-worth-5",
+                                              GNUNET_TIME_UNIT_ZERO_ABS,
+                                              GNUNET_TIME_UNIT_FOREVER_ABS,
+                                              "EUR:5.0"),
       TALER_TESTING_cmd_merchant_pay_order ("deposit-simple",
                                             merchant_url,
                                             MHD_HTTP_OK,
@@ -281,7 +229,10 @@ run (void *cls,
       TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2",
                                               merchant_url,
                                               MHD_HTTP_OK,
-                                              order_worth_5_track),
+                                              "order-worth-5-track",
+                                              GNUNET_TIME_UNIT_ZERO_ABS,
+                                              GNUNET_TIME_UNIT_FOREVER_ABS,
+                                              "EUR:5.0"),
       TALER_TESTING_cmd_merchant_pay_order ("deposit-simple-2",
                                             merchant_url,
                                             MHD_HTTP_OK,
@@ -335,7 +286,10 @@ run (void *cls,
       TALER_TESTING_cmd_merchant_post_orders ("create-unaggregated-proposal",
                                               alt_instance_url,
                                               MHD_HTTP_OK,
-                                              order_worth_5_unaggregated),
+                                              "order-worth-5-unaggregated",
+                                              GNUNET_TIME_UNIT_ZERO_ABS,
+                                              GNUNET_TIME_UNIT_FOREVER_ABS,
+                                              "EUR:5.0"),
       TALER_TESTING_cmd_merchant_pay_order ("deposit-unaggregated",
                                             merchant_url,
                                             MHD_HTTP_OK,
@@ -363,7 +317,10 @@ run (void *cls,
       TALER_TESTING_cmd_merchant_post_orders ("create-twocoins-proposal",
                                               merchant_url,
                                               MHD_HTTP_OK,
-                                              order_worth_10_2coins),
+                                              "order-worth-10-2coins",
+                                              GNUNET_TIME_UNIT_ZERO_ABS,
+                                              GNUNET_TIME_UNIT_FOREVER_ABS,
+                                              "EUR:10.0"),
       TALER_TESTING_cmd_merchant_pay_order ("deposit-twocoins",
                                             merchant_url,
                                             MHD_HTTP_OK,
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 7f418c9..f01f93f 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -212,15 +212,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1",
                                             merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"1\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }"),
+                                            "1",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:5.0"),
     TALER_TESTING_cmd_poll_orders_conclude ("poll-orders-1-conclude",
                                             MHD_HTTP_OK,
                                             "poll-orders-1-start"),
@@ -334,30 +329,20 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-wm-nx",
                                              merchant_url,
                                              MHD_HTTP_NOT_FOUND,
-                                             "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"order-p3\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }",
+                                             "order-p3",
+                                             GNUNET_TIME_UNIT_ZERO_ABS,
+                                             GNUNET_TIME_UNIT_FOREVER_ABS,
+                                             "EUR:5.0",
                                              "unsupported-wire-method",
                                              "product-3/2",
                                              ""),
     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3-pd-nx",
                                              merchant_url,
                                              MHD_HTTP_NOT_FOUND,
-                                             "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"order-p3\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }",
+                                             "order-p3",
+                                             GNUNET_TIME_UNIT_ZERO_ABS,
+                                             GNUNET_TIME_UNIT_FOREVER_ABS,
+                                             "EUR:5.0",
                                              "x-taler-bank",
                                              "unknown-product/2",
                                              ""),
@@ -365,30 +350,20 @@ run (void *cls,
       "create-proposal-p3-not-enough-stock",
       merchant_url,
       MHD_HTTP_GONE,
-      "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"order-p3\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }",
+      "order-p3",
+      GNUNET_TIME_UNIT_ZERO_ABS,
+      GNUNET_TIME_UNIT_FOREVER_ABS,
+      "EUR:5.0",
       "x-taler-bank",
       "product-3/24",
       ""),
     TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-p3",
                                              merchant_url,
                                              MHD_HTTP_OK,
-                                             "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"order-p3\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }",
+                                             "order-p3",
+                                             GNUNET_TIME_UNIT_ZERO_ABS,
+                                             GNUNET_TIME_UNIT_FOREVER_ABS,
+                                             "EUR:5.0",
                                              "x-taler-bank",
                                              "product-3/3",
                                              "lock-product-p3"),
@@ -404,15 +379,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-2",
                                             merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"2\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"useful product\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }"),
+                                            "2",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:5.0"),
     TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal-2",
                                             merchant_url,
                                             MHD_HTTP_OK,
@@ -479,15 +449,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1r",
                                             merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"1r\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }"),
+                                            "1r",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:5.0"),
     TALER_TESTING_cmd_merchant_pay_order ("pay-for-refund-1r",
                                           merchant_url,
                                           MHD_HTTP_OK,
@@ -558,15 +523,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-not-to-be-paid",
                                             merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"1-unpaid\",\
-        \"refund_deadline\":{\"t_ms\":0},\
-        \"pay_deadline\":{\"t_ms\":\"never\"},\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"useful product\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }"),
+                                            "1-unpaid",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:5.0"),
     /* Try to increase a non paid proposal.  */
     TALER_TESTING_cmd_merchant_order_refund ("refund-increase-unpaid-proposal",
                                              merchant_url,
@@ -606,15 +566,10 @@ run (void *cls,
       "create-proposal-unincreased-refund",
       merchant_url,
       MHD_HTTP_OK,
-      "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"unincreased-proposal\",\
-        \"refund_deadline\":{\"t_ms\":0},\
-        \"pay_deadline\":{\"t_ms\":\"never\"},\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }"),
+      "unincreased-proposal",
+      GNUNET_TIME_UNIT_ZERO_ABS,
+      GNUNET_TIME_UNIT_FOREVER_ABS,
+      "EUR:5.0"),
     TALER_TESTING_cmd_merchant_pay_order ("pay-unincreased-proposal",
                                           merchant_url,
                                           MHD_HTTP_OK,
@@ -868,15 +823,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-10",
                                             merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"10\",\
-        \"refund_deadline\":{\"t_ms\":0},\
-        \"pay_deadline\":{\"t_ms\":\"never\"},\
-        \"amount\":\"EUR:10.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:10}\"} ] }"),
+                                            "10",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:10.0"),
     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-10",
                                           merchant_url,
                                           MHD_HTTP_CONFLICT,
@@ -925,15 +875,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-11",
                                             merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"11\",\
-        \"refund_deadline\":{\"t_ms\":0},\
-        \"pay_deadline\":{\"t_ms\":\"never\"},\
-        \"amount\":\"EUR:10.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:10}\"} ] }"),
+                                            "11",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:10.0"),
     TALER_TESTING_cmd_merchant_pay_order ("pay-fail-partial-double-11-good",
                                           merchant_url,
                                           MHD_HTTP_NOT_ACCEPTABLE,
diff --git a/src/testing/test_merchant_api_twisted.c 
b/src/testing/test_merchant_api_twisted.c
index 8f94ac1..baf025d 100644
--- a/src/testing/test_merchant_api_twisted.c
+++ b/src/testing/test_merchant_api_twisted.c
@@ -222,15 +222,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-abort-1",
                                             twister_merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"abort-one\",\
-        \"refund_deadline\":{\"t_ms\":0},\
-        \"pay_deadline\":{\"t_ms\":\"never\"},\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"amount\":\"EUR:3.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:3}\"} ] }"),
+                                            "abort-one",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:3.0"),
     /* Will only pay _half_ the supposed price,
      * so we'll then have the right to abort.  */
     TALER_TESTING_cmd_merchant_pay_order ("deposit-simple-for-abort",
@@ -283,25 +278,17 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-double-spend",
                                             twister_merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"DS-1\",\
-        \"refund_deadline\":{\"t_ms\":0},\
-        \"pay_deadline\":{\"t_ms\":\"never\"},\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"amount\":\"EUR:1.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"products\": [ {\"description\": \"will succeed\"}] }"),
+                                            "DS-1",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:1.0"),
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-double-spend-1",
                                             twister_merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"DS-2\",\
-        \"refund_deadline\":{\"t_ms\":0},\
-        \"pay_deadline\":{\"t_ms\":\"never\"},\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"amount\":\"EUR:1.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"products\": [ {\"description\": \"will fail\"}] }"),
+                                            "DS-2",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:3.0"),
 
     TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-double-spend",
                                        "create-reserve-double-spend",
@@ -367,15 +354,10 @@ run (void *cls,
     TALER_TESTING_cmd_merchant_post_orders ("create-proposal-1",
                                             merchant_url,
                                             MHD_HTTP_OK,
-                                            "{\"max_fee\":\"EUR:0.5\",\
-        \"order_id\":\"1\",\
-        \"refund_deadline\": {\"t_ms\": 0},\
-        \"pay_deadline\": {\"t_ms\": \"never\" },\
-        \"amount\":\"EUR:5.0\",\
-        \"summary\": \"merchant-lib testcase\",\
-        \"fulfillment_url\": \"https://example.com/\",\
-        \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{EUR:5}\"} ] }"),
+                                            "1",
+                                            GNUNET_TIME_UNIT_ZERO_ABS,
+                                            GNUNET_TIME_UNIT_FOREVER_ABS,
+                                            "EUR:5.0"),
     TALER_TESTING_cmd_malform_response ("malform-exchange-reponse-1",
                                         PROXY_EXCHANGE_CONFIG_FILE),
     TALER_TESTING_cmd_merchant_pay_order ("deposit-simple",
diff --git a/src/testing/testing_api_cmd_post_orders.c 
b/src/testing/testing_api_cmd_post_orders.c
index 0e4f47a..3a48902 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -38,7 +38,7 @@ struct OrdersState
   /**
    * The order.
    */
-  const char *order;
+  char *order;
 
   /**
    * Expected status code.
@@ -505,32 +505,101 @@ orders_cleanup (void *cls,
   }
 
   json_decref (ps->contract_terms);
+  GNUNET_free (ps->order);
   GNUNET_free_nz ((void *) ps->order_id);
   GNUNET_free (ps);
 }
 
 
 /**
- * Make the "orders" command.
+ * Constructs the json for a POST order request.
+ *
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
+ * @param order[out] where to write the json string.
+ */
+static void
+make_order_json (const char *order_id,
+                 struct GNUNET_TIME_Absolute refund_deadline,
+                 struct GNUNET_TIME_Absolute pay_deadline,
+                 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];
+
+  GNUNET_TIME_round_abs (&refund_deadline_round);
+  GNUNET_TIME_round_abs (&pay_deadline_round);
+
+  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);
+}
+
+
+/**
+ * Make the "proposal" command.
  *
  * @param label command label
  * @param merchant_url base URL of the merchant serving
- *        the orders request.
+ *        the proposal request.
  * @param http_status expected HTTP status.
- * @param order the order to PUT to the merchant.
- *
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
  * @return the command
  */
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_merchant_post_orders (const char *label,
                                         const char *merchant_url,
                                         unsigned int http_status,
-                                        const char *order)
+                                        const char *order_id,
+                                        struct GNUNET_TIME_Absolute
+                                        refund_deadline,
+                                        struct GNUNET_TIME_Absolute
+                                        pay_deadline,
+                                        const char *amount)
 {
   struct OrdersState *ps;
 
   ps = GNUNET_new (struct OrdersState);
-  ps->order = order;
+  make_order_json (order_id,
+                   refund_deadline,
+                   pay_deadline,
+                   amount,
+                   &ps->order);
   ps->http_status = http_status;
   ps->merchant_url = merchant_url;
   {
@@ -554,7 +623,10 @@ TALER_TESTING_cmd_merchant_post_orders (const char *label,
  * @param merchant_url base URL of the merchant serving
  *        the proposal request.
  * @param http_status expected HTTP status.
- * @param order the order to PUT to the merchant.
+ * @param order_id the name of the order to add.
+ * @param refund_deadline the deadline for refunds on this order.
+ * @param pay_deadline the deadline for payment on this order.
+ * @param amount the amount this order is for.
  * @param payment_target payment target for the order.
  * @param products a string indicating the products this order will be
  *        purchasing. Should be formatted as
@@ -567,7 +639,12 @@ struct TALER_TESTING_Command
 TALER_TESTING_cmd_merchant_post_orders2 (const char *label,
                                          const char *merchant_url,
                                          unsigned int http_status,
-                                         const char *order,
+                                         const char *order_id,
+                                         struct GNUNET_TIME_Absolute
+                                         refund_deadline,
+                                         struct GNUNET_TIME_Absolute
+                                         pay_deadline,
+                                         const char *amount,
                                          const char *payment_target,
                                          const char *products,
                                          const char *locks)
@@ -575,7 +652,11 @@ TALER_TESTING_cmd_merchant_post_orders2 (const char *label,
   struct OrdersState *ps;
 
   ps = GNUNET_new (struct OrdersState);
-  ps->order = order;
+  make_order_json (order_id,
+                   refund_deadline,
+                   pay_deadline,
+                   amount,
+                   &ps->order);
   ps->http_status = http_status;
   ps->merchant_url = merchant_url;
   ps->payment_target = payment_target;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]