make fakebank_url more robust
This commit is contained in:
parent
652bb0f9c4
commit
de092c2c2b
@ -30,16 +30,17 @@
|
|||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration file we use. One (big) configuration is used
|
||||||
|
* for the various components for this test.
|
||||||
|
*/
|
||||||
|
#define CONFIG_FILE "test_exchange_api.conf"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the configuration file is set to include wire format 'test'?
|
* URL of the fakebank. Obtained from CONFIG_FILE's "exchange-wire-test:BANK_URI" option.
|
||||||
*/
|
*/
|
||||||
#define WIRE_TEST 1
|
static char *fakebank_url;
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the configuration file is set to include wire format 'sepa'?
|
|
||||||
*/
|
|
||||||
#define WIRE_SEPA 1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account number of the exchange at the bank.
|
* Account number of the exchange at the bank.
|
||||||
@ -52,41 +53,37 @@
|
|||||||
#define USER_ACCOUNT_NO 42
|
#define USER_ACCOUNT_NO 42
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* User name. Never checked by fakebank.
|
||||||
*/
|
*/
|
||||||
#define USER_LOGIN_NAME "user42"
|
#define USER_LOGIN_NAME "user42"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* User password. Never checked by fakebank.
|
||||||
*/
|
*/
|
||||||
#define USER_LOGIN_PASS "pass42"
|
#define USER_LOGIN_PASS "pass42"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Execute the taler-exchange-wirewatch command with
|
||||||
|
* our configuration file.
|
||||||
*
|
*
|
||||||
*/
|
* @param label label to use for the command.
|
||||||
#define FAKEBANK_URL "http://localhost:8082/"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define CONFIG_FILE "test_exchange_api.conf"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define CMD_EXEC_WIREWATCH(label) \
|
#define CMD_EXEC_WIREWATCH(label) \
|
||||||
TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE)
|
TALER_TESTING_cmd_exec_wirewatch (label, CONFIG_FILE)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Run wire transfer of funds from some user's account to the
|
||||||
|
* exchange.
|
||||||
*
|
*
|
||||||
|
* @param label label to use for the command.
|
||||||
|
* @param amount amount to transfer, i.e. "EUR:1"
|
||||||
*/
|
*/
|
||||||
#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)
|
USER_LOGIN_NAME, USER_LOGIN_PASS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main function that will tell the interpreter what commands to run.
|
* Main function that will tell the interpreter what commands to run.
|
||||||
*
|
*
|
||||||
@ -105,7 +102,7 @@ run (void *cls,
|
|||||||
|
|
||||||
TALER_TESTING_run_with_fakebank (is,
|
TALER_TESTING_run_with_fakebank (is,
|
||||||
commands,
|
commands,
|
||||||
FAKEBANK_URL);
|
fakebank_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,8 +116,7 @@ main (int argc,
|
|||||||
GNUNET_log_setup ("test-exchange-api-new",
|
GNUNET_log_setup ("test-exchange-api-new",
|
||||||
"INFO",
|
"INFO",
|
||||||
NULL);
|
NULL);
|
||||||
if (GNUNET_OK !=
|
if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank (CONFIG_FILE)))
|
||||||
TALER_TESTING_url_port_free (FAKEBANK_URL))
|
|
||||||
return 77;
|
return 77;
|
||||||
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
TALER_TESTING_cleanup_files (CONFIG_FILE);
|
||||||
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE))
|
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE))
|
||||||
|
@ -95,6 +95,7 @@ TALER_TESTING_prepare_exchange (const char *config_filename)
|
|||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"exchange",
|
"exchange",
|
||||||
"PORT");
|
"PORT");
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
GNUNET_CONFIGURATION_destroy (cfg);
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
@ -324,4 +325,46 @@ TALER_TESTING_url_port_free (const char *url)
|
|||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare launching a fakebank. Check that the configuration
|
||||||
|
* file has the right option, and that the port is avaiable.
|
||||||
|
* If everything is OK, return the configured URL of the fakebank.
|
||||||
|
*
|
||||||
|
* @param config_filename configuration file to use
|
||||||
|
* @return NULL on error, fakebank URL otherwise
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_TESTING_prepare_fakebank (const char *config_filename)
|
||||||
|
{
|
||||||
|
struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||||
|
char *fakebank_url;
|
||||||
|
|
||||||
|
cfg = GNUNET_CONFIGURATION_create ();
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_CONFIGURATION_load (cfg,
|
||||||
|
config_filename))
|
||||||
|
return NULL;
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
|
"exchange-wire-test",
|
||||||
|
"BANK_URI",
|
||||||
|
&fakebank_url))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
"exchange-wire-test",
|
||||||
|
"BANK_URI");
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg);
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_TESTING_url_port_free (fakebank_url))
|
||||||
|
{
|
||||||
|
GNUNET_free (fakebank_url);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return fakebank_url;
|
||||||
|
}
|
||||||
|
|
||||||
/* end of testing_api_helpers.c */
|
/* end of testing_api_helpers.c */
|
||||||
|
@ -71,6 +71,17 @@ int
|
|||||||
TALER_TESTING_url_port_free (const char *url);
|
TALER_TESTING_url_port_free (const char *url);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare launching a fakebank. Check that the configuration
|
||||||
|
* file has the right option, and that the port is avaiable.
|
||||||
|
* If everything is OK, return the configured URL of the fakebank.
|
||||||
|
*
|
||||||
|
* @param config_filename configuration file to use
|
||||||
|
* @return NULL on error, fakebank URL otherwise
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_TESTING_prepare_fakebank (const char *config_filename);
|
||||||
|
|
||||||
|
|
||||||
/* ******************* Generic interpreter logic ****************** */
|
/* ******************* Generic interpreter logic ****************** */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user