aboutsummaryrefslogtreecommitdiff
path: root/src/exchange-lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange-lib')
-rw-r--r--src/exchange-lib/exchange_api_track_transfer.c6
-rw-r--r--src/exchange-lib/test_exchange_api.c46
2 files changed, 43 insertions, 9 deletions
diff --git a/src/exchange-lib/exchange_api_track_transfer.c b/src/exchange-lib/exchange_api_track_transfer.c
index 819a00adf..dff39eb29 100644
--- a/src/exchange-lib/exchange_api_track_transfer.c
+++ b/src/exchange-lib/exchange_api_track_transfer.c
@@ -87,12 +87,14 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
struct GNUNET_HashCode h_wire;
struct GNUNET_TIME_Absolute exec_time;
struct TALER_Amount total_amount;
+ struct TALER_Amount wire_fee;
struct TALER_MerchantPublicKeyP merchant_pub;
unsigned int num_details;
struct TALER_ExchangePublicKeyP exchange_pub;
struct TALER_ExchangeSignatureP exchange_sig;
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("total", &total_amount),
+ TALER_JSON_spec_amount ("wire_fee", &wire_fee),
GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub),
GNUNET_JSON_spec_fixed_auto ("H_wire", &h_wire),
GNUNET_JSON_spec_absolute_time ("execution_time", &exec_time),
@@ -158,6 +160,8 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
wdp.purpose.size = htonl (sizeof (struct TALER_WireDepositDataPS));
TALER_amount_hton (&wdp.total,
&total_amount);
+ TALER_amount_hton (&wdp.wire_fee,
+ &wire_fee);
wdp.merchant_pub = merchant_pub;
wdp.h_wire = h_wire;
GNUNET_CRYPTO_hash_context_finish (hash_context,
@@ -186,6 +190,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
&h_wire,
exec_time,
&total_amount,
+ &wire_fee,
num_details,
details);
}
@@ -257,6 +262,7 @@ handle_track_transfer_finished (void *cls,
NULL,
GNUNET_TIME_UNIT_ZERO_ABS,
NULL,
+ NULL,
0, NULL);
TALER_EXCHANGE_track_transfer_cancel (wdh);
}
diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c
index 2456d77a7..3e69c25bb 100644
--- a/src/exchange-lib/test_exchange_api.c
+++ b/src/exchange-lib/test_exchange_api.c
@@ -540,6 +540,12 @@ struct Command
*/
const char *total_amount_expected;
+ /**
+ * What is the expected wire fee? Only used if
+ * @e expected_response_code was #MHD_HTTP_OK.
+ */
+ const char *wire_fee_expected;
+
/* TODO: may want to add list of deposits we expected
to see aggregated here in the future. */
@@ -1417,6 +1423,7 @@ wire_cb (void *cls,
* @param execution_time time when the exchange claims to have performed the wire transfer
* @param total_amount total amount of the wire transfer, or NULL if the exchange could
* not provide any @a wtid (set only if @a http_status is #MHD_HTTP_OK)
+ * @param wire_fee wire fee that was charged by the exchange
* @param details_length length of the @a details array
* @param details array with details about the combined transactions
*/
@@ -1429,6 +1436,7 @@ wire_deposits_cb (void *cls,
const struct GNUNET_HashCode *h_wire,
struct GNUNET_TIME_Absolute execution_time,
const struct TALER_Amount *total_amount,
+ const struct TALER_Amount *wire_fee,
unsigned int details_length,
const struct TALER_TrackTransferDetails *details)
{
@@ -1469,6 +1477,24 @@ wire_deposits_cb (void *cls,
fail (is);
return;
}
+ if (GNUNET_OK !=
+ TALER_string_to_amount (cmd->details.wire_deposits.wire_fee_expected,
+ &expected_amount))
+ {
+ GNUNET_break (0);
+ fail (is);
+ return;
+ }
+ if (0 != TALER_amount_cmp (wire_fee,
+ &expected_amount))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Wire fee missmatch to command %s\n",
+ cmd->label);
+ json_dumpf (json, stderr, 0);
+ fail (is);
+ return;
+ }
ref = find_command (is,
cmd->details.wire_deposits.wtid_ref);
GNUNET_assert (NULL != ref);
@@ -2923,28 +2949,28 @@ run (void *cls)
{ .oc = OC_CHECK_BANK_TRANSFER,
.label = "check_bank_transfer-499c",
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
- .details.check_bank_transfer.amount = "EUR:4.99",
+ .details.check_bank_transfer.amount = "EUR:4.98",
.details.check_bank_transfer.account_debit = 2,
.details.check_bank_transfer.account_credit = 42
},
{ .oc = OC_CHECK_BANK_TRANSFER,
.label = "check_bank_transfer-99c1",
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
- .details.check_bank_transfer.amount = "EUR:0.99",
+ .details.check_bank_transfer.amount = "EUR:0.98",
.details.check_bank_transfer.account_debit = 2,
.details.check_bank_transfer.account_credit = 42
},
{ .oc = OC_CHECK_BANK_TRANSFER,
.label = "check_bank_transfer-99c2",
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
- .details.check_bank_transfer.amount = "EUR:0.99",
+ .details.check_bank_transfer.amount = "EUR:0.98",
.details.check_bank_transfer.account_debit = 2,
.details.check_bank_transfer.account_credit = 42
},
{ .oc = OC_CHECK_BANK_TRANSFER,
.label = "check_bank_transfer-9c",
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
- .details.check_bank_transfer.amount = "EUR:0.09",
+ .details.check_bank_transfer.amount = "EUR:0.08",
.details.check_bank_transfer.account_debit = 2,
.details.check_bank_transfer.account_credit = 43
},
@@ -2959,16 +2985,18 @@ run (void *cls)
.details.deposit_wtid.bank_transfer_ref = "check_bank_transfer-499c" },
{ .oc = OC_WIRE_DEPOSITS,
- .label = "wire-deposits-sucess-bank",
+ .label = "wire-deposits-success-bank",
.expected_response_code = MHD_HTTP_OK,
.details.wire_deposits.wtid_ref = "check_bank_transfer-99c1",
- .details.wire_deposits.total_amount_expected = "EUR:0.99" },
+ .details.wire_deposits.total_amount_expected = "EUR:0.98",
+ .details.wire_deposits.wire_fee_expected = "EUR:0.01" },
{ .oc = OC_WIRE_DEPOSITS,
- .label = "wire-deposits-sucess-wtid",
+ .label = "wire-deposits-success-wtid",
.expected_response_code = MHD_HTTP_OK,
.details.wire_deposits.wtid_ref = "deposit-wtid-ok",
- .details.wire_deposits.total_amount_expected = "EUR:4.99" },
+ .details.wire_deposits.total_amount_expected = "EUR:4.98",
+ .details.wire_deposits.wire_fee_expected = "EUR:0.01" },
/* ************** End of tracking API testing************* */
@@ -3030,7 +3058,7 @@ run (void *cls)
{ .oc = OC_CHECK_BANK_TRANSFER,
.label = "check_bank_transfer-pre-refund",
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
- .details.check_bank_transfer.amount = "EUR:4.98",
+ .details.check_bank_transfer.amount = "EUR:4.97",
.details.check_bank_transfer.account_debit = 2,
.details.check_bank_transfer.account_credit = 42
},