aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/Makefile.am14
-rw-r--r--src/exchangedb/perf_taler_exchangedb_init.c2
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.c24
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.h20
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c97
-rw-r--r--src/exchangedb/test_exchangedb.c35
-rw-r--r--src/exchangedb/test_exchangedb_deposits.c152
-rw-r--r--src/exchangedb/test_perf_taler_exchangedb.c15
8 files changed, 97 insertions, 262 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 83be82a23..fc87feea1 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -56,7 +56,6 @@ libtalerexchangedb_la_LDFLAGS = \
check_PROGRAMS = \
- test-exchangedb-deposits \
test-exchangedb-keyio \
test-exchangedb-postgres \
test-perf-taler-exchangedb \
@@ -65,17 +64,8 @@ check_PROGRAMS = \
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
test-exchangedb-postgres \
- test-perf-taler-exchangedb
-
-test_exchangedb_deposits_SOURCES = \
- test_exchangedb_deposits.c
-test_exchangedb_deposits_LDADD = \
- libtalerexchangedb.la \
- $(top_srcdir)/src/util/libtalerutil.la \
- $(top_srcdir)/src/pq/libtalerpq.la \
- -lgnunetutil \
- -ljansson \
- -lpq
+ test-perf-taler-exchangedb \
+ test-exchangedb-keyio
test_exchangedb_keyio_SOURCES = \
test_exchangedb_keyio.c
diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c
index 67ac56c77..2d018bdf0 100644
--- a/src/exchangedb/perf_taler_exchangedb_init.c
+++ b/src/exchangedb/perf_taler_exchangedb_init.c
@@ -66,7 +66,7 @@ PERF_TALER_EXCHANGEDB_denomination_init ()
&properties.master.eddsa_pub);
properties.start = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get());
properties.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever_());
- properties.expire_spend = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever_());
+ properties.expire_deposit = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever_());
properties.expire_legal = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_forever_());
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.1", &amount));
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c
index 78b58a5ae..cb805a0b3 100644
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.c
+++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c
@@ -1369,7 +1369,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
break;
case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION:
- state->session = state->plugin->get_session (state->plugin->cls, GNUNET_YES);
+ state->session = state->plugin->get_session (state->plugin->cls);
break;
case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION:
@@ -1816,8 +1816,7 @@ PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin,
ret = cmd_init (cmd);
if (GNUNET_SYSERR == ret)
return ret;
- state.session = db_plugin->get_session (db_plugin->cls,
- GNUNET_YES);
+ state.session = db_plugin->get_session (db_plugin->cls);
GNUNET_assert (NULL != state.session);
ret = interpret (&state);
cmd_clean (cmd);
@@ -1833,7 +1832,8 @@ PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin,
* @param init the commands to use for the database initialisation,
* if #NULL the standard initialization is used
* @param benchmark the commands for the benchmark
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure, #GNUNET_NO
+ * if we failed to init the database
*/
int
PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
@@ -1940,15 +1940,14 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error connectiong to the database\n");
- return ret;
+ return GNUNET_NO;
}
- ret = plugin->create_tables (plugin->cls,
- GNUNET_YES);
+ ret = plugin->create_tables (plugin->cls);
if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error while creating the database architecture\n");
- return ret;
+ return GNUNET_NO;
}
/*
* Running the initialization
@@ -1958,7 +1957,7 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
init = init_def;
}
ret = PERF_TALER_EXCHANGEDB_interpret (plugin,
- init);
+ init);
if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1980,10 +1979,9 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
{
struct TALER_EXCHANGEDB_Session *session;
- session = plugin->get_session (plugin->cls,
- GNUNET_YES);
- ret = plugin->drop_temporary (plugin->cls,
- session);
+ session = plugin->get_session (plugin->cls);
+ ret = plugin->drop_tables (plugin->cls,
+ session);
if (GNUNET_OK != ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.h b/src/exchangedb/perf_taler_exchangedb_interpreter.h
index a83251c60..1c2659dd1 100644
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.h
+++ b/src/exchangedb/perf_taler_exchangedb_interpreter.h
@@ -467,7 +467,7 @@
/**
* Get informations about a refresh session
- *
+ *
* @param _label the label of the command
* @param _label_hash the label of the hash to search
*/
@@ -933,8 +933,8 @@ union PERF_TALER_EXCHANGEDB_CMD_Details
*/
const char *label_denom;
unsigned int index_denom;
- } insert_denomination;
-
+ } insert_denomination;
+
/**
* Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION command
*/
@@ -1283,13 +1283,14 @@ struct PERF_TALER_EXCHANGEDB_Cmd
* @param init the commands to use for the database initialisation,
* if #NULL the standard initialization is used
* @param benchmark the commands for the benchmark
- * @return GNUNET_OK upon success; GNUNET_SYSERR upon failure
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure,
+ * #GNUNET_NO if we failed to init the database
*/
int
PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
- const char *configuration_file,
- struct PERF_TALER_EXCHANGEDB_Cmd *init,
- struct PERF_TALER_EXCHANGEDB_Cmd *benchmark);
+ const char *configuration_file,
+ struct PERF_TALER_EXCHANGEDB_Cmd *init,
+ struct PERF_TALER_EXCHANGEDB_Cmd *benchmark);
/**
@@ -1300,9 +1301,8 @@ PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
* @param cmd the commands to run
*/
int
-PERF_TALER_EXCHANGEDB_interpret(
- struct TALER_EXCHANGEDB_Plugin *db_plugin,
- struct PERF_TALER_EXCHANGEDB_Cmd cmd[]);
+PERF_TALER_EXCHANGEDB_interpret(struct TALER_EXCHANGEDB_Plugin *db_plugin,
+ struct PERF_TALER_EXCHANGEDB_Cmd cmd[]);
/**
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index d69fa7d61..1cc64ce4d 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -30,15 +30,6 @@
#include "plugin_exchangedb_common.c"
/**
- * For testing / experiments, we set the Postgres schema to
- * #TALER_TEMP_SCHEMA_NAME so we can easily purge everything
- * associated with a test. We *also* should use the database
- * "talercheck" instead of "taler" for testing, but we're doing
- * both: better safe than sorry.
- */
-#define TALER_TEMP_SCHEMA_NAME "taler_temporary"
-
-/**
* Log a query error.
*
* @param result PQ result object of the query that failed
@@ -138,39 +129,48 @@ struct PostgresClosure
-/**
- * Set the given connection to use a temporary schema
- *
- * @param db the database connection
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon error
- */
-static int
-set_temporary_schema (PGconn *db)
-{
- SQLEXEC_(db,
- "CREATE SCHEMA IF NOT EXISTS " TALER_TEMP_SCHEMA_NAME ";"
- "SET search_path to " TALER_TEMP_SCHEMA_NAME ";");
- return GNUNET_OK;
- SQLEXEC_fail:
- return GNUNET_SYSERR;
-}
-
/**
- * Drop the temporary taler schema. This is only useful for testcases
+ * Drop all Taler tables. This should only be used by testcases.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param session database session to use
* @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
*/
static int
-postgres_drop_temporary (void *cls,
- struct TALER_EXCHANGEDB_Session *session)
+postgres_drop_tables (void *cls,
+ struct TALER_EXCHANGEDB_Session *session)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Dropping temporary tables\n");
+ "Dropping ALL tables\n");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS prewire;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS aggregation_tracking;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS deposits;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS refresh_out;");
SQLEXEC_ (session->conn,
- "DROP SCHEMA " TALER_TEMP_SCHEMA_NAME " CASCADE;");
+ "DROP TABLE IF EXISTS refresh_commit_coin;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS refresh_commit_link;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS refresh_order;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS refresh_melts;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS refresh_sessions;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS known_coins;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS reserves_out;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS reserves_in;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS reserves;");
+ SQLEXEC_ (session->conn,
+ "DROP TABLE IF EXISTS denominations;");
return GNUNET_OK;
SQLEXEC_fail:
return GNUNET_SYSERR;
@@ -215,12 +215,10 @@ pq_notice_processor_cb (void *arg,
* Create the necessary tables if they are not present
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
- * @param temporary should we use a temporary schema
* @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
*/
static int
-postgres_create_tables (void *cls,
- int temporary)
+postgres_create_tables (void *cls)
{
struct PostgresClosure *pc = cls;
PGconn *conn;
@@ -239,12 +237,6 @@ postgres_create_tables (void *cls,
PQsetNoticeProcessor (conn,
&pq_notice_processor_cb,
NULL);
- if ( (GNUNET_YES == temporary) &&
- (GNUNET_SYSERR == set_temporary_schema (conn)))
- {
- PQfinish (conn);
- return GNUNET_SYSERR;
- }
#define SQLEXEC(sql) SQLEXEC_(conn, sql);
#define SQLEXEC_INDEX(sql) SQLEXEC_IGNORE_ERROR_(conn, sql);
/* Denomination table for holding the publicly available information of
@@ -258,7 +250,7 @@ postgres_create_tables (void *cls,
",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)"
",valid_from INT8 NOT NULL"
",expire_withdraw INT8 NOT NULL"
- ",expire_spend INT8 NOT NULL"
+ ",expire_deposit INT8 NOT NULL"
",expire_legal INT8 NOT NULL"
",coin_val INT8 NOT NULL" /* value of this denom */
",coin_frac INT4 NOT NULL" /* fractional value of this denom */
@@ -533,7 +525,7 @@ postgres_prepare (PGconn *db_conn)
",master_sig"
",valid_from"
",expire_withdraw"
- ",expire_spend"
+ ",expire_deposit"
",expire_legal"
",coin_val" /* value of this denom */
",coin_frac" /* fractional value of this denom */
@@ -563,7 +555,7 @@ postgres_prepare (PGconn *db_conn)
",master_sig"
",valid_from"
",expire_withdraw"
- ",expire_spend"
+ ",expire_deposit"
",expire_legal"
",coin_val" /* value of this denom */
",coin_frac" /* fractional value of this denom */
@@ -1200,13 +1192,10 @@ db_conn_destroy (void *cls)
* Connect to the db if the connection does not exist yet.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
- * @param temporary #GNUNET_YES to use a temporary schema; #GNUNET_NO to use the
- * database default one
* @return the database connection, or NULL on error
*/
static struct TALER_EXCHANGEDB_Session *
-postgres_get_session (void *cls,
- int temporary)
+postgres_get_session (void *cls)
{
struct PostgresClosure *pc = cls;
PGconn *db_conn;
@@ -1229,12 +1218,6 @@ postgres_get_session (void *cls,
PQsetNoticeProcessor (db_conn,
&pq_notice_processor_cb,
NULL);
- if ( (GNUNET_YES == temporary) &&
- (GNUNET_SYSERR == set_temporary_schema(db_conn)) )
- {
- GNUNET_break (0);
- return NULL;
- }
if (GNUNET_OK !=
postgres_prepare (db_conn))
{
@@ -1382,7 +1365,7 @@ postgres_insert_denomination_info (void *cls,
GNUNET_PQ_query_param_auto_from_type (&issue->signature),
GNUNET_PQ_query_param_absolute_time_nbo (&issue->properties.start),
GNUNET_PQ_query_param_absolute_time_nbo (&issue->properties.expire_withdraw),
- GNUNET_PQ_query_param_absolute_time_nbo (&issue->properties.expire_spend),
+ GNUNET_PQ_query_param_absolute_time_nbo (&issue->properties.expire_deposit),
GNUNET_PQ_query_param_absolute_time_nbo (&issue->properties.expire_legal),
TALER_PQ_query_param_amount_nbo (&issue->properties.value),
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_withdraw),
@@ -1478,8 +1461,8 @@ postgres_get_denomination_info (void *cls,
&issue->properties.start),
GNUNET_PQ_result_spec_absolute_time_nbo ("expire_withdraw",
&issue->properties.expire_withdraw),
- GNUNET_PQ_result_spec_absolute_time_nbo ("expire_spend",
- &issue->properties.expire_spend),
+ GNUNET_PQ_result_spec_absolute_time_nbo ("expire_deposit",
+ &issue->properties.expire_deposit),
GNUNET_PQ_result_spec_absolute_time_nbo ("expire_legal",
&issue->properties.expire_legal),
TALER_PQ_result_spec_amount_nbo ("coin",
@@ -4243,7 +4226,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin);
plugin->cls = pg;
plugin->get_session = &postgres_get_session;
- plugin->drop_temporary = &postgres_drop_temporary;
+ plugin->drop_tables = &postgres_drop_tables;
plugin->create_tables = &postgres_create_tables;
plugin->start = &postgres_start;
plugin->commit = &postgres_commit;
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 3bb9b9f2c..2ef7f5d72 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -137,7 +137,7 @@ create_denom_key_pair (unsigned int size,
dki.issue.properties.expire_withdraw = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
GNUNET_TIME_UNIT_HOURS));
- dki.issue.properties.expire_spend = GNUNET_TIME_absolute_hton
+ dki.issue.properties.expire_deposit = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add
(GNUNET_TIME_absolute_get (),
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 2)));
@@ -172,9 +172,10 @@ static struct TALER_Amount fee_refresh;
static struct TALER_Amount fee_refund;
static struct TALER_Amount amount_with_fee;
+
static void
-free_refresh_commit_coins_array(struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins,
- unsigned int size)
+free_refresh_commit_coins_array (struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins,
+ unsigned int size)
{
unsigned int cnt;
struct TALER_EXCHANGEDB_RefreshCommitCoin *ccoin;
@@ -282,6 +283,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
return ret;
}
+
/**
* Function to test melting of coins as part of a refresh session
*
@@ -658,21 +660,30 @@ run (void *cls)
if (NULL ==
(plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
{
- result = 1;
+ result = 77;
return;
}
+ if (NULL !=
+ (session = plugin->get_session (plugin->cls)))
+ {
+ if (GNUNET_OK !=
+ plugin->drop_tables (plugin->cls,
+ session))
+ {
+ result = 77;
+ goto drop;
+ }
+ }
if (GNUNET_OK !=
- plugin->create_tables (plugin->cls,
- GNUNET_YES))
+ plugin->create_tables (plugin->cls))
{
- result = 2;
+ result = 77;
goto drop;
}
if (NULL ==
- (session = plugin->get_session (plugin->cls,
- GNUNET_YES)))
+ (session = plugin->get_session (plugin->cls)))
{
- result = 3;
+ result = 77;
goto drop;
}
RND_BLK (&reserve_pub);
@@ -932,8 +943,8 @@ run (void *cls)
rh = NULL;
if (NULL != session)
GNUNET_break (GNUNET_OK ==
- plugin->drop_temporary (plugin->cls,
- session));
+ plugin->drop_tables (plugin->cls,
+ session));
if (NULL != dkp)
destroy_denom_key_pair (dkp);
if (NULL != cbc.sig.rsa_signature)
diff --git a/src/exchangedb/test_exchangedb_deposits.c b/src/exchangedb/test_exchangedb_deposits.c
deleted file mode 100644
index 09c65b2b2..000000000
--- a/src/exchangedb/test_exchangedb_deposits.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file exchange/test_exchange_deposits.c
- * @brief testcase for exchange deposits
- * @author Sree Harsha Totakura <sreeharsha@totakura.in>
- */
-#include "platform.h"
-#include <libpq-fe.h>
-#include <gnunet/gnunet_util_lib.h>
-#include "taler_pq_lib.h"
-#include "taler_exchangedb_lib.h"
-#include "taler_exchangedb_plugin.h"
-
-#define EXCHANGE_CURRENCY "EUR"
-
-#define DB_URI "postgres:///taler"
-
-#define break_db_err(result) do { \
- GNUNET_break(0); \
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Database failure: %s\n", PQresultErrorMessage (result)); \
- } while (0)
-
-/**
- * Shorthand for exit jumps.
- */
-#define EXITIF(cond) \
- do { \
- if (cond) { GNUNET_break (0); goto EXITIF_exit; } \
- } while (0)
-
-
-/**
- * Should we not interact with a temporary table?
- */
-static int persistent;
-
-/**
- * Testcase result
- */
-static int result;
-
-/**
- * The plugin.
- */
-static struct TALER_EXCHANGEDB_Plugin *plugin;
-
-/**
- * Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param cfg configuration
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- static const char wire[] = "{"
- "\"type\":\"SEPA\","
- "\"IBAN\":\"DE67830654080004822650\","
- "\"NAME\":\"GNUNET E.V\","
- "\"BIC\":\"GENODEF1SRL\""
- "}";
- struct TALER_EXCHANGEDB_Deposit *deposit;
- uint64_t transaction_id;
- struct TALER_EXCHANGEDB_Session *session;
-
- deposit = NULL;
- EXITIF (NULL == (plugin = TALER_EXCHANGEDB_plugin_load (cfg)));
- EXITIF (GNUNET_OK !=
- plugin->create_tables (plugin->cls,
- ! persistent));
- session = plugin->get_session (plugin->cls,
- ! persistent);
- EXITIF (NULL == session);
- deposit = GNUNET_malloc (sizeof (struct TALER_EXCHANGEDB_Deposit) + sizeof (wire));
- /* Makeup a random coin public key */
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- deposit,
- sizeof (struct TALER_EXCHANGEDB_Deposit));
- /* Makeup a random 64bit transaction ID */
- transaction_id = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX);
- deposit->transaction_id = GNUNET_htonll (transaction_id);
- /* Random amount */
- deposit->amount_with_fee.value =
- htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
- deposit->amount_with_fee.fraction =
- htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
- GNUNET_assert (strlen (EXCHANGE_CURRENCY) < sizeof (deposit->amount_with_fee.currency));
- strcpy (deposit->amount_with_fee.currency, EXCHANGE_CURRENCY);
- /* Copy wireformat */
- deposit->wire = json_loads (wire, 0, NULL);
- EXITIF (GNUNET_OK !=
- plugin->insert_deposit (plugin->cls,
- session,
- deposit));
- EXITIF (GNUNET_OK !=
- plugin->have_deposit (plugin->cls,
- session,
- deposit));
- result = GNUNET_OK;
-
- EXITIF_exit:
- GNUNET_free_non_null (deposit);
- if (NULL != plugin)
- {
- TALER_EXCHANGEDB_plugin_unload (plugin);
- plugin = NULL;
- }
-}
-
-
-int
-main (int argc,
- char *const argv[])
-{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'T', "persist", NULL,
- gettext_noop ("Use a persistent database table instead of a temporary one"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &persistent},
- GNUNET_GETOPT_OPTION_END
- };
-
-
- persistent = GNUNET_NO;
- result = GNUNET_SYSERR;
- if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc, argv,
- "test-exchange-deposits",
- "testcase for exchange deposits",
- options, &run, NULL))
- return 3;
- return (GNUNET_OK == result) ? 0 : 1;
-}
diff --git a/src/exchangedb/test_perf_taler_exchangedb.c b/src/exchangedb/test_perf_taler_exchangedb.c
index a4ec9591d..8f7aa55d5 100644
--- a/src/exchangedb/test_perf_taler_exchangedb.c
+++ b/src/exchangedb/test_perf_taler_exchangedb.c
@@ -35,6 +35,7 @@
#define NB_WITHDRAW_INIT 1
#define NB_WITHDRAW_SAVE 1
+
/**
* Allocate, copies and free all the data used in the interpreter
* Used to check for memory leaks
@@ -42,7 +43,8 @@
static void
test_allocate ()
{
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki, *dki_copy;
+ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
+ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki_copy;
struct PERF_TALER_EXCHANGEDB_Reserve *reserve, *reserve_copy;
struct PERF_TALER_EXCHANGEDB_Coin *coin, *coin_copy;
struct TALER_EXCHANGEDB_Deposit *deposit, *deposit_copy;
@@ -68,6 +70,7 @@ test_allocate ()
PERF_TALER_EXCHANGEDB_deposit_free (deposit_copy);
}
+
/**
* Runs the performances tests for the exchange database
* and logs the results using Gauger
@@ -170,13 +173,15 @@ main (int argc, char ** argv)
// End of deposit initialization
PERF_TALER_EXCHANGEDB_INIT_CMD_END ("end"),
};
-
+
test_allocate ();
ret = PERF_TALER_EXCHANGEDB_run_benchmark ("test-perf-taler-exchangedb",
- "./test-exchange-db-postgres.conf",
- init,
- benchmark);
+ "./test-exchange-db-postgres.conf",
+ init,
+ benchmark);
if (GNUNET_SYSERR == ret)
return 1;
+ if (GNUNET_NO == ret)
+ return 77; /* testcase skipped */
return 0;
}