summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-06-18 14:25:09 +0200
committerChristian Grothoff <christian@grothoff.org>2015-06-18 14:25:09 +0200
commit5e87b47c487ccf29ac907d922bef39bc74867af7 (patch)
tree2b2b5e9a2aeb69e7f8d6154d7400fe481f375932 /src
parent3a4429aa008fdab3b5787cd5e406bfd1c556c8e0 (diff)
downloadexchange-5e87b47c487ccf29ac907d922bef39bc74867af7.tar.gz
exchange-5e87b47c487ccf29ac907d922bef39bc74867af7.tar.bz2
exchange-5e87b47c487ccf29ac907d922bef39bc74867af7.zip
add test mode option to mint
Diffstat (limited to 'src')
-rw-r--r--src/mint-lib/test-mint-home/master.priv1
-rw-r--r--src/mint-lib/test_mint_api.c11
-rw-r--r--src/mint/taler-mint-httpd.c26
-rw-r--r--src/mint/taler-mint-httpd.h5
-rw-r--r--src/mint/taler-mint-httpd_db.c12
5 files changed, 49 insertions, 6 deletions
diff --git a/src/mint-lib/test-mint-home/master.priv b/src/mint-lib/test-mint-home/master.priv
new file mode 100644
index 00000000..39492693
--- /dev/null
+++ b/src/mint-lib/test-mint-home/master.priv
@@ -0,0 +1 @@
+p^-33XX!\0qmU_ \ No newline at end of file
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c
index f80b3206..7252337f 100644
--- a/src/mint-lib/test_mint_api.c
+++ b/src/mint-lib/test_mint_api.c
@@ -204,11 +204,22 @@ int
main (int argc,
char * const *argv)
{
+ struct GNUNET_OS_Process *proc;
struct GNUNET_OS_Process *mintd;
GNUNET_log_setup ("test-mint-api",
"WARNING",
NULL);
+ proc = GNUNET_OS_start_process (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-mint-keyup",
+ "taler-mint-keyup",
+ "-d", "test-mint-home",
+ "-m", "test-mint-home/master.priv",
+ NULL);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_destroy (proc);
mintd = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
diff --git a/src/mint/taler-mint-httpd.c b/src/mint/taler-mint-httpd.c
index 0d221444..d74ecf02 100644
--- a/src/mint/taler-mint-httpd.c
+++ b/src/mint/taler-mint-httpd.c
@@ -69,6 +69,11 @@ char *TMH_expected_wire_format;
struct TALER_MINTDB_Plugin *TMH_plugin;
/**
+ * Are we running in test mode?
+ */
+int TMH_test_mode;
+
+/**
* The HTTP Daemon.
*/
static struct MHD_Daemon *mydaemon;
@@ -368,6 +373,17 @@ mint_serve_process_config (const char *mint_directory)
"Failed to initialize DB subsystem\n");
return GNUNET_SYSERR;
}
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "mint",
+ "TESTRUN"))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Running in TEST mode! Database contents will not persist!\n");
+ TMH_test_mode = GNUNET_YES;
+ TMH_plugin->create_tables (TMH_plugin->cls,
+ GNUNET_YES);
+ }
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
@@ -452,6 +468,16 @@ main (int argc, char *const *argv)
ret = TMH_KS_loop ();
MHD_stop_daemon (mydaemon);
+ if (GNUNET_YES == TMH_test_mode)
+ {
+ struct TALER_MINTDB_Session *session;
+
+ session = TMH_plugin->get_session (TMH_plugin->cls,
+ GNUNET_YES);
+ TMH_plugin->drop_temporary (TMH_plugin->cls,
+ session);
+ }
+
TALER_MINTDB_plugin_unload (TMH_plugin);
return (GNUNET_OK == ret) ? 0 : 1;
}
diff --git a/src/mint/taler-mint-httpd.h b/src/mint/taler-mint-httpd.h
index c674a9da..a54e5aa2 100644
--- a/src/mint/taler-mint-httpd.h
+++ b/src/mint/taler-mint-httpd.h
@@ -38,6 +38,11 @@ extern char *TMH_mint_currency_string;
extern struct GNUNET_CONFIGURATION_Handle *cfg;
/**
+ * Are we running in test mode?
+ */
+extern int TMH_test_mode;
+
+/**
* Main directory with mint data.
*/
extern char *TMH_mint_directory;
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c
index 8a46a183..c51f5820 100644
--- a/src/mint/taler-mint-httpd_db.c
+++ b/src/mint/taler-mint-httpd_db.c
@@ -107,7 +107,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
int ret;
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
- GNUNET_NO)))
+ TMH_test_mode)))
{
GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection);
@@ -222,7 +222,7 @@ TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
int res;
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
- GNUNET_NO)))
+ TMH_test_mode)))
{
GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection);
@@ -288,7 +288,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
&h_blind);
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
- GNUNET_NO)))
+ TMH_test_mode)))
{
GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection);
@@ -615,7 +615,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
if (NULL ==
(session = TMH_plugin->get_session (TMH_plugin->cls,
- GNUNET_NO)))
+ TMH_test_mode)))
{
GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection);
@@ -1071,7 +1071,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
unsigned int off;
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
- GNUNET_NO)))
+ TMH_test_mode)))
{
GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection);
@@ -1335,7 +1335,7 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
unsigned int i;
if (NULL == (ctx.session = TMH_plugin->get_session (TMH_plugin->cls,
- GNUNET_NO)))
+ TMH_test_mode)))
{
GNUNET_break (0);
return TMH_RESPONSE_reply_internal_db_error (connection);