summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_deposits_get.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_deposits_get.c')
-rw-r--r--src/testing/testing_api_cmd_deposits_get.c121
1 files changed, 64 insertions, 57 deletions
diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c
index f2f3f0e39..5d4436e2a 100644
--- a/src/testing/testing_api_cmd_deposits_get.c
+++ b/src/testing/testing_api_cmd_deposits_get.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2020 Taler Systems SA
+ Copyright (C) 2014-2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -40,6 +40,11 @@ struct TrackTransactionState
const char *bank_transfer_reference;
/**
+ * Our command.
+ */
+ const struct TALER_TESTING_Command *cmd;
+
+ /**
* The WTID associated by the transaction being tracked.
*/
struct TALER_WireTransferIdentifierRawP wtid;
@@ -50,12 +55,31 @@ struct TrackTransactionState
unsigned int expected_response_code;
/**
+ * Set to the KYC requirement payto hash *if* the exchange replied with a
+ * request for KYC (#MHD_HTTP_ACCEPTED).
+ * Note: set based on our @e merchant_payto_uri, as
+ * the exchange does not respond with the payto hash.
+ */
+ struct TALER_PaytoHashP h_payto;
+
+ /**
+ * Set to the KYC requirement row *if* the exchange replied with
+ * a request for KYC (#MHD_HTTP_ACCEPTED).
+ */
+ uint64_t requirement_row;
+
+ /**
* Reference to any operation that can provide a transaction.
* Will be the transaction to track.
*/
const char *transaction_reference;
/**
+ * Payto URI of the merchant receiving the deposit.
+ */
+ char *merchant_payto_uri;
+
+ /**
* Index of the coin involved in the transaction. Recall:
* at the exchange, the tracking is done _per coin_.
*/
@@ -80,38 +104,27 @@ struct TrackTransactionState
* line matches our expectations.
*
* @param cls closure.
- * @param hr HTTP response details
- * @param dd data about the wire transfer associated with the deposit
+ * @param dr GET deposit response details
*/
static void
deposit_wtid_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr,
- const struct TALER_EXCHANGE_DepositData *dd)
+ const struct TALER_EXCHANGE_GetDepositResponse *dr)
{
struct TrackTransactionState *tts = cls;
struct TALER_TESTING_Interpreter *is = tts->is;
- struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
tts->tth = NULL;
- if (tts->expected_response_code != hr->http_status)
+ if (tts->expected_response_code != dr->hr.http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d to command %s in %s:%u\n",
- hr->http_status,
- (int) hr->ec,
- cmd->label,
- __FILE__,
- __LINE__);
- json_dumpf (hr->reply,
- stderr,
- 0);
- TALER_TESTING_interpreter_fail (is);
+ TALER_TESTING_unexpected_status (is,
+ dr->hr.http_status,
+ tts->expected_response_code);
return;
}
- switch (hr->http_status)
+ switch (dr->hr.http_status)
{
case MHD_HTTP_OK:
- tts->wtid = dd->wtid;
+ tts->wtid = dr->details.ok.wtid;
if (NULL != tts->bank_transfer_reference)
{
const struct TALER_TESTING_Command *bank_transfer_cmd;
@@ -130,7 +143,6 @@ deposit_wtid_cb (void *cls,
if (GNUNET_OK !=
TALER_TESTING_get_trait_wtid (bank_transfer_cmd,
- 0,
&wtid_want))
{
GNUNET_break (0);
@@ -139,7 +151,7 @@ deposit_wtid_cb (void *cls,
}
/* Compare that expected and gotten subjects match. */
- if (0 != GNUNET_memcmp (&dd->wtid,
+ if (0 != GNUNET_memcmp (&dr->details.ok.wtid,
wtid_want))
{
GNUNET_break (0);
@@ -147,11 +159,13 @@ deposit_wtid_cb (void *cls,
return;
}
}
-
-
break;
case MHD_HTTP_ACCEPTED:
/* allowed, nothing to check here */
+ TALER_payto_hash (tts->merchant_payto_uri,
+ &tts->h_payto);
+ tts->requirement_row
+ = dr->details.accepted.requirement_row;
break;
case MHD_HTTP_NOT_FOUND:
/* allowed, nothing to check here */
@@ -182,11 +196,11 @@ track_transaction_run (void *cls,
struct TALER_CoinSpendPublicKeyP coin_pub;
const json_t *contract_terms;
const json_t *wire_details;
- struct GNUNET_HashCode h_wire_details;
- struct GNUNET_HashCode h_contract_terms;
+ struct TALER_MerchantWireHashP h_wire_details;
+ struct TALER_PrivateContractHashP h_contract_terms;
const struct TALER_MerchantPrivateKeyP *merchant_priv;
- (void) cmd;
+ tts->cmd = cmd;
tts->is = is;
transaction_cmd
= TALER_TESTING_interpreter_lookup_command (tts->is,
@@ -214,17 +228,17 @@ track_transaction_run (void *cls,
/* Get the strings.. */
if (GNUNET_OK !=
TALER_TESTING_get_trait_wire_details (transaction_cmd,
- 0,
&wire_details))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (tts->is);
return;
}
-
+ tts->merchant_payto_uri
+ = GNUNET_strdup (json_string_value (json_object_get (wire_details,
+ "payto_uri")));
if (GNUNET_OK !=
TALER_TESTING_get_trait_contract_terms (transaction_cmd,
- 0,
&contract_terms))
{
GNUNET_break (0);
@@ -251,7 +265,6 @@ track_transaction_run (void *cls,
if (GNUNET_OK !=
TALER_TESTING_get_trait_merchant_priv (transaction_cmd,
- 0,
&merchant_priv))
{
GNUNET_break (0);
@@ -259,13 +272,17 @@ track_transaction_run (void *cls,
return;
}
- tts->tth = TALER_EXCHANGE_deposits_get (is->exchange,
- merchant_priv,
- &h_wire_details,
- &h_contract_terms,
- &coin_pub,
- &deposit_wtid_cb,
- tts);
+ tts->tth = TALER_EXCHANGE_deposits_get (
+ TALER_TESTING_interpreter_get_context (is),
+ TALER_TESTING_get_exchange_url (is),
+ TALER_TESTING_get_keys (is),
+ merchant_priv,
+ &h_wire_details,
+ &h_contract_terms,
+ &coin_pub,
+ GNUNET_TIME_UNIT_ZERO,
+ &deposit_wtid_cb,
+ tts);
GNUNET_assert (NULL != tts->tth);
}
@@ -285,13 +302,12 @@ track_transaction_cleanup (void *cls,
if (NULL != tts->tth)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Command %u (%s) did not complete\n",
- tts->is->ip,
- cmd->label);
+ TALER_TESTING_command_incomplete (tts->is,
+ cmd->label);
TALER_EXCHANGE_deposits_get_cancel (tts->tth);
tts->tth = NULL;
}
+ GNUNET_free (tts->merchant_payto_uri);
GNUNET_free (tts);
}
@@ -305,7 +321,7 @@ track_transaction_cleanup (void *cls,
* @param index index number of the object to offer.
* @return #GNUNET_OK on success.
*/
-static int
+static enum GNUNET_GenericReturnValue
track_transaction_traits (void *cls,
const void **ret,
const char *trait,
@@ -313,7 +329,11 @@ track_transaction_traits (void *cls,
{
struct TrackTransactionState *tts = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_wtid (0, &tts->wtid),
+ TALER_TESTING_make_trait_wtid (&tts->wtid),
+ TALER_TESTING_make_trait_legi_requirement_row (
+ &tts->requirement_row),
+ TALER_TESTING_make_trait_h_payto (&tts->h_payto),
+ TALER_TESTING_make_trait_payto_uri (tts->merchant_payto_uri),
TALER_TESTING_trait_end ()
};
@@ -324,19 +344,6 @@ track_transaction_traits (void *cls,
}
-/**
- * Create a "track transaction" command.
- *
- * @param label the command label.
- * @param transaction_reference reference to a deposit operation,
- * will be used to get the input data for the track.
- * @param coin_index index of the coin involved in the transaction.
- * @param expected_response_code expected HTTP response code.
- * @param bank_transfer_reference reference to a command that
- * can offer a WTID so as to check that against what WTID
- * the tracked operation has. Set as NULL if not needed.
- * @return the command.
- */
struct TALER_TESTING_Command
TALER_TESTING_cmd_track_transaction (const char *label,
const char *transaction_reference,