[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] 01/03: cover invalid /pay abortion.
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] 01/03: cover invalid /pay abortion. |
Date: |
Thu, 22 Mar 2018 17:12:34 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant.
commit 152c64b1b3ab84e3dc78b1fef5e49a2f221f2d8c
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Mar 22 12:44:46 2018 +0100
cover invalid /pay abortion.
---
src/backend/taler-merchant-httpd_pay.c | 6 ++-
src/lib/test_merchant_api_twisted.c | 72 ++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/src/backend/taler-merchant-httpd_pay.c
b/src/backend/taler-merchant-httpd_pay.c
index eee23c1..3ac4f39 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -1226,6 +1226,7 @@ check_coin_paid (void *cls,
if (GNUNET_YES == dc->found_in_db)
continue; /* processed earlier */
+
/* Get matching coin from results*/
if ( (0 != memcmp (coin_pub,
&dc->coin_pub,
@@ -1663,6 +1664,8 @@ begin_transaction (struct PayContext *pc)
"Merchant database error (could not start
transaction)");
return;
}
+
+ /* Init. some price accumulators. */
GNUNET_break (GNUNET_OK ==
TALER_amount_get_zero (pc->amount.currency,
&pc->total_paid));
@@ -1673,7 +1676,7 @@ begin_transaction (struct PayContext *pc)
TALER_amount_get_zero (pc->amount.currency,
&pc->total_refunded));
- /* Check if some of these coins already succeeded */
+ /* Check if some of these coins already succeeded for _this_ contract. */
qs = db->find_payments (db->cls,
&pc->h_contract_terms,
&pc->mi->pubkey,
@@ -1725,6 +1728,7 @@ begin_transaction (struct PayContext *pc)
/* The wallet is going for a refund,
(on aborted operation)! */
+
/* check payment was indeed incomplete */
qs = db->find_paid_contract_terms_from_hash (db->cls,
&terms,
diff --git a/src/lib/test_merchant_api_twisted.c
b/src/lib/test_merchant_api_twisted.c
index 216ac91..756b084 100644
--- a/src/lib/test_merchant_api_twisted.c
+++ b/src/lib/test_merchant_api_twisted.c
@@ -509,6 +509,78 @@ run (void *cls,
"deposit-simple",
"EUR:0.01"), // ignored
+ /****** Covering /pay *******/
+
+ /**
+ * Move money to the exchange's bank account.
+ */
+ CMD_TRANSFER_TO_EXCHANGE ("create-reserve-abort-1",
+ "EUR:1.01"),
+
+ /**
+ * Make a reserve exist, according to the previous
+ * transfer.
+ */
+ CMD_EXEC_WIREWATCH ("wirewatch-abort-1"),
+
+ TALER_TESTING_cmd_check_bank_transfer
+ ("check_bank_transfer-abort-1",
+ "http://localhost:8081/",
+ "EUR:1.01", USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO),
+
+ TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-abort-1",
+ is->exchange,
+ "create-reserve-abort-1",
+ "EUR:1",
+ MHD_HTTP_OK),
+
+ TALER_TESTING_cmd_status ("withdraw-status-abort-1",
+ is->exchange,
+ "create-reserve-abort-1",
+ "EUR:0",
+ MHD_HTTP_OK),
+
+ TALER_TESTING_cmd_proposal
+ ("create-proposal-abort-1",
+ twister_merchant_url,
+ is->ctx,
+ MHD_HTTP_OK,
+ "{\"max_fee\":\
+ {\"currency\":\"EUR\",\
+ \"value\":0,\
+ \"fraction\":50000000},\
+ \"order_id\":\"abort-one\",\
+ \"refund_deadline\":\"\\/Date(0)\\/\",\
+ \"pay_deadline\":\"\\/Date(99999999999)\\/\",\
+ \"fulfillment_url\": \"https://example.com/\",\
+ \"amount\":\
+ {\"currency\":\"EUR\",\
+ \"value\":3,\
+ \"fraction\":0},\
+ \"summary\": \"merchant-lib testcase\",\
+ \"products\": [ {\"description\":\"ice cream\",\
+ \"value\":\"{EUR:3}\"} ] }",
+ NULL),
+
+ TALER_TESTING_cmd_pay ("deposit-simple-for-abort",
+ twister_merchant_url,
+ is->ctx,
+ 0,
+ "create-proposal-abort-1",
+ "withdraw-coin-abort-1",
+ "EUR:1",
+ "EUR:1.99", // no sense now
+ "EUR:0.01"), // no sense now
+
+ TALER_TESTING_cmd_delete_object ("hack-abort",
+ PROXY_MERCHANT_CONFIG_FILE,
+ "merchant_pub"),
+
+ TALER_TESTING_cmd_pay_abort ("pay-abort-1",
+ twister_merchant_url,
+ "deposit-simple-for-abort",
+ is->ctx,
+ MHD_HTTP_OK),
/**
* End the suite. Fixme: better to have a label for this
* too, as it shows a "(null)" token on logs.
--
To stop receiving notification emails like this one, please contact
address@hidden