aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c7
-rw-r--r--src/exchange-lib/test_exchange_api_new.c39
-rw-r--r--src/exchange-lib/testing_api_helpers.c18
-rw-r--r--src/include/taler_testing_lib.h6
4 files changed, 48 insertions, 22 deletions
diff --git a/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c b/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c
index c32d6424f..773fc717d 100644
--- a/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c
+++ b/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c
@@ -47,6 +47,10 @@
#define CONFIG_FILE_EXTENDED \
"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
@@ -107,7 +111,8 @@ main (int argc,
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
- switch (TALER_TESTING_prepare_exchange (CONFIG_FILE))
+ switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
+ &exchange_url))
{
case GNUNET_SYSERR:
GNUNET_break (0);
diff --git a/src/exchange-lib/test_exchange_api_new.c b/src/exchange-lib/test_exchange_api_new.c
index 870f920ec..c3e1ce85e 100644
--- a/src/exchange-lib/test_exchange_api_new.c
+++ b/src/exchange-lib/test_exchange_api_new.c
@@ -49,11 +49,11 @@
static char *fakebank_url;
/**
- * FIXME: what about putting exchange_url also global
- * here? Right now, the exchange port is being "bounced"
- * between functions before exchange_url is constructed
- * and TALER_EXCHANGE_connect() is called with that.
+ * Exchange base URL as it appears in the configuration. Note
+ * that it might differ from the one where the exchange actually
+ * listens from.
*/
+static char *exchange_url;
/**
* Account number of the exchange at the bank.
@@ -103,7 +103,7 @@ static char *fakebank_url;
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_fakebank_transfer (label, amount, \
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
@@ -116,7 +116,7 @@ static char *fakebank_url;
TALER_TESTING_cmd_fakebank_transfer_with_subject \
(label, amount, fakebank_url, USER_ACCOUNT_NO, \
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
@@ -391,23 +391,23 @@ run (void *cls,
* Check all the transfers took place.
*/
TALER_TESTING_cmd_check_bank_transfer
- ("check_bank_transfer-499c", "https://exchange.com/",
+ ("check_bank_transfer-499c", exchange_url,
"EUR:4.98", 2, 42),
TALER_TESTING_cmd_check_bank_transfer
- ("check_bank_transfer-99c1", "https://exchange.com/",
+ ("check_bank_transfer-99c1", exchange_url,
"EUR:0.98", 2, 42),
TALER_TESTING_cmd_check_bank_transfer
- ("check_bank_transfer-99c2", "https://exchange.com/",
+ ("check_bank_transfer-99c2", exchange_url,
"EUR:0.98", 2, 42),
TALER_TESTING_cmd_check_bank_transfer
- ("check_bank_transfer-99c", "https://exchange.com/",
+ ("check_bank_transfer-99c", exchange_url,
"EUR:0.08", 2, 43),
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),
/**
@@ -415,7 +415,7 @@ run (void *cls,
* command with debit account == 424.
*/
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),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
@@ -486,7 +486,7 @@ run (void *cls,
*/
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),
TALER_TESTING_cmd_check_bank_empty
@@ -520,7 +520,7 @@ run (void *cls,
* Check that deposit did run.
*/
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),
/**
@@ -549,7 +549,7 @@ run (void *cls,
MHD_HTTP_OK),
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),
@@ -706,13 +706,13 @@ run (void *cls,
/* check that we are empty before the rejection test */
TALER_TESTING_cmd_check_bank_transfer
- ("check_bank_transfer-pr1", "https://exchange.com/",
+ ("check_bank_transfer-pr1", exchange_url,
"EUR:5.01", 42, 2),
TALER_TESTING_cmd_check_bank_transfer
- ("check_bank_transfer-pr2", "https://exchange.com/",
+ ("check_bank_transfer-pr2", exchange_url,
"EUR:2.02", 42, 2),
TALER_TESTING_cmd_check_bank_transfer
- ("check_bank_transfer-pr3", "https://exchange.com/",
+ ("check_bank_transfer-pr3", exchange_url,
"EUR:1.01", 42, 2),
TALER_TESTING_cmd_check_bank_empty ("check-empty-again"),
@@ -759,7 +759,8 @@ main (int argc,
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
- switch (TALER_TESTING_prepare_exchange (CONFIG_FILE))
+ switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
+ &exchange_url))
{
case GNUNET_SYSERR:
GNUNET_break (0);
diff --git a/src/exchange-lib/testing_api_helpers.c b/src/exchange-lib/testing_api_helpers.c
index 690c222c9..50ee5e2ca 100644
--- a/src/exchange-lib/testing_api_helpers.c
+++ b/src/exchange-lib/testing_api_helpers.c
@@ -73,11 +73,15 @@ TALER_TESTING_cleanup_files (const char *config_name)
* launch the exchange process itself.
*
* @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
* skipped, #GNUNET_SYSERR on test failure
*/
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;
enum GNUNET_OS_ProcessStatusType type;
@@ -110,6 +114,18 @@ TALER_TESTING_prepare_exchange (const char *config_filename)
(cfg, config_filename))
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 !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"paths",
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index d06105dd1..3914208f1 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -99,11 +99,15 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
* launch the exchange process itself.
*
* @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
* skipped, #GNUNET_SYSERR on test failure
*/
int
-TALER_TESTING_prepare_exchange (const char *config_filename);
+TALER_TESTING_prepare_exchange (const char *config_filename,
+ char **base_url);
/**