diff options
Diffstat (limited to 'src/testing/testing_api_cmd_reserve_purse.c')
-rw-r--r-- | src/testing/testing_api_cmd_reserve_purse.c | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index 488790888..ef6964f26 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -98,6 +98,18 @@ struct ReservePurseState struct GNUNET_TIME_Timestamp purse_expiration; /** + * 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; + + /** * Contract terms for the purse. */ json_t *contract_terms; @@ -117,6 +129,10 @@ struct ReservePurseState */ unsigned int expected_response_code; + /** + * True to pay the purse fee. + */ + bool pay_purse_fee; }; @@ -137,18 +153,19 @@ purse_cb (void *cls, ds->reserve_sig = *dr->reserve_sig; 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; } + switch (dr->hr.http_status) + { + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + /* KYC required */ + ds->requirement_row = + dr->details.unavailable_for_legal_reasons.requirement_row; + break; + } TALER_TESTING_interpreter_next (ds->is); } @@ -194,6 +211,30 @@ purse_run (void *cls, GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv); ds->purse_expiration = GNUNET_TIME_absolute_to_timestamp ( GNUNET_TIME_relative_to_absolute (ds->expiration_rel)); + + { + 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_assert (0 == json_object_set_new ( ds->contract_terms, @@ -201,14 +242,16 @@ purse_run (void *cls, GNUNET_JSON_from_timestamp (ds->purse_expiration))); ds->merge_timestamp = GNUNET_TIME_timestamp_get (); ds->dh = TALER_EXCHANGE_purse_create_with_merge ( - is->exchange, + TALER_TESTING_interpreter_get_context (is), + TALER_TESTING_get_exchange_url (is), + TALER_TESTING_get_keys (is), &ds->reserve_priv, &ds->purse_priv, &ds->merge_priv, &ds->contract_priv, ds->contract_terms, true /* upload contract */, - true /* do pay purse fee -- FIXME: make this a choice to test this case; then update testing_api_cmd_purse_deposit flags logic to match! */, + ds->pay_purse_fee, ds->merge_timestamp, &purse_cb, ds); @@ -238,10 +281,8 @@ purse_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_purse_create_with_merge_cancel (ds->dh); ds->dh = NULL; } @@ -278,6 +319,8 @@ purse_traits (void *cls, TALER_TESTING_make_trait_reserve_priv (&ds->reserve_priv), TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub), TALER_TESTING_make_trait_reserve_sig (&ds->reserve_sig), + TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row), + TALER_TESTING_make_trait_h_payto (&ds->h_payto), TALER_TESTING_trait_end () }; @@ -294,6 +337,7 @@ TALER_TESTING_cmd_purse_create_with_reserve ( unsigned int expected_http_status, const char *contract_terms, bool upload_contract, + bool pay_purse_fee, struct GNUNET_TIME_Relative expiration, const char *reserve_ref) { @@ -306,6 +350,7 @@ TALER_TESTING_cmd_purse_create_with_reserve ( 0 /* flags */, &err); GNUNET_assert (NULL != ds->contract_terms); + ds->pay_purse_fee = pay_purse_fee; ds->reserve_ref = reserve_ref; ds->expected_response_code = expected_http_status; |