summaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-24 19:54:50 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-24 19:54:50 +0200
commit0fa2888bc7d1095a2341e16eda59cb5085b78b67 (patch)
treec27104816a49f7906704a8de6f0fe2289bb6df32 /src/testing
parent874f09525fee53e8a69f040cd3cf9b4f369fdee5 (diff)
downloadmerchant-0fa2888bc7d1095a2341e16eda59cb5085b78b67.tar.gz
merchant-0fa2888bc7d1095a2341e16eda59cb5085b78b67.tar.bz2
merchant-0fa2888bc7d1095a2341e16eda59cb5085b78b67.zip
improve API
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_merchant_api.c40
-rw-r--r--src/testing/testing_api_cmd_patch_instance.c12
-rw-r--r--src/testing/testing_api_cmd_patch_product.c6
-rw-r--r--src/testing/testing_api_cmd_post_instances.c29
-rw-r--r--src/testing/testing_api_cmd_post_products.c13
5 files changed, 72 insertions, 28 deletions
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,