summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_kyc_wallet_get.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_kyc_wallet_get.c')
-rw-r--r--src/testing/testing_api_cmd_kyc_wallet_get.c82
1 files changed, 53 insertions, 29 deletions
diff --git a/src/testing/testing_api_cmd_kyc_wallet_get.c b/src/testing/testing_api_cmd_kyc_wallet_get.c
index 91ad09ff9..ffb143ffb 100644
--- a/src/testing/testing_api_cmd_kyc_wallet_get.c
+++ b/src/testing/testing_api_cmd_kyc_wallet_get.c
@@ -49,6 +49,11 @@ struct KycWalletGetState
char *reserve_payto_uri;
/**
+ * Our command.
+ */
+ const struct TALER_TESTING_Command *cmd;
+
+ /**
* Command to get a reserve private key from.
*/
const char *reserve_reference;
@@ -59,10 +64,16 @@ struct KycWalletGetState
unsigned int expected_response_code;
/**
- * Set to the KYC UUID *if* the exchange replied with
- * a request for KYC (#MHD_HTTP_ACCEPTED).
+ * Set to the KYC requirement payto hash *if* the exchange replied with a
+ * request for KYC (#MHD_HTTP_OK).
+ */
+ struct TALER_PaytoHashP h_payto;
+
+ /**
+ * Set to the KYC requirement row *if* the exchange replied with
+ * a request for KYC (#MHD_HTTP_OK).
*/
- uint64_t kyc_uuid;
+ uint64_t requirement_row;
/**
* Handle to the "track transaction" pending operation.
@@ -70,6 +81,11 @@ struct KycWalletGetState
struct TALER_EXCHANGE_KycWalletHandle *kwh;
/**
+ * Balance to pass to the exchange.
+ */
+ struct TALER_Amount balance;
+
+ /**
* Interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
@@ -88,33 +104,29 @@ wallet_kyc_cb (void *cls,
{
struct KycWalletGetState *kwg = cls;
struct TALER_TESTING_Interpreter *is = kwg->is;
- struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
kwg->kwh = NULL;
if (kwg->expected_response_code != wkr->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d (wanted %u) to command %s in %s:%u\n",
- wkr->http_status,
- (int) wkr->ec,
- kwg->expected_response_code,
- cmd->label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (is);
+ TALER_TESTING_unexpected_status (is,
+ wkr->http_status,
+ kwg->expected_response_code);
return;
}
switch (wkr->http_status)
{
- case MHD_HTTP_OK:
- kwg->kyc_uuid = wkr->payment_target_uuid;
- break;
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
+ case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
+ kwg->requirement_row
+ = wkr->details.unavailable_for_legal_reasons.requirement_row;
+ kwg->h_payto
+ = wkr->details.unavailable_for_legal_reasons.h_payto;
+ break;
default:
GNUNET_break (0);
break;
@@ -136,9 +148,16 @@ wallet_kyc_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct KycWalletGetState *kwg = cls;
+ const char *exchange_url;
- (void) cmd;
+ kwg->cmd = cmd;
kwg->is = is;
+ exchange_url = TALER_TESTING_get_exchange_url (is);
+ if (NULL == exchange_url)
+ {
+ GNUNET_break (0);
+ return;
+ }
if (NULL != kwg->reserve_reference)
{
const struct TALER_TESTING_Command *res_cmd;
@@ -170,12 +189,15 @@ wallet_kyc_run (void *cls,
GNUNET_CRYPTO_eddsa_key_get_public (&kwg->reserve_priv.eddsa_priv,
&kwg->reserve_pub.eddsa_pub);
kwg->reserve_payto_uri
- = TALER_payto_from_reserve (TALER_EXCHANGE_get_base_url (is->exchange),
+ = TALER_reserve_make_payto (exchange_url,
&kwg->reserve_pub);
- kwg->kwh = TALER_EXCHANGE_kyc_wallet (is->exchange,
- &kwg->reserve_priv,
- &wallet_kyc_cb,
- kwg);
+ kwg->kwh = TALER_EXCHANGE_kyc_wallet (
+ TALER_TESTING_interpreter_get_context (is),
+ exchange_url,
+ &kwg->reserve_priv,
+ &kwg->balance,
+ &wallet_kyc_cb,
+ kwg);
GNUNET_assert (NULL != kwg->kwh);
}
@@ -195,10 +217,8 @@ wallet_kyc_cleanup (void *cls,
if (NULL != kwg->kwh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Command %u (%s) did not complete\n",
- kwg->is->ip,
- cmd->label);
+ TALER_TESTING_command_incomplete (kwg->is,
+ cmd->label);
TALER_EXCHANGE_kyc_wallet_cancel (kwg->kwh);
kwg->kwh = NULL;
}
@@ -226,9 +246,9 @@ wallet_kyc_traits (void *cls,
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_reserve_priv (&kwg->reserve_priv),
TALER_TESTING_make_trait_reserve_pub (&kwg->reserve_pub),
- TALER_TESTING_make_trait_payment_target_uuid (&kwg->kyc_uuid),
- TALER_TESTING_make_trait_payto_uri (
- (const char **) &kwg->reserve_payto_uri),
+ TALER_TESTING_make_trait_legi_requirement_row (&kwg->requirement_row),
+ TALER_TESTING_make_trait_h_payto (&kwg->h_payto),
+ TALER_TESTING_make_trait_payto_uri (kwg->reserve_payto_uri),
TALER_TESTING_trait_end ()
};
@@ -242,6 +262,7 @@ wallet_kyc_traits (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_wallet_kyc_get (const char *label,
const char *reserve_reference,
+ const char *threshold_balance,
unsigned int expected_response_code)
{
struct KycWalletGetState *kwg;
@@ -249,6 +270,9 @@ TALER_TESTING_cmd_wallet_kyc_get (const char *label,
kwg = GNUNET_new (struct KycWalletGetState);
kwg->reserve_reference = reserve_reference;
kwg->expected_response_code = expected_response_code;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (threshold_balance,
+ &kwg->balance));
{
struct TALER_TESTING_Command cmd = {
.cls = kwg,