From 8dfb3b87b47ca2d25f6bdcbdfa2acc517fbe6ae2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 21 May 2016 19:22:03 +0200 Subject: testing refund, fixing bugs, refund test passes --- src/exchange-lib/exchange_api_refund.c | 6 +++++- src/exchange-lib/test_exchange_api.c | 26 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src/exchange-lib') diff --git a/src/exchange-lib/exchange_api_refund.c b/src/exchange-lib/exchange_api_refund.c index 82ae5e8ab..3a840c7c4 100644 --- a/src/exchange-lib/exchange_api_refund.c +++ b/src/exchange-lib/exchange_api_refund.c @@ -169,6 +169,10 @@ handle_refund_finished (void *cls, /* Nothing really to verify, this should never happen, we should pass the JSON reply to the application */ break; + case MHD_HTTP_GONE: + /* Kind of normal: the money was already sent to the merchant + (it was too late for the refund). */ + break; case MHD_HTTP_INTERNAL_SERVER_ERROR: /* Server had an internal issue; we should retry, but this API leaves this to the application */ @@ -266,7 +270,7 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, " s:I, s:I," /* transaction id, rtransaction id */ " s:o, s:o}", /* merchant_pub, merchant_sig */ "refund_amount", TALER_JSON_from_amount (amount), - "refund_fee", TALER_JSON_from_amount (amount), + "refund_fee", TALER_JSON_from_amount (refund_fee), "H_contract", GNUNET_JSON_from_data_auto (h_contract), "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "transaction_id", (json_int_t) transaction_id, diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index 169d68f39..6612609fa 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -2926,7 +2926,10 @@ run (void *cls) }, /* Run transfers. Should do nothing as refund deadline blocks it */ { .oc = OC_RUN_AGGREGATOR, - .label = "run-aggregator" }, + .label = "run-aggregator-refund" }, + /* check that aggregator didn't do anything, as expected */ + { .oc = OC_CHECK_BANK_TRANSFERS_EMPTY, + .label = "check-refund-not-run" }, /* Trigger refund */ { .oc = OC_REFUND, .label = "refund-ok", @@ -2949,11 +2952,18 @@ run (void *cls) }, /* Run transfers. This will do the transfer as refund deadline was 0 */ { .oc = OC_RUN_AGGREGATOR, - .label = "run-aggregator" }, + .label = "run-aggregator-3" }, + /* Check that deposit did run */ + { .oc = OC_CHECK_BANK_TRANSFER, + .label = "check_bank_transfer-pre-refund", + .details.check_bank_transfer.amount = "EUR:4.98", + .details.check_bank_transfer.account_debit = 2, + .details.check_bank_transfer.account_credit = 42 + }, /* Run failing refund, as past deadline & aggregation */ { .oc = OC_REFUND, .label = "refund-fail", - .expected_response_code = MHD_HTTP_OK, + .expected_response_code = MHD_HTTP_GONE, .details.refund.amount = "EUR:4.99", .details.refund.fee = "EUR:0.01", .details.refund.deposit_ref = "deposit-refund-2", @@ -3015,6 +3025,16 @@ main (int argc, NULL); GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); + proc = GNUNET_OS_start_process (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-dbinit", + "taler-exchange-dbinit", + "-c", "test_exchange_api.conf", + "-r", + NULL); + GNUNET_OS_process_wait (proc); + GNUNET_OS_process_destroy (proc); exchanged = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, -- cgit v1.2.3