aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/pg_insert_close_request.c4
-rw-r--r--src/exchangedb/pg_select_reserve_close_info.c12
-rw-r--r--src/include/taler_testing_lib.h2
-rw-r--r--src/testing/test_exchange_p2p.c54
-rw-r--r--src/testing/testing_api_cmd_reserve_purse.c8
5 files changed, 62 insertions, 18 deletions
diff --git a/src/exchangedb/pg_insert_close_request.c b/src/exchangedb/pg_insert_close_request.c
index 43ca944f4..a62c2cba7 100644
--- a/src/exchangedb/pg_insert_close_request.c
+++ b/src/exchangedb/pg_insert_close_request.c
@@ -54,12 +54,12 @@ TEH_PG_insert_close_request (
",close_timestamp"
",reserve_sig"
",close_val"
- ",close_frac,"
+ ",close_frac"
",close_fee_val"
",close_fee_frac"
",payto_uri"
")"
- "VALUES ($1, $2, $3, $4, $5, $6, $7)"
+ "VALUES ($1, $2, $3, $4, $5, $6, $7, $8)"
" ON CONFLICT DO NOTHING;");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_account_close",
diff --git a/src/exchangedb/pg_select_reserve_close_info.c b/src/exchangedb/pg_select_reserve_close_info.c
index 0b373b7bb..973f5fa51 100644
--- a/src/exchangedb/pg_select_reserve_close_info.c
+++ b/src/exchangedb/pg_select_reserve_close_info.c
@@ -39,7 +39,7 @@ TEH_PG_select_reserve_close_info (
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("close",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance",
balance),
GNUNET_PQ_result_spec_string ("payto_uri",
payto_uri),
@@ -49,10 +49,12 @@ TEH_PG_select_reserve_close_info (
PREPARE (pg,
"select_reserve_close_info",
"SELECT "
- " close_frac"
- ",close_val"
- ",payto_uri"
- " FROM close_requests"
+ " r.current_balance_val"
+ ",r.current_balance_frac"
+ ",wt.payto_uri"
+ " FROM reserves r"
+ " LEFT JOIN reserves_in ri USING (reserve_pub)"
+ " LEFT JOIN wire_targets wt ON (ri.wire_source_h_payto = wt.wire_target_h_payto)"
" WHERE reserve_pub=$1;");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"select_reserve_close_info",
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 84ba18378..a964ba4a1 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -2652,6 +2652,7 @@ TALER_TESTING_cmd_purse_poll_finish (const char *label,
* @param expected_http_status what HTTP status do we expect to get returned from the exchange
* @param contract_terms contract, JSON string
* @param upload_contract should we upload the contract
+ * @param pay_purse_fee should we pay a fee to create the purse
* @param expiration when should the purse expire
* @param reserve_ref reference to reserve key, or NULL to create a new reserve
* @return the command
@@ -2662,6 +2663,7 @@ TALER_TESTING_cmd_purse_create_with_reserve (
unsigned int expected_http_status,
const char *contract_terms,
bool upload_contract,
+ bool pay_purse_fee,
struct GNUNET_TIME_Relative expiration,
const char *reserve_ref);
diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c
index 3f77ebc7f..1a6c5854f 100644
--- a/src/testing/test_exchange_p2p.c
+++ b/src/testing/test_exchange_p2p.c
@@ -22,7 +22,7 @@
* @author Christian Grothoff
*
* TODO:
- * - Test purse creation with reserve purse quota
+ * - enable reserve close test once implementation is complete!
*/
#include "platform.h"
#include "taler_util.h"
@@ -216,6 +216,7 @@ run (void *cls,
MHD_HTTP_OK,
"{\"amount\":\"EUR:1\",\"summary\":\"ice cream\"}",
true /* upload contract */,
+ true /* pay purse fee */,
GNUNET_TIME_UNIT_MINUTES, /* expiration */
"create-reserve-1"),
TALER_TESTING_cmd_contract_get (
@@ -260,6 +261,7 @@ run (void *cls,
MHD_HTTP_OK,
"{\"amount\":\"EUR:4\",\"summary\":\"beer\"}",
true /* upload contract */,
+ true /* pay purse fee */,
GNUNET_TIME_UNIT_MINUTES, /* expiration */
"create-reserve-1"),
TALER_TESTING_cmd_purse_deposit_coins (
@@ -279,6 +281,7 @@ run (void *cls,
MHD_HTTP_OK,
"{\"amount\":\"EUR:2\",\"summary\":\"ice cream\"}",
true /* upload contract */,
+ true /* pay purse fee */,
GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_SECONDS,
1), /* expiration */
@@ -404,7 +407,31 @@ run (void *cls,
"EUR:0.03", /* 0.02 for the reserve open, 0.01 for deposit fee */
NULL,
NULL),
- /* FIXME: use purse creation with purse quota here */
+ /* Use purse creation with purse quota here */
+ TALER_TESTING_cmd_purse_create_with_reserve (
+ "purse-create-with-reserve-101-a",
+ MHD_HTTP_OK,
+ "{\"amount\":\"EUR:1\",\"summary\":\"ice cream\"}",
+ true /* upload contract */,
+ false /* pay purse fee */,
+ GNUNET_TIME_UNIT_MINUTES, /* expiration */
+ "create-reserve-101"),
+ TALER_TESTING_cmd_purse_create_with_reserve (
+ "purse-create-with-reserve-101-b",
+ MHD_HTTP_OK,
+ "{\"amount\":\"EUR:1\",\"summary\":\"ice cream\"}",
+ true /* upload contract */,
+ false /* pay purse fee */,
+ GNUNET_TIME_UNIT_MINUTES, /* expiration */
+ "create-reserve-101"),
+ TALER_TESTING_cmd_purse_create_with_reserve (
+ "purse-create-with-reserve-101-fail",
+ MHD_HTTP_CONFLICT,
+ "{\"amount\":\"EUR:1\",\"summary\":\"ice cream\"}",
+ true /* upload contract */,
+ false /* pay purse fee */,
+ GNUNET_TIME_UNIT_MINUTES, /* expiration */
+ "create-reserve-101"),
TALER_TESTING_cmd_reserve_get_attestable ("reserve-101-attestable",
"create-reserve-101",
MHD_HTTP_NOT_FOUND,
@@ -415,13 +442,23 @@ run (void *cls,
"nx-attribute-name",
NULL),
/* FIXME: do KYC for reserve, then get actual attributes attested */
-#if 0
TALER_TESTING_cmd_reserve_close ("reserve-101-close",
"create-reserve-101",
NULL, /* to origin */
MHD_HTTP_OK),
- /* FIXME: trigger helper to close reserve here */
- /* FIXME: check reserve was actually closed (money wired back) */
+#if FIXME
+ /* reserve close logic is not yet implemented, hence this fails: */
+ TALER_TESTING_cmd_exec_closer ("close-reserves-101",
+ config_file,
+ "EUR:1.02",
+ "EUR:0.01",
+ "create-reserve-101"),
+ TALER_TESTING_cmd_exec_transfer ("close-reserves-101-transfer",
+ config_file),
+ TALER_TESTING_cmd_status ("reserve-101-closed-status",
+ "create-reserve-101",
+ "EUR:0",
+ MHD_HTTP_OK),
#endif
TALER_TESTING_cmd_end ()
};
@@ -456,11 +493,6 @@ run (void *cls,
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
-#if 0
- TALER_TESTING_cmd_batch ("reserves",
- reserves),
- TALER_TESTING_cmd_end (), // FIXME
-#endif
TALER_TESTING_cmd_batch ("withdraw",
withdraw),
TALER_TESTING_cmd_batch ("push",
@@ -469,6 +501,8 @@ run (void *cls,
pull),
TALER_TESTING_cmd_batch ("expire",
expire),
+ TALER_TESTING_cmd_batch ("reserves",
+ reserves),
/* End the suite. */
TALER_TESTING_cmd_end ()
};
diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c
index cdffa97fe..f01741b07 100644
--- a/src/testing/testing_api_cmd_reserve_purse.c
+++ b/src/testing/testing_api_cmd_reserve_purse.c
@@ -129,6 +129,10 @@ struct ReservePurseState
*/
unsigned int expected_response_code;
+ /**
+ * True to pay the purse fee.
+ */
+ bool pay_purse_fee;
};
@@ -239,7 +243,7 @@ purse_run (void *cls,
&ds->contract_priv,
ds->contract_terms,
true /* upload contract */,
- true /* do pay purse fee -- FIXME #7274: make this a choice to test this case; then update testing_api_cmd_purse_deposit flags logic to match! */,
+ ds->pay_purse_fee,
ds->merge_timestamp,
&purse_cb,
ds);
@@ -327,6 +331,7 @@ TALER_TESTING_cmd_purse_create_with_reserve (
unsigned int expected_http_status,
const char *contract_terms,
bool upload_contract,
+ bool pay_purse_fee,
struct GNUNET_TIME_Relative expiration,
const char *reserve_ref)
{
@@ -339,6 +344,7 @@ TALER_TESTING_cmd_purse_create_with_reserve (
0 /* flags */,
&err);
GNUNET_assert (NULL != ds->contract_terms);
+ ds->pay_purse_fee = pay_purse_fee;
ds->reserve_ref = reserve_ref;
ds->expected_response_code = expected_http_status;