diff options
Diffstat (limited to 'src/testing/testing_api_cmd_purse_merge.c')
-rw-r--r-- | src/testing/testing_api_cmd_purse_merge.c | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c index 4d1e8bf4b..cf9d4f996 100644 --- a/src/testing/testing_api_cmd_purse_merge.c +++ b/src/testing/testing_api_cmd_purse_merge.c @@ -72,6 +72,18 @@ struct PurseMergeState struct TALER_TESTING_Interpreter *is; /** + * Hash of the payto://-URI for the reserve we are + * merging into. + */ + struct TALER_PaytoHashP h_payto; + + /** + * Set to the KYC requirement row *if* the exchange replied with + * a request for KYC. + */ + uint64_t requirement_row; + + /** * Reserve history entry that corresponds to this operation. * Will be of type #TALER_EXCHANGE_RTT_MERGE. */ @@ -129,8 +141,9 @@ merge_cb (void *cls, struct PurseMergeState *ds = cls; ds->dh = NULL; - if (MHD_HTTP_OK == dr->hr.http_status) + switch (dr->hr.http_status) { + case MHD_HTTP_OK: ds->reserve_history.type = TALER_EXCHANGE_RTT_MERGE; ds->reserve_history.amount = ds->value_after_fees; GNUNET_assert (GNUNET_OK == @@ -153,21 +166,20 @@ merge_cb (void *cls, = ds->min_age; ds->reserve_history.details.merge_details.flags = TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE; + break; + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + /* KYC required */ + ds->requirement_row = + dr->details.unavailable_for_legal_reasons.requirement_row; + break; } if (ds->expected_response_code != dr->hr.http_status) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u to command %s in %s:%u\n", - dr->hr.http_status, - ds->is->commands[ds->is->ip].label, - __FILE__, - __LINE__); - json_dumpf (dr->hr.reply, - stderr, - 0); - TALER_TESTING_interpreter_fail (ds->is); + TALER_TESTING_unexpected_status (ds->is, + dr->hr.http_status, + ds->expected_response_code); return; } TALER_TESTING_interpreter_next (ds->is); @@ -281,11 +293,35 @@ merge_run (void *cls, } GNUNET_CRYPTO_eddsa_key_get_public (&ds->reserve_priv.eddsa_priv, &ds->reserve_pub.eddsa_pub); + { + char *payto_uri; + const char *exchange_url; + const struct TALER_TESTING_Command *exchange_cmd; + + exchange_cmd = TALER_TESTING_interpreter_get_command (is, + "exchange"); + if (NULL == exchange_cmd) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_exchange_url (exchange_cmd, + &exchange_url)); + payto_uri = TALER_reserve_make_payto (exchange_url, + &ds->reserve_pub); + TALER_payto_hash (payto_uri, + &ds->h_payto); + GNUNET_free (payto_uri); + } GNUNET_CRYPTO_eddsa_key_get_public (&merge_priv->eddsa_priv, &ds->merge_pub.eddsa_pub); ds->merge_timestamp = GNUNET_TIME_timestamp_get (); ds->dh = TALER_EXCHANGE_account_merge ( - is->exchange, + TALER_TESTING_interpreter_get_context (is), + TALER_TESTING_get_exchange_url (is), + TALER_TESTING_get_keys (is), NULL, /* no wad */ &ds->reserve_priv, &ds->purse_pub, @@ -323,10 +359,8 @@ merge_cleanup (void *cls, if (NULL != ds->dh) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Command %u (%s) did not complete\n", - ds->is->ip, - cmd->label); + TALER_TESTING_command_incomplete (ds->is, + cmd->label); TALER_EXCHANGE_account_merge_cancel (ds->dh); ds->dh = NULL; } @@ -357,6 +391,8 @@ merge_traits (void *cls, TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub), TALER_TESTING_make_trait_timestamp (0, &ds->merge_timestamp), + TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row), + TALER_TESTING_make_trait_h_payto (&ds->h_payto), TALER_TESTING_trait_end () }; |