diff options
-rw-r--r-- | src/include/taler_merchant_testing_lib.h | 12 | ||||
-rw-r--r-- | src/testing/test_merchant_api.c | 40 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_patch_instance.c | 12 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_patch_product.c | 6 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_post_instances.c | 29 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_post_products.c | 13 |
6 files changed, 78 insertions, 34 deletions
diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h index d9d3c8e1..bba80d3b 100644 --- a/src/include/taler_merchant_testing_lib.h +++ b/src/include/taler_merchant_testing_lib.h @@ -147,9 +147,9 @@ TALER_TESTING_cmd_merchant_post_instances2 ( const char *name, json_t *address, json_t *jurisdiction, - const struct TALER_Amount *default_max_wire_fee, + const char *default_max_wire_fee, uint32_t default_wire_fee_amortization, - const struct TALER_Amount *default_max_deposit_fee, + const char *default_max_deposit_fee, struct GNUNET_TIME_Relative default_wire_transfer_delay, struct GNUNET_TIME_Relative default_pay_delay, unsigned int http_status); @@ -185,9 +185,9 @@ TALER_TESTING_cmd_merchant_patch_instance ( const char *name, json_t *address, json_t *jurisdiction, - const struct TALER_Amount *default_max_wire_fee, + const char *default_max_wire_fee, uint32_t default_wire_fee_amortization, - const struct TALER_Amount *default_max_deposit_fee, + const char *default_max_deposit_fee, struct GNUNET_TIME_Relative default_wire_transfer_delay, struct GNUNET_TIME_Relative default_pay_delay, unsigned int http_status); @@ -281,7 +281,7 @@ TALER_TESTING_cmd_merchant_post_products2 ( const char *description, json_t *description_i18n, const char *unit, - const struct TALER_Amount *price, + const char *price, json_t *image, json_t *taxes, int64_t total_stocked, @@ -345,7 +345,7 @@ TALER_TESTING_cmd_merchant_patch_product ( const char *description, json_t *description_i18n, const char *unit, - const struct TALER_Amount *price, + const char *price, json_t *image, json_t *taxes, int64_t total_stocked, diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 3a203fce..76fbb438 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -42,6 +42,8 @@ */ #define CONFIG_FILE "test_merchant_api.conf" +#define PAYTO_I1 "payto://taler-bank/localhost/3" + /** * Exchange base URL. Could also be taken from config. */ @@ -895,10 +897,48 @@ run (void *cls, TALER_TESTING_cmd_end () }; + const char *payto_uris[] = { + PAYTO_I1 + }; struct TALER_TESTING_Command commands[] = { TALER_TESTING_cmd_config ("config", merchant_url, MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_instances ("instances-empty", + merchant_url, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1", + merchant_url, + "i1", + PAYTO_I1, + "EUR", + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_get_instances ("instances-get-i1", + merchant_url, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_instance ("instances-get-i1", + merchant_url, + "i1", + MHD_HTTP_OK, + "instance-create-i1"), + TALER_TESTING_cmd_merchant_patch_instance ("instance-create-i1", + merchant_url, + "i1", + 1, + payto_uris, + "bob-the-merchant", + json_pack ("{s:s}", + "street", + "bobstreet"), + json_pack ("{s:s}", + "street", + "bobjuryst"), + "EUR:0.1", + 4, + "EUR:0.5", + GNUNET_TIME_UNIT_MINUTES, + GNUNET_TIME_UNIT_MINUTES, + MHD_HTTP_NO_CONTENT), #if 0 TALER_TESTING_cmd_batch ("pay", pay), diff --git a/src/testing/testing_api_cmd_patch_instance.c b/src/testing/testing_api_cmd_patch_instance.c index 0d589bb2..a198829a 100644 --- a/src/testing/testing_api_cmd_patch_instance.c +++ b/src/testing/testing_api_cmd_patch_instance.c @@ -237,9 +237,9 @@ TALER_TESTING_cmd_merchant_patch_instance ( const char *name, json_t *address, json_t *jurisdiction, - const struct TALER_Amount *default_max_wire_fee, + const char *default_max_wire_fee, uint32_t default_wire_fee_amortization, - const struct TALER_Amount *default_max_deposit_fee, + const char *default_max_deposit_fee, struct GNUNET_TIME_Relative default_wire_transfer_delay, struct GNUNET_TIME_Relative default_pay_delay, unsigned int http_status) @@ -255,9 +255,13 @@ TALER_TESTING_cmd_merchant_patch_instance ( pis->name = name; pis->address = address; /* ownership transfer! */ pis->jurisdiction = jurisdiction; /* ownership transfer! */ - pis->default_max_wire_fee = *default_max_wire_fee; + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (default_max_wire_fee, + &pis->default_max_wire_fee)); pis->default_wire_fee_amortization = default_wire_fee_amortization; - pis->default_max_deposit_fee = *default_max_deposit_fee; + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (default_max_deposit_fee, + &pis->default_max_deposit_fee)); pis->default_wire_transfer_delay = default_wire_transfer_delay; pis->default_pay_delay = default_pay_delay; { diff --git a/src/testing/testing_api_cmd_patch_product.c b/src/testing/testing_api_cmd_patch_product.c index 8088932d..ec4bb4c4 100644 --- a/src/testing/testing_api_cmd_patch_product.c +++ b/src/testing/testing_api_cmd_patch_product.c @@ -243,7 +243,7 @@ TALER_TESTING_cmd_merchant_patch_product ( const char *description, json_t *description_i18n, const char *unit, - const struct TALER_Amount *price, + const char *price, json_t *image, json_t *taxes, int64_t total_stocked, @@ -261,7 +261,9 @@ TALER_TESTING_cmd_merchant_patch_product ( pis->description = description; pis->description_i18n = description_i18n; /* ownership taken */ pis->unit = unit; - pis->price = *price; + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (price, + &pis->price)); pis->image = image; /* ownership taken */ pis->taxes = taxes; /* ownership taken */ pis->total_stocked = total_stocked; diff --git a/src/testing/testing_api_cmd_post_instances.c b/src/testing/testing_api_cmd_post_instances.c index f9da2dae..26efd0be 100644 --- a/src/testing/testing_api_cmd_post_instances.c +++ b/src/testing/testing_api_cmd_post_instances.c @@ -237,9 +237,9 @@ TALER_TESTING_cmd_merchant_post_instances2 ( const char *name, json_t *address, json_t *jurisdiction, - const struct TALER_Amount *default_max_wire_fee, + const char *default_max_wire_fee, uint32_t default_wire_fee_amortization, - const struct TALER_Amount *default_max_deposit_fee, + const char *default_max_deposit_fee, struct GNUNET_TIME_Relative default_wire_transfer_delay, struct GNUNET_TIME_Relative default_pay_delay, unsigned int http_status) @@ -255,9 +255,13 @@ TALER_TESTING_cmd_merchant_post_instances2 ( pis->name = name; pis->address = address; /* ownership transfer! */ pis->jurisdiction = jurisdiction; /* ownership transfer! */ - pis->default_max_wire_fee = *default_max_wire_fee; + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (default_max_wire_fee, + &pis->default_max_wire_fee)); pis->default_wire_fee_amortization = default_wire_fee_amortization; - pis->default_max_deposit_fee = *default_max_deposit_fee; + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (default_max_deposit_fee, + &pis->default_max_deposit_fee)); pis->default_wire_transfer_delay = default_wire_transfer_delay; pis->default_pay_delay = default_pay_delay; { @@ -296,17 +300,14 @@ TALER_TESTING_cmd_merchant_post_instances (const char *label, const char *payto_uris[] = { payto_uri }; - struct TALER_Amount default_max_wire_fee; - struct TALER_Amount default_max_deposit_fee; + struct TALER_Amount default_max_fee; + const char *default_max_fee_s; GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, - &default_max_wire_fee)); - GNUNET_assert (GNUNET_OK == - TALER_amount_get_zero (currency, - &default_max_deposit_fee)); - default_max_wire_fee.value = 1; - default_max_deposit_fee.value = 1; + &default_max_fee)); + default_max_fee.value = 1; + default_max_fee_s = TALER_amount2s (&default_max_fee); return TALER_TESTING_cmd_merchant_post_instances2 ( label, @@ -317,9 +318,9 @@ TALER_TESTING_cmd_merchant_post_instances (const char *label, instance_id, json_pack ("{s:s}", "city", "shopcity"), json_pack ("{s:s}", "city", "lawyercity"), - &default_max_wire_fee, + default_max_fee_s, 10, - &default_max_deposit_fee, + default_max_fee_s, GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_MINUTES, http_status); diff --git a/src/testing/testing_api_cmd_post_products.c b/src/testing/testing_api_cmd_post_products.c index f5fed272..8f787bc1 100644 --- a/src/testing/testing_api_cmd_post_products.c +++ b/src/testing/testing_api_cmd_post_products.c @@ -234,7 +234,7 @@ TALER_TESTING_cmd_merchant_post_products2 ( const char *description, json_t *description_i18n, const char *unit, - const struct TALER_Amount *price, + const char *price, json_t *image, json_t *taxes, int64_t total_stocked, @@ -251,7 +251,9 @@ TALER_TESTING_cmd_merchant_post_products2 ( pis->description = description; pis->description_i18n = description_i18n; /* ownership taken */ pis->unit = unit; - pis->price = *price; + GNUNET_assert (GNUNET_OK == + TALER_string_to_amount (price, + &pis->price)); pis->image = image; /* ownership taken */ pis->taxes = taxes; /* ownership taken */ pis->total_stocked = total_stocked; @@ -290,11 +292,6 @@ TALER_TESTING_cmd_merchant_post_products (const char *label, const char *price, unsigned int http_status) { - struct TALER_Amount amount; - - GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (price, - &amount)); return TALER_TESTING_cmd_merchant_post_products2 ( label, merchant_url, @@ -302,7 +299,7 @@ TALER_TESTING_cmd_merchant_post_products (const char *label, description, json_pack ("{s:s}", "en", description), "test-unit", - &amount, + price, json_object (), json_object (), 4, |