diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-01-17 20:42:24 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-01-17 20:42:24 +0100 |
commit | 90c411bc190126e3b2641e31d821233c83dcfecb (patch) | |
tree | 521b3d71b8585a5bc309fb4043443aec32ba1aba /src | |
parent | fad5a2268017c647d2b86b75ba28115345a550c4 (diff) | |
download | exchange-90c411bc190126e3b2641e31d821233c83dcfecb.tar.xz |
sort out URL types more nicely
Diffstat (limited to 'src')
-rw-r--r-- | src/include/taler_testing_lib.h | 27 | ||||
-rw-r--r-- | src/lib/exchange_api_common.c | 6 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_bank_admin_add_incoming.c | 3 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_bank_check.c | 46 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_bank_history_credit.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_bank_history_debit.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_bank_transfer.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_serialize_keys.c | 44 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_withdraw.c | 48 |
9 files changed, 101 insertions, 79 deletions
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 7b286f94e..c52635508 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -2352,6 +2352,29 @@ TALER_TESTING_make_trait_wtid (unsigned int index, /** + * Different types of URLs that appear in traits. + */ +enum TALER_TESTING_URL_Type +{ + /** + * Category of last resort. Should not be used. + */ + TALER_TESTING_UT_UNDEFINED = 0, + + /** + * HTTP base URL of an exchange (API), as for example + * given in wire transfers subjects made by the aggregator. + */ + TALER_TESTING_UT_EXCHANGE_BASE_URL = 1, + + /** + * HTTP URL of the exchange's bank account at the bank. + */ + TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL = 2 +}; + + +/** * Offer HTTP url in a trait. * * @param index which url is to be picked, @@ -2360,7 +2383,7 @@ TALER_TESTING_make_trait_wtid (unsigned int index, * @return the trait. */ struct TALER_TESTING_Trait -TALER_TESTING_make_trait_url (unsigned int index, +TALER_TESTING_make_trait_url (enum TALER_TESTING_URL_Type index, const char *url); @@ -2375,7 +2398,7 @@ TALER_TESTING_make_trait_url (unsigned int index, */ int TALER_TESTING_get_trait_url (const struct TALER_TESTING_Command *cmd, - unsigned int index, + enum TALER_TESTING_URL_Type index, const char **url); diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 649752021..2e3cb8d64 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -141,7 +141,7 @@ TALER_EXCHANGE_verify_coin_history (const struct &dr.deposit_fee); if ( (GNUNET_YES != TALER_amount_cmp_currency (&fee, - &dki->fee_deposit)) || + &dk->fee_deposit)) || (0 != TALER_amount_cmp (&fee, &dk->fee_deposit)) ) @@ -193,7 +193,7 @@ TALER_EXCHANGE_verify_coin_history (const struct &rm.melt_fee); if ( (GNUNET_YES != TALER_amount_cmp_currency (&fee, - &dki->fee_refresh)) || + &dk->fee_refresh)) || (0 != TALER_amount_cmp (&fee, &dk->fee_refresh)) ) @@ -257,7 +257,7 @@ TALER_EXCHANGE_verify_coin_history (const struct &rr.refund_fee); if ( (GNUNET_YES != TALER_amount_cmp_currency (&fee, - &dki->fee_refund)) || + &dk->fee_refund)) || (0 != TALER_amount_cmp (&fee, &dk->fee_refund)) ) 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 761e66171..bdcc65b8a 100644 --- a/src/lib/testing_api_cmd_bank_admin_add_incoming.c +++ b/src/lib/testing_api_cmd_bank_admin_add_incoming.c @@ -409,7 +409,8 @@ admin_add_incoming_traits (void *cls, fts->payto_debit_account), TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT, fts->payto_credit_account), - TALER_TESTING_make_trait_url (0, fts->exchange_credit_url), + TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL, + 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, diff --git a/src/lib/testing_api_cmd_bank_check.c b/src/lib/testing_api_cmd_bank_check.c index 5c10e2a68..3ac4b87cd 100644 --- a/src/lib/testing_api_cmd_bank_check.c +++ b/src/lib/testing_api_cmd_bank_check.c @@ -124,29 +124,29 @@ check_bank_transfer_run (void *cls, (is), bcs->deposit_reference, bcs->deposit_reference); - deposit_cmd = TALER_TESTING_interpreter_lookup_command - (is, bcs->deposit_reference); - + deposit_cmd + = TALER_TESTING_interpreter_lookup_command (is, + bcs->deposit_reference); if (NULL == deposit_cmd) TALER_TESTING_FAIL (is); - - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_amount_obj (deposit_cmd, - 0, - &amount_ptr)); + if ( (GNUNET_OK != + TALER_TESTING_get_trait_amount_obj (deposit_cmd, + 0, + &amount_ptr)) || + (GNUNET_OK != + TALER_TESTING_get_trait_payto (deposit_cmd, + TALER_TESTING_PT_DEBIT, + &debit_payto)) || + (GNUNET_OK != + TALER_TESTING_get_trait_payto (deposit_cmd, + TALER_TESTING_PT_CREDIT, + &credit_payto)) || + (GNUNET_OK != + TALER_TESTING_get_trait_url (deposit_cmd, + TALER_TESTING_UT_EXCHANGE_BASE_URL, + &exchange_base_url)) ) + TALER_TESTING_FAIL (is); amount = *amount_ptr; - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_payto (deposit_cmd, - TALER_TESTING_PT_DEBIT, - &debit_payto)); - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_payto (deposit_cmd, - TALER_TESTING_PT_CREDIT, - &credit_payto)); - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_url (deposit_cmd, - 0, /* TODO: check 0 works! */ - &exchange_base_url)); } @@ -218,8 +218,10 @@ check_bank_transfer_traits (void *cls, struct BankCheckState *bcs = cls; struct TALER_WireTransferIdentifierRawP *wtid_ptr = &bcs->wtid; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_wtid (0, wtid_ptr), - TALER_TESTING_make_trait_url (0, bcs->exchange_base_url), + TALER_TESTING_make_trait_wtid (0, + wtid_ptr), + TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL, + bcs->exchange_base_url), TALER_TESTING_trait_end () }; diff --git a/src/lib/testing_api_cmd_bank_history_credit.c b/src/lib/testing_api_cmd_bank_history_credit.c index 24af2e6f0..2b6eb41ea 100644 --- a/src/lib/testing_api_cmd_bank_history_credit.c +++ b/src/lib/testing_api_cmd_bank_history_credit.c @@ -279,7 +279,7 @@ build_history (struct TALER_TESTING_Interpreter *is, &reserve_pub)) || (GNUNET_OK != TALER_TESTING_get_trait_url (cmd, - 0, + TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL, &exchange_credit_url)) ) continue; /* not an interesting event */ /* Seek "/history" starting row. */ diff --git a/src/lib/testing_api_cmd_bank_history_debit.c b/src/lib/testing_api_cmd_bank_history_debit.c index 4622ab077..6ca3942b1 100644 --- a/src/lib/testing_api_cmd_bank_history_debit.c +++ b/src/lib/testing_api_cmd_bank_history_debit.c @@ -285,7 +285,7 @@ build_history (struct TALER_TESTING_Interpreter *is, &wtid)) || (GNUNET_OK != TALER_TESTING_get_trait_url (cmd, - 0, + TALER_TESTING_UT_EXCHANGE_BASE_URL, &exchange_base_url)) ) continue; /* not an event we care about */ /* Seek "/history" starting row. */ diff --git a/src/lib/testing_api_cmd_bank_transfer.c b/src/lib/testing_api_cmd_bank_transfer.c index 159c0669b..be5a24329 100644 --- a/src/lib/testing_api_cmd_bank_transfer.c +++ b/src/lib/testing_api_cmd_bank_transfer.c @@ -308,7 +308,7 @@ transfer_traits (void *cls, { struct TransferState *fts = cls; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_url (0, + TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL, fts->exchange_base_url), TALER_TESTING_make_trait_bank_row (&fts->serial_id), TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT, diff --git a/src/lib/testing_api_cmd_serialize_keys.c b/src/lib/testing_api_cmd_serialize_keys.c index aa07b1f35..932ee8324 100644 --- a/src/lib/testing_api_cmd_serialize_keys.c +++ b/src/lib/testing_api_cmd_serialize_keys.c @@ -144,7 +144,8 @@ serialize_keys_traits (void *cls, struct SerializeKeysState *sks = cls; struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_exchange_keys (0, sks->keys), - TALER_TESTING_make_trait_url (0, sks->exchange_url), + TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL, + sks->exchange_url), TALER_TESTING_trait_end () }; @@ -192,12 +193,10 @@ connect_with_state_run (void *cls, return; } - GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_exchange_keys - (state_cmd, - 0, - &serialized_keys)); - + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_exchange_keys (state_cmd, + 0, + &serialized_keys)); { char *dump; @@ -208,21 +207,17 @@ connect_with_state_run (void *cls, free (dump); } - GNUNET_assert - (GNUNET_OK == TALER_TESTING_get_trait_url - (state_cmd, - 0, - &exchange_url)); - - is->exchange = TALER_EXCHANGE_connect - (is->ctx, - exchange_url, - TALER_TESTING_cert_cb, - cwss, - TALER_EXCHANGE_OPTION_DATA, - serialized_keys, - TALER_EXCHANGE_OPTION_END); - + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_url (state_cmd, + TALER_TESTING_UT_EXCHANGE_BASE_URL, + &exchange_url)); + is->exchange = TALER_EXCHANGE_connect (is->ctx, + exchange_url, + TALER_TESTING_cert_cb, + cwss, + TALER_EXCHANGE_OPTION_DATA, + serialized_keys, + TALER_EXCHANGE_OPTION_END); cwss->consumed = GNUNET_YES; } @@ -235,9 +230,8 @@ connect_with_state_run (void *cls, * @param cmd the command which is being cleaned up. */ static void -connect_with_state_cleanup - (void *cls, - const struct TALER_TESTING_Command *cmd) +connect_with_state_cleanup (void *cls, + const struct TALER_TESTING_Command *cmd) { struct ConnectWithStateState *cwss = cls; diff --git a/src/lib/testing_api_cmd_withdraw.c b/src/lib/testing_api_cmd_withdraw.c index 5ebec44c5..b01209b50 100644 --- a/src/lib/testing_api_cmd_withdraw.c +++ b/src/lib/testing_api_cmd_withdraw.c @@ -385,30 +385,32 @@ withdraw_traits (void *cls, if (NULL == ws->exchange_url) ws->exchange_url = GNUNET_strdup (TALER_EXCHANGE_get_base_url (ws->is->exchange)); + { + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_coin_priv (0 /* only one coin */, + &ws->ps.coin_priv), + TALER_TESTING_make_trait_blinding_key (0 /* only one coin */, + &ws->ps.blinding_key), + TALER_TESTING_make_trait_denom_pub (0 /* only one coin */, + ws->pk), + TALER_TESTING_make_trait_denom_sig (0 /* only one coin */, + &ws->sig), + TALER_TESTING_make_trait_reserve_priv (0, + reserve_priv), + TALER_TESTING_make_trait_reserve_pub (0, + reserve_pub), + TALER_TESTING_make_trait_amount_obj (0, + &ws->amount), + TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BASE_URL, + ws->exchange_url), + TALER_TESTING_trait_end () + }; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_coin_priv (0 /* only one coin */, - &ws->ps.coin_priv), - TALER_TESTING_make_trait_blinding_key (0 /* only one coin */, - &ws->ps.blinding_key), - TALER_TESTING_make_trait_denom_pub (0 /* only one coin */, - ws->pk), - TALER_TESTING_make_trait_denom_sig (0 /* only one coin */, - &ws->sig), - TALER_TESTING_make_trait_reserve_priv (0, - reserve_priv), - TALER_TESTING_make_trait_reserve_pub (0, - reserve_pub), - TALER_TESTING_make_trait_amount_obj (0, - &ws->amount), - TALER_TESTING_make_trait_url (0, ws->exchange_url), - TALER_TESTING_trait_end () - }; - - return TALER_TESTING_get_trait (traits, - ret, - trait, - index); + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); + } } |