summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-14 03:05:12 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-14 03:05:12 -0400
commiteec18999238cf247043e9f9c093b5bcfa1eb87ea (patch)
treeef6ffb0818c72df4a82d16bc90e0f7c6e2b03e00 /src/backend
parente13b13b3041e905feb0e22a3488457c280dbeed2 (diff)
downloadmerchant-eec18999238cf247043e9f9c093b5bcfa1eb87ea.tar.gz
merchant-eec18999238cf247043e9f9c093b5bcfa1eb87ea.tar.bz2
merchant-eec18999238cf247043e9f9c093b5bcfa1eb87ea.zip
tests for idempotent/conflicting post requests
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-httpd_private-post-instances.c11
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c6
-rw-r--r--src/backend/taler-merchant-httpd_private-post-products.c6
3 files changed, 13 insertions, 10 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c
index 2320cd7b..ae583e75 100644
--- a/src/backend/taler-merchant-httpd_private-post-instances.c
+++ b/src/backend/taler-merchant-httpd_private-post-instances.c
@@ -69,8 +69,8 @@ accounts_equal (const struct TMH_MerchantInstance *mi,
i));
if (NULL == str)
return false;
- if ( (strcasecmp (uri,
- str)) )
+ if (0 == strcasecmp (uri,
+ str))
{
if (matches[i])
{
@@ -196,13 +196,14 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh,
is.address)) &&
(1 == json_equal (mi->settings.jurisdiction,
is.jurisdiction)) &&
- (0 == TALER_amount_cmp_currency (
+ (GNUNET_OK == TALER_amount_cmp_currency (
&mi->settings.default_max_deposit_fee,
&is.default_max_deposit_fee)) &&
(0 == TALER_amount_cmp (&mi->settings.default_max_deposit_fee,
&is.default_max_deposit_fee)) &&
- (0 == TALER_amount_cmp_currency (&mi->settings.default_max_wire_fee,
- &is.default_max_wire_fee)) &&
+ (GNUNET_OK == TALER_amount_cmp_currency (
+ &mi->settings.default_max_wire_fee,
+ &is.default_max_wire_fee)) &&
(0 == TALER_amount_cmp (&mi->settings.default_max_wire_fee,
&is.default_max_wire_fee)) &&
(mi->settings.default_wire_fee_amortization ==
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
index c97ac21c..33883f5f 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -218,12 +218,12 @@ execute_transaction (struct TMH_HandlerContext *hc,
order_id,
pay_deadline,
order);
- if (qs < 0)
+ /* qs == 0: order already exists. */
+ if (qs <= 0)
{
TMH_db->rollback (TMH_db->cls);
return qs;
}
- GNUNET_assert (qs > 0);
/* Migrate locks from UUIDs to new order: first release old locks */
for (unsigned int i = 0; i<uuids_length; i++)
{
@@ -428,7 +428,7 @@ execute_order (struct MHD_Connection *connection,
if (GNUNET_DB_STATUS_SOFT_ERROR != qs)
break;
}
- if (0 > qs)
+ if (0 >= qs)
{
/* Special report if retries insufficient */
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
diff --git a/src/backend/taler-merchant-httpd_private-post-products.c b/src/backend/taler-merchant-httpd_private-post-products.c
index 688a1aad..b7d240ae 100644
--- a/src/backend/taler-merchant-httpd_private-post-products.c
+++ b/src/backend/taler-merchant-httpd_private-post-products.c
@@ -50,8 +50,8 @@ products_equal (const struct TALER_MERCHANTDB_ProductDetails *p1,
p2->description_i18n)) &&
(0 == strcmp (p1->unit,
p2->unit)) &&
- (0 == TALER_amount_cmp_currency (&p1->price,
- &p2->price)) &&
+ (GNUNET_OK == TALER_amount_cmp_currency (&p1->price,
+ &p2->price)) &&
(0 == TALER_amount_cmp (&p1->price,
&p2->price)) &&
(1 == json_equal (p1->taxes,
@@ -117,6 +117,8 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh,
res = TALER_MHD_parse_json_data (connection,
hc->request_body,
spec);
+ pd.total_sold = 0;
+ pd.total_lost = 0;
if (GNUNET_OK != res)
return (GNUNET_NO == res)
? MHD_YES