diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/testing_api_cmd_bank_admin_add_incoming.c | 168 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_bank_history_credit.c | 40 |
2 files changed, 106 insertions, 102 deletions
diff --git a/src/lib/testing_api_cmd_bank_admin_add_incoming.c b/src/lib/testing_api_cmd_bank_admin_add_incoming.c index e490fce25..04e7d5637 100644 --- a/src/lib/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/lib/testing_api_cmd_bank_admin_add_incoming.c @@ -17,7 +17,7 @@ <http://www.gnu.org/licenses/> */ /** - * @file exchange-lib/testing_api_cmd_admin_add_incoming.c + * @file lib/testing_api_cmd_admin_add_incoming.c * @brief implementation of a bank /admin/add-incoming command * @author Christian Grothoff * @author Marcello Stanisci @@ -59,6 +59,11 @@ struct AdminAddIncomingState const char *payto_debit_account; /** + * Money sender account URL. + */ + char *payto_credit_account; + + /** * Username to use for authentication. */ struct TALER_BANK_AuthenticationData auth; @@ -376,6 +381,7 @@ admin_add_incoming_cleanup (void *cls, GNUNET_SCHEDULER_cancel (fts->retry_task); fts->retry_task = NULL; } + GNUNET_free (fts->payto_credit_account); GNUNET_free (fts); } @@ -402,7 +408,8 @@ admin_add_incoming_traits (void *cls, TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT, fts->payto_debit_account), TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT, - fts->exchange_credit_url), + fts->payto_credit_account), + TALER_TESTING_make_trait_url (0, fts->exchange_credit_url), TALER_TESTING_make_trait_amount_obj (0, &fts->amount), TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp), TALER_TESTING_make_trait_reserve_priv (0, @@ -420,52 +427,88 @@ admin_add_incoming_traits (void *cls, /** - * Create admin/add-incoming command. + * Create internal state for "/admin/add-incoming" CMD. * - * @param label command label. - * @param amount amount to transfer. - * @param exchange_base_url base URL of the account that receives this - * wire transer (which account receives money). - * @param payto_debit_account which account sends money. + * @param amount the amount to transfer. + * @param account_bank_url base URL of the exchange account receiving the money + * @param payto_debit_account which account sends money * @param auth authentication data - * @return the command. + * @return the internal state */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_admin_add_incoming - (const char *label, - const char *amount, - const char *exchange_base_url, - const struct TALER_BANK_AuthenticationData *auth, - const char *payto_debit_account) +static struct AdminAddIncomingState * +make_fts (const char *amount, + const char *exchange_base_url, + const struct TALER_BANK_AuthenticationData *auth, + const char *payto_debit_account) { struct AdminAddIncomingState *fts; fts = GNUNET_new (struct AdminAddIncomingState); fts->exchange_credit_url = exchange_base_url; fts->payto_debit_account = payto_debit_account; + fts->payto_credit_account + = TALER_payto_xtalerbank_make2 (exchange_base_url); fts->auth = *auth; if (GNUNET_OK != TALER_string_to_amount (amount, &fts->amount)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse amount `%s' at %s\n", - amount, - label); + "Failed to parse amount `%s'\n", + amount); GNUNET_assert (0); } + return fts; +} - { - struct TALER_TESTING_Command cmd = { - .cls = fts, - .label = label, - .run = &admin_add_incoming_run, - .cleanup = &admin_add_incoming_cleanup, - .traits = &admin_add_incoming_traits - }; - - return cmd; - } + +/** + * Helper function to create admin/add-incoming command. + * + * @param label command label. + * @param fts internal state to use + * @return the command. + */ +static struct TALER_TESTING_Command +make_command (const char *label, + struct AdminAddIncomingState *fts) +{ + struct TALER_TESTING_Command cmd = { + .cls = fts, + .label = label, + .run = &admin_add_incoming_run, + .cleanup = &admin_add_incoming_cleanup, + .traits = &admin_add_incoming_traits + }; + + return cmd; +} + + +/** + * Create admin/add-incoming command. + * + * @param label command label. + * @param amount amount to transfer. + * @param exchange_base_url base URL of the account that receives this + * wire transer (which account receives money). + * @param payto_debit_account which account sends money. + * @param auth authentication data + * @return the command. + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_admin_add_incoming + (const char *label, + const char *amount, + const char *exchange_base_url, + const struct TALER_BANK_AuthenticationData *auth, + const char *payto_debit_account) +{ + return make_command (label, + make_fts (amount, + exchange_base_url, + auth, + payto_debit_account)); } @@ -495,32 +538,13 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref { struct AdminAddIncomingState *fts; - fts = GNUNET_new (struct AdminAddIncomingState); - fts->exchange_credit_url = account_base_url; - fts->payto_debit_account = payto_debit_account; - fts->auth = *auth; + fts = make_fts (amount, + account_base_url, + auth, + payto_debit_account); fts->reserve_reference = ref; - if (GNUNET_OK != - TALER_string_to_amount (amount, - &fts->amount)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse amount `%s' at %s\n", - amount, - label); - GNUNET_assert (0); - } - { - struct TALER_TESTING_Command cmd = { - .cls = fts, - .label = label, - .run = &admin_add_incoming_run, - .cleanup = &admin_add_incoming_cleanup, - .traits = &admin_add_incoming_traits - }; - - return cmd; - } + return make_command (label, + fts); } @@ -557,33 +581,15 @@ TALER_TESTING_cmd_admin_add_incoming_with_instance { struct AdminAddIncomingState *fts; - fts = GNUNET_new (struct AdminAddIncomingState); - fts->exchange_credit_url = account_base_url; - fts->payto_debit_account = payto_debit_account; - fts->auth = *auth; + fts = make_fts (amount, + account_base_url, + auth, + payto_debit_account); fts->instance = instance; fts->config_filename = config_filename; - if (GNUNET_OK != - TALER_string_to_amount (amount, - &fts->amount)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse amount `%s' at %s\n", - amount, - label); - GNUNET_assert (0); - } - { - struct TALER_TESTING_Command cmd = { - .cls = fts, - .label = label, - .run = &admin_add_incoming_run, - .cleanup = &admin_add_incoming_cleanup, - .traits = &admin_add_incoming_traits - }; - - return cmd; - } + + return make_command (label, + fts); } @@ -607,4 +613,4 @@ TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd) } -/* end of testing_api_cmd_admin_add_incoming.c */ +/* end of testing_api_cmd_bank_admin_add_incoming.c */ diff --git a/src/lib/testing_api_cmd_bank_history_credit.c b/src/lib/testing_api_cmd_bank_history_credit.c index 40ec99162..d2f962e20 100644 --- a/src/lib/testing_api_cmd_bank_history_credit.c +++ b/src/lib/testing_api_cmd_bank_history_credit.c @@ -304,7 +304,6 @@ build_history (struct TALER_TESTING_Interpreter *is, continue; /* skip until we find the marker */ TALER_LOG_DEBUG ("Found first row\n"); - if (build_history_hit_limit (total, hs, pos)) @@ -312,16 +311,14 @@ build_history (struct TALER_TESTING_Interpreter *is, TALER_LOG_DEBUG ("Hit history limit\n"); break; } - - - GNUNET_assert - (GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT - (pos, &credit_account)); - - GNUNET_assert - (GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT - (pos, &debit_account)); - + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_payto (pos, + TALER_TESTING_PT_CREDIT, + &credit_account)); + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_payto (pos, + TALER_TESTING_PT_DEBIT, + &debit_account)); TALER_LOG_INFO ("Potential history element:" " %s->%s; my account: %s\n", debit_account, @@ -365,8 +362,9 @@ build_history (struct TALER_TESTING_Interpreter *is, const char *credit_account; const char *debit_account; - if (GNUNET_OK != TALER_TESTING_GET_TRAIT_ROW_ID - (pos, &row_id)) + if (GNUNET_OK != + TALER_TESTING_GET_TRAIT_ROW_ID (pos, + &row_id)) continue; if (NULL != row_id_start) @@ -401,14 +399,14 @@ build_history (struct TALER_TESTING_Interpreter *is, break; } - GNUNET_assert - (GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT - (pos, &credit_account)); - - GNUNET_assert - (GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT - (pos, &debit_account)); - + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_payto (pos, + TALER_TESTING_PT_CREDIT, + &credit_account)); + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_payto (pos, + TALER_TESTING_PT_DEBIT, + &debit_account)); TALER_LOG_INFO ("Potential history bit:" " %s->%s; my account: %s\n", debit_account, |