helpers return exchange base url from config.

This commit is contained in:
Marcello Stanisci 2018-02-28 16:15:18 +01:00
parent 6b7ad9c50d
commit ed8dfac6db
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
4 changed files with 48 additions and 22 deletions

View File

@ -47,6 +47,10 @@
#define CONFIG_FILE_EXTENDED \ #define CONFIG_FILE_EXTENDED \
"test_exchange_api_keys_cherry_picking_extended.conf" "test_exchange_api_keys_cherry_picking_extended.conf"
/**
* Exchange base URL; mainly purpose is to make the compiler happy.
*/
char *exchange_url;
/** /**
* Main function that will tell the interpreter what commands to * Main function that will tell the interpreter what commands to
@ -107,7 +111,8 @@ main (int argc,
/* @helpers. Run keyup, create tables, ... Note: it /* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see * fetches the port number from config in order to see
* if it's available. */ * if it's available. */
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE)) switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
&exchange_url))
{ {
case GNUNET_SYSERR: case GNUNET_SYSERR:
GNUNET_break (0); GNUNET_break (0);

View File

@ -49,11 +49,11 @@
static char *fakebank_url; static char *fakebank_url;
/** /**
* FIXME: what about putting exchange_url also global * Exchange base URL as it appears in the configuration. Note
* here? Right now, the exchange port is being "bounced" * that it might differ from the one where the exchange actually
* between functions before exchange_url is constructed * listens from.
* and TALER_EXCHANGE_connect() is called with that.
*/ */
static char *exchange_url;
/** /**
* Account number of the exchange at the bank. * Account number of the exchange at the bank.
@ -103,7 +103,7 @@ static char *fakebank_url;
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ #define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_fakebank_transfer (label, amount, \ TALER_TESTING_cmd_fakebank_transfer (label, amount, \
fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ fakebank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \
USER_LOGIN_NAME, USER_LOGIN_PASS, "https://exchange.com/") USER_LOGIN_NAME, USER_LOGIN_PASS, exchange_url)
/** /**
* Run wire transfer of funds from some user's account to the * Run wire transfer of funds from some user's account to the
@ -116,7 +116,7 @@ static char *fakebank_url;
TALER_TESTING_cmd_fakebank_transfer_with_subject \ TALER_TESTING_cmd_fakebank_transfer_with_subject \
(label, amount, fakebank_url, USER_ACCOUNT_NO, \ (label, amount, fakebank_url, USER_ACCOUNT_NO, \
EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \ EXCHANGE_ACCOUNT_NO, USER_LOGIN_NAME, USER_LOGIN_PASS, \
subject, "https://exchange.com/") subject, exchange_url)
/** /**
* Main function that will tell the interpreter what commands to * Main function that will tell the interpreter what commands to
@ -391,23 +391,23 @@ run (void *cls,
* Check all the transfers took place. * Check all the transfers took place.
*/ */
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-499c", "https://exchange.com/", ("check_bank_transfer-499c", exchange_url,
"EUR:4.98", 2, 42), "EUR:4.98", 2, 42),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-99c1", "https://exchange.com/", ("check_bank_transfer-99c1", exchange_url,
"EUR:0.98", 2, 42), "EUR:0.98", 2, 42),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-99c2", "https://exchange.com/", ("check_bank_transfer-99c2", exchange_url,
"EUR:0.98", 2, 42), "EUR:0.98", 2, 42),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-99c", "https://exchange.com/", ("check_bank_transfer-99c", exchange_url,
"EUR:0.08", 2, 43), "EUR:0.08", 2, 43),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-aai-1", "https://exchange.com/", ("check_bank_transfer-aai-1", exchange_url,
"EUR:5.01", 42, 2), "EUR:5.01", 42, 2),
/** /**
@ -415,7 +415,7 @@ run (void *cls,
* command with debit account == 424. * command with debit account == 424.
*/ */
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-aai-2", "https://exchange.com/", ("check_bank_transfer-aai-2", exchange_url,
"EUR:5.01", 42, 2), "EUR:5.01", 42, 2),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
@ -486,7 +486,7 @@ run (void *cls,
*/ */
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-pre-refund", "https://exchange.com/", ("check_bank_transfer-pre-refund", exchange_url,
"EUR:5.01", 42, 2), "EUR:5.01", 42, 2),
TALER_TESTING_cmd_check_bank_empty TALER_TESTING_cmd_check_bank_empty
@ -520,7 +520,7 @@ run (void *cls,
* Check that deposit did run. * Check that deposit did run.
*/ */
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-pre-refund", "https://exchange.com/", ("check_bank_transfer-pre-refund", exchange_url,
"EUR:4.97", 2, 42), "EUR:4.97", 2, 42),
/** /**
@ -549,7 +549,7 @@ run (void *cls,
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-aai-3b", "https://exchange.com/", ("check_bank_transfer-aai-3b", exchange_url,
"EUR:5.01", 42, 2), "EUR:5.01", 42, 2),
@ -706,13 +706,13 @@ run (void *cls,
/* check that we are empty before the rejection test */ /* check that we are empty before the rejection test */
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-pr1", "https://exchange.com/", ("check_bank_transfer-pr1", exchange_url,
"EUR:5.01", 42, 2), "EUR:5.01", 42, 2),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-pr2", "https://exchange.com/", ("check_bank_transfer-pr2", exchange_url,
"EUR:2.02", 42, 2), "EUR:2.02", 42, 2),
TALER_TESTING_cmd_check_bank_transfer TALER_TESTING_cmd_check_bank_transfer
("check_bank_transfer-pr3", "https://exchange.com/", ("check_bank_transfer-pr3", exchange_url,
"EUR:1.01", 42, 2), "EUR:1.01", 42, 2),
TALER_TESTING_cmd_check_bank_empty ("check-empty-again"), TALER_TESTING_cmd_check_bank_empty ("check-empty-again"),
@ -759,7 +759,8 @@ main (int argc,
/* @helpers. Run keyup, create tables, ... Note: it /* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see * fetches the port number from config in order to see
* if it's available. */ * if it's available. */
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE)) switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
&exchange_url))
{ {
case GNUNET_SYSERR: case GNUNET_SYSERR:
GNUNET_break (0); GNUNET_break (0);

View File

@ -73,11 +73,15 @@ TALER_TESTING_cleanup_files (const char *config_name)
* launch the exchange process itself. * launch the exchange process itself.
* *
* @param config_filename configuration file to use * @param config_filename configuration file to use
* @param base_url[out] will be set to the exchange base url,
* if the config has any; otherwise it will be set to
* NULL.
* @return #GNUNET_OK on success, #GNUNET_NO if test should be * @return #GNUNET_OK on success, #GNUNET_NO if test should be
* skipped, #GNUNET_SYSERR on test failure * skipped, #GNUNET_SYSERR on test failure
*/ */
int int
TALER_TESTING_prepare_exchange (const char *config_filename) TALER_TESTING_prepare_exchange (const char *config_filename,
char **base_url)
{ {
struct GNUNET_OS_Process *proc; struct GNUNET_OS_Process *proc;
enum GNUNET_OS_ProcessStatusType type; enum GNUNET_OS_ProcessStatusType type;
@ -110,6 +114,18 @@ TALER_TESTING_prepare_exchange (const char *config_filename)
(cfg, config_filename)) (cfg, config_filename))
return GNUNET_SYSERR; return GNUNET_SYSERR;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"exchange",
"BASE_URL",
base_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
"exchange",
"BASE_URL");
*base_url = NULL;
}
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"paths", "paths",

View File

@ -99,11 +99,15 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
* launch the exchange process itself. * launch the exchange process itself.
* *
* @param config_filename configuration file to use * @param config_filename configuration file to use
* @param base_url[out] will be set to the exchange base url,
* if the config has any; otherwise it will be set to
* NULL.
* @return #GNUNET_OK on success, #GNUNET_NO if test should be * @return #GNUNET_OK on success, #GNUNET_NO if test should be
* skipped, #GNUNET_SYSERR on test failure * skipped, #GNUNET_SYSERR on test failure
*/ */
int int
TALER_TESTING_prepare_exchange (const char *config_filename); TALER_TESTING_prepare_exchange (const char *config_filename,
char **base_url);
/** /**