diff options
Diffstat (limited to 'src/testing/testing_api_cmd_reserve_purse.c')
-rw-r--r-- | src/testing/testing_api_cmd_reserve_purse.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c index cd9ea1ea3..ef6964f26 100644 --- a/src/testing/testing_api_cmd_reserve_purse.c +++ b/src/testing/testing_api_cmd_reserve_purse.c @@ -104,10 +104,10 @@ struct ReservePurseState struct TALER_PaytoHashP h_payto; /** - * Set to the KYC UUID *if* the exchange replied with + * Set to the KYC requirement row *if* the exchange replied with * a request for KYC. */ - uint64_t kyc_uuid; + uint64_t requirement_row; /** * Contract terms for the purse. @@ -129,6 +129,10 @@ struct ReservePurseState */ unsigned int expected_response_code; + /** + * True to pay the purse fee. + */ + bool pay_purse_fee; }; @@ -149,24 +153,17 @@ 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->kyc_uuid = - dr->details.unavailable_for_legal_reasons.legitimization_uuid; + ds->requirement_row = + dr->details.unavailable_for_legal_reasons.requirement_row; break; } TALER_TESTING_interpreter_next (ds->is); @@ -217,8 +214,21 @@ purse_run (void *cls, { char *payto_uri; - - payto_uri = TALER_reserve_make_payto (is->exchange_url, + 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); @@ -232,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 #7274: 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); @@ -269,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; } @@ -309,7 +319,7 @@ 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_legitimization_uuid (&ds->kyc_uuid), + TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row), TALER_TESTING_make_trait_h_payto (&ds->h_payto), TALER_TESTING_trait_end () }; @@ -327,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) { @@ -339,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; |