remove unused, unclean perf logic (we should measure using the logic in the src/benchmark/ directory anyway)

This commit is contained in:
Christian Grothoff 2019-09-15 11:20:27 +02:00
parent 7dca6dacb9
commit 5503c78160
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
8 changed files with 2 additions and 4264 deletions

View File

@ -64,9 +64,7 @@ check_PROGRAMS = \
test-exchangedb-denomkeys \
test-exchangedb-fees \
test-exchangedb-signkeys \
test-exchangedb-postgres \
test-perf-taler-exchangedb \
perf-exchangedb
test-exchangedb-postgres
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
@ -74,8 +72,7 @@ TESTS = \
test-exchangedb-denomkeys \
test-exchangedb-fees \
test-exchangedb-postgres \
test-exchangedb-signkeys \
test-perf-taler-exchangedb
test-exchangedb-signkeys
test_exchangedb_auditors_SOURCES = \
test_exchangedb_auditors.c
@ -115,28 +112,5 @@ test_exchangedb_postgres_LDADD = \
-ljansson \
-lgnunetutil
test_perf_taler_exchangedb_SOURCES = \
test_perf_taler_exchangedb.c \
perf_taler_exchangedb_init.c perf_taler_exchangedb_init.h \
perf_taler_exchangedb_interpreter.c perf_taler_exchangedb_interpreter.h
test_perf_taler_exchangedb_LDADD = \
libtalerexchangedb.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil \
-ljansson
perf_exchangedb_SOURCES = \
perf_taler_exchangedb.c \
perf_taler_exchangedb_init.c perf_taler_exchangedb_init.h \
perf_taler_exchangedb_interpreter.c perf_taler_exchangedb_interpreter.h
perf_exchangedb_LDADD = \
libtalerexchangedb.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
-lgnunetutil \
-ljansson
EXTRA_test_exchangedb_postgres_DEPENDENCIES = \
libtaler_plugin_exchangedb_postgres.la

View File

@ -1,382 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014-2018 Taler Systems SA
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, see <http://www.gnu.org/licenses/>
*/
/**
* @file exchangedb/perf_taler_exchangedb.c
* @brief Exchange database performance analysis
* @author Nicolas Fournier
* @author Christian Grothoff
*/
#include "platform.h"
#include "perf_taler_exchangedb_interpreter.h"
#define NB_DENOMINATION_INIT 15
#define NB_DENOMINATION_SAVE 15
#define SMALL 1000
#define BIG 10000
#define BIGGER 100000
#define NB_RESERVE_INIT BIGGER
#define NB_RESERVE_SAVE BIG
#define NB_DEPOSIT_INIT BIGGER
#define NB_DEPOSIT_SAVE BIG
#define NB_WITHDRAW_INIT BIGGER
#define NB_WITHDRAW_SAVE BIG
#define NB_REFRESH_INIT BIGGER
#define NB_REFRESH_SAVE BIG
#define NB_MELT_INIT BIG
#define NB_MELT_SAVE SMALL
/**
* Runs the performances tests for the exchange database
* and logs the results using Gauger
*/
int
main (int argc, char **argv)
{
int ret;
struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = {
/* Denomination used to create coins */
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Initializing database"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop",
NB_DENOMINATION_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert",
"01 - denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
"01 - denomination loop",
"01 - denomination",
NB_DENOMINATION_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - end",
"01 - denomination loop"),
/* End of initialization */
/* Reserve initialization */
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop",
NB_RESERVE_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert",
"02 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
"02 - init reserve loop",
"02 - reserve",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - end",
"02 - init reserve loop"),
/* End reserve init */
/* Withdrawal initialization */
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop",
NB_WITHDRAW_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
"03 - init withdraw loop",
"01 - save denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
"03 - init withdraw loop",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw",
"03 - denomination load",
"03 - reserve load"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert",
"03 - withdraw"),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin",
"03 - init withdraw loop",
"03 - withdraw",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - end",
"03 - init withdraw loop"),
/*End of withdrawal initialization */
/*Deposit initialization */
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop",
NB_DEPOSIT_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load",
"04 - deposit init loop",
"03 - save coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit",
"04 - coin load"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert",
"04 - deposit"),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
"04 - deposit init loop",
"04 - deposit",
NB_DEPOSIT_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"04 - deposit init loop"),
/* End of deposit initialization */
/* Session initialization */
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("05 - refresh session init loop",
NB_REFRESH_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - denomination load",
"05 - refresh session init loop",
"01 - save denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - reserve load",
"05 - refresh session init loop",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("05 - withdraw",
"05 - denomination load",
"05 - reserve load"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION (
"05 - refresh session",
"05 - withdraw"),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("05 - session array",
"05 - refresh session init loop",
"05 - refresh session",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("05 - end",
"05 - refresh session init loop"),
/* End of refresh session initialization */
/* Refresh melt initialization */
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("06 - refresh melt init loop",
NB_MELT_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
/* TODO: initialize using coins & sessions created localy
* in order to make sure the same coin are not melted twice*/
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - session hash",
"06 - refresh melt init loop",
"05 - session array"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - coin",
"06 - refresh melt init loop",
"03 - save coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("06 - end",
"06 - refresh melt init loop"),
/* End of refresh melt initialization */
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of initialization"),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Start of performances measuring"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("21 - reserve insert measure",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("21 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("21 - insert",
"21 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"21 - reserve insert measure"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("21 - gauger",
"21 - start",
"21 - stop",
"POSTGRES",
"Number of reserve inserted per second",
"item/sec",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve insertion"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("22 - reserve load measure",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("22 - reserve",
"22 - reserve load measure",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE ("22 - get",
"22 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"22 - reserve load measure"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"22 - start",
"22 - stop",
"POSTGRES",
"Number of reserve loaded per second",
"item/sec",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve retreival"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("23 - reserve history measure",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("23 - reserve",
"23 - reserve history measure",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY ("",
"23 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"23 - reserve history measure"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"23 - start",
"23 - stop",
"POSTGRES",
"Number of reserve history loaded per second",
"item/sec",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve history access"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("24 - withdraw insert measure",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - reserve",
"24 - withdraw insert measure",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - denomination",
"24 - withdraw insert measure",
"01 - save denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("24 - withdraw",
"24 - denomination",
"24 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("24 - insert",
"24 - withdraw"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"24 - withdraw insert measure"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"24 - start",
"24 - stop",
"POSTGRES",
"Number of withdraw insert per second",
"item/sec",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw insertion"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("25 - withdraw insert measure",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("25 - coin",
"25 - withdraw insert measure",
"03 - save coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW ("",
"25 - coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"25 - withdraw insert measure"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"25 - start",
"25 - stop",
"POSTGRES",
"Number of withdraw loaded per second",
"item/sec",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw loading"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("26 - get coin transaction",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("26 - coin",
"26 - get coin transaction",
"03 - save coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION ("",
"26 - coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"26 - get coin transaction"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - end"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"26 - start",
"26 - end",
"POSTGRES",
"Number of coin transaction history loaded per second",
"item/sec",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of transaction loading"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("27 - /reserve/withdraw",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - reserve",
"27 - /reserve/withdraw",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - dki",
"27 - /reserve/withdraw",
"01 - save denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN ("",
"27 - dki",
"27 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"27 - /reserve/withdraw"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - end"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"27 - start",
"27 - end",
"POSTGRES",
"Number of /reserve/withdraw per second",
"item/sec",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of /reserve/withdraw"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("28 - /deposit",
NB_DEPOSIT_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("28 - coin",
"28 - /deposit",
"03 - save coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT ("28 - deposit",
"28 - coin"),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"28 - /deposit"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"28 - start",
"28 - stop",
"POSTGRES",
"Number of /deposit per second",
"item/sec",
NB_DEPOSIT_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("29 - insert refresh session",
NB_REFRESH_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("29 - denomination load",
"29 - insert refresh session",
"01 - save denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("29 - reserve load",
"29 - insert refresh session",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("29 - withdraw",
"29 - denomination load",
"29 - reserve load"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION (
"29 - refresh session",
"29 - withdraw"),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("29 - session array",
"29 - insert refresh session",
"29 - refresh session",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
"29 - insert refresh session"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
"29 - start",
"29 - stop",
"POSTGRES",
"Number of refresh session inserted per second",
"item/sec",
NB_REFRESH_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END (""),
};
ret = PERF_TALER_EXCHANGEDB_run_benchmark (
"perf-taler-exchangedb",
"./test-exchange-db-postgres.conf",
(struct PERF_TALER_EXCHANGEDB_Cmd []) {PERF_TALER_EXCHANGEDB_INIT_CMD_END (
"")},
benchmark);
if (GNUNET_SYSERR == ret)
return 1;
return 0;
}

View File

@ -1,527 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015, 2016 Inria & 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, see <http://www.gnu.org/licenses/>
*/
/**
* @file exchangedb/perf_taler_exchangedb_init.c
* @brief Interpreter library for exchange database performance analysis
* @author Nicolas Fournier
* @author Christian Grothoff
*/
#include "platform.h"
#include "perf_taler_exchangedb_init.h"
#include <gnunet/gnunet_signatures.h>
#include "taler_signatures.h"
#include "taler_amount_lib.h"
#define CURRENCY "EUR"
#define PERF_TALER_EXCHANGEDB_RSA_SIZE 512
/**
* Generate a dummy DenominationKeyInformation for testing purposes
* @return a dummy denomination key
*/
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
PERF_TALER_EXCHANGEDB_denomination_init ()
{
struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt;
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
struct TALER_DenominationPrivateKey denom_priv;
struct TALER_DenominationPublicKey denom_pub;
struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
master_prvt = GNUNET_CRYPTO_eddsa_key_create ();
dki = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation);
GNUNET_assert (NULL != dki);
denom_priv.rsa_private_key
= GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_EXCHANGEDB_RSA_SIZE);
GNUNET_assert (NULL != denom_priv.rsa_private_key);
denom_pub.rsa_public_key =
GNUNET_CRYPTO_rsa_private_key_get_public (denom_priv.rsa_private_key);
GNUNET_assert (NULL != denom_pub.rsa_public_key);
{/* issue */
struct TALER_MasterSignatureP signature;
struct TALER_DenominationKeyValidityPS properties;
{/* properties */
struct TALER_Amount amount;
struct GNUNET_TIME_Absolute now;
properties.purpose.purpose = htonl (
TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY);
properties.purpose.size = htonl (sizeof (struct
TALER_DenominationKeyValidityPS));
GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
&properties.master.eddsa_pub);
now = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&now);
properties.start = GNUNET_TIME_absolute_hton (now);
properties.expire_withdraw = GNUNET_TIME_absolute_hton (
GNUNET_TIME_UNIT_FOREVER_ABS);
properties.expire_deposit = GNUNET_TIME_absolute_hton (
GNUNET_TIME_UNIT_FOREVER_ABS);
properties.expire_legal = GNUNET_TIME_absolute_hton (
GNUNET_TIME_UNIT_FOREVER_ABS);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.1", &amount));
TALER_amount_hton (&properties.value, &amount);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.1", &amount));
TALER_amount_hton (&properties.fee_withdraw, &amount);
TALER_amount_hton (&properties.fee_deposit, &amount);
TALER_amount_hton (&properties.fee_refresh, &amount);
TALER_amount_hton (&properties.fee_refund, &amount);
GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key,
&properties.denom_hash);
issue.properties = properties;
}
{/* signature */
GNUNET_CRYPTO_eddsa_sign (master_prvt,
&properties.purpose,
&signature.eddsa_signature);
issue.signature = signature;
}
}
dki->denom_priv = denom_priv;
dki->denom_pub = denom_pub;
dki->issue = issue;
GNUNET_free (master_prvt);
return dki;
}
/**
* Copies the given denomination
* @param reserve the deposit copy
* @return a copy of @a deposit; NULL if error
*/
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
PERF_TALER_EXCHANGEDB_denomination_copy (const struct
TALER_EXCHANGEDB_DenominationKeyIssueInformation
*dki)
{
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *copy;
GNUNET_assert (NULL !=
(copy = GNUNET_new (struct
TALER_EXCHANGEDB_DenominationKeyIssueInformation)));
{/* denom_priv */
copy->denom_priv.rsa_private_key =
GNUNET_CRYPTO_rsa_private_key_dup (dki->denom_priv.rsa_private_key);
}
{/* denom_pub */
copy->denom_pub.rsa_public_key =
GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key);
}
{/* issue */
copy->issue.properties = dki->issue.properties;
copy->issue.signature = dki->issue.signature;
}
return copy;
}
/**
* Free memory of a DenominationKeyIssueInformation
* @param dki pointer to the struct to free
*/
int
PERF_TALER_EXCHANGEDB_denomination_free (struct
TALER_EXCHANGEDB_DenominationKeyIssueInformation
*dki)
{
if (NULL == dki)
return GNUNET_OK;
GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key);
GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key);
GNUNET_free (dki);
return GNUNET_OK;
}
/**
* Generate a dummy reserve for testing
* @return a reserve with 1000 EUR in it
*/
struct PERF_TALER_EXCHANGEDB_Reserve *
PERF_TALER_EXCHANGEDB_reserve_init ()
{
struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
GNUNET_assert (NULL !=
(reserve = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve)));
{/* private */
struct GNUNET_CRYPTO_EddsaPrivateKey *private;
private = GNUNET_CRYPTO_eddsa_key_create ();
GNUNET_assert (NULL != private);
reserve->private = *private;
GNUNET_free (private);
}
GNUNET_CRYPTO_eddsa_key_get_public (&reserve->private,
&reserve->reserve.pub.eddsa_pub);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1000",
&reserve->reserve.balance));
reserve->reserve.expiry = GNUNET_TIME_UNIT_FOREVER_ABS;
return reserve;
}
/**
* Copies the given reserve
* @param reserve the reserve to copy
* @return a copy of @a reserve; NULL if error
*/
struct PERF_TALER_EXCHANGEDB_Reserve *
PERF_TALER_EXCHANGEDB_reserve_copy (const struct
PERF_TALER_EXCHANGEDB_Reserve *reserve)
{
struct PERF_TALER_EXCHANGEDB_Reserve *copy;
GNUNET_assert (NULL !=
(copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve)));
*copy = *reserve;
return copy;
}
/**
* Free memory of a reserve
* @param reserve pointer to the structure to be freed
*/
int
PERF_TALER_EXCHANGEDB_reserve_free (struct
PERF_TALER_EXCHANGEDB_Reserve *reserve)
{
if (NULL == reserve)
return GNUNET_OK;
GNUNET_free (reserve);
return GNUNET_OK;
}
/**
* Generate a dummy deposit for testing purposes
*
* @param dki the denomination key used to sign the key
*/
struct TALER_EXCHANGEDB_Deposit *
PERF_TALER_EXCHANGEDB_deposit_init (const struct
PERF_TALER_EXCHANGEDB_Coin *coin)
{
struct TALER_EXCHANGEDB_Deposit *deposit;
struct TALER_CoinSpendSignatureP csig;
struct TALER_MerchantPublicKeyP merchant_pub;
struct GNUNET_HashCode h_contract_terms;
struct GNUNET_HashCode h_wire;
struct GNUNET_TIME_Absolute timestamp;
struct GNUNET_TIME_Absolute refund_deadline;
struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee;
deposit = GNUNET_new (struct TALER_EXCHANGEDB_Deposit);
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
&h_contract_terms);
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
&h_wire);
{ // csig
struct u32_presign
{
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
struct GNUNET_HashCode h_wire;
struct GNUNET_HashCode h_contract_terms;
} unsigned_data;
unsigned_data.h_contract_terms = h_contract_terms;
unsigned_data.h_wire = h_wire;
unsigned_data.purpose.size = htonl (sizeof (struct u32_presign));
unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_eddsa_sign (&coin->priv,
&unsigned_data.purpose,
&csig.eddsa_signature));
}
{ // merchant_pub
struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv;
eddsa_prv = GNUNET_CRYPTO_eddsa_key_create ();
GNUNET_assert (NULL != eddsa_prv);
GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prv,
&merchant_pub.eddsa_pub);
GNUNET_free (eddsa_prv);
}
timestamp = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&timestamp);
refund_deadline = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&refund_deadline);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.1",
&amount_with_fee));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.1",
&deposit_fee));
{
deposit->coin.coin_pub = coin->public_info.coin_pub;
deposit->coin.denom_pub_hash = coin->public_info.denom_pub_hash;
deposit->coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup (
coin->public_info.denom_sig.rsa_signature);
GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature);
}
deposit->csig = csig;
deposit->h_contract_terms = h_contract_terms;
deposit->h_wire = h_wire;
deposit->receiver_wire_account
= json_pack ("{s:s, s:s}",
"url", "payto://iban/DE67830654080004822650",
"salt", "this-is-a-salt-value");
deposit->timestamp = timestamp;
deposit->refund_deadline = refund_deadline;
deposit->amount_with_fee = amount_with_fee;
deposit->deposit_fee = deposit_fee;
return deposit;
}
/**
* Copies the given deposit
* @param reserve the deposit copy
* @return a copy of @a deposit; NULL if error
*/
struct TALER_EXCHANGEDB_Deposit *
PERF_TALER_EXCHANGEDB_deposit_copy (const struct
TALER_EXCHANGEDB_Deposit *deposit)
{
struct TALER_EXCHANGEDB_Deposit *copy;
copy = GNUNET_new (struct TALER_EXCHANGEDB_Deposit);
*copy = *deposit;
copy->receiver_wire_account = json_incref (deposit->receiver_wire_account);
copy->coin.denom_sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (deposit->coin.denom_sig.rsa_signature);
return copy;
}
/**
* Free memory of a deposit
* @param deposit pointer to the structure to free
*/
int
PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit)
{
if (NULL == deposit)
return GNUNET_OK;
GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature);
json_decref (deposit->receiver_wire_account);
GNUNET_free (deposit);
return GNUNET_OK;
}
/**
* Generate a CollectableBlindcoin for testing purpuses
* @param dki denomination key used to sign the coin
* @param reserve reserve providing the money for the coin
* @return a randomly generated CollectableBlindcoin
*/
struct PERF_TALER_EXCHANGEDB_Coin *
PERF_TALER_EXCHANGEDB_coin_init (
const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki,
const struct PERF_TALER_EXCHANGEDB_Reserve *reserve)
{
struct PERF_TALER_EXCHANGEDB_Coin *coin;
struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
struct GNUNET_HashCode hc;
coin = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin);
GNUNET_assert (NULL != coin);
/* priv */
priv = GNUNET_CRYPTO_eddsa_key_create ();
GNUNET_assert (NULL != priv);
coin->priv = *priv;
GNUNET_free (priv);
/* public_info */
GNUNET_CRYPTO_eddsa_key_get_public (&coin->priv,
&coin->public_info.coin_pub.eddsa_pub);
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
&coin->public_info.denom_pub_hash);
GNUNET_CRYPTO_hash (&coin->public_info.coin_pub,
sizeof (struct TALER_CoinSpendPublicKeyP),
&hc);
coin->public_info.denom_sig.rsa_signature =
GNUNET_CRYPTO_rsa_sign_fdh (dki->denom_priv.rsa_private_key,
&hc);
GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature);
/* blind */
coin->blind.sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature);
coin->blind.denom_pub_hash = coin->public_info.denom_pub_hash;
GNUNET_assert (NULL != coin->blind.sig.rsa_signature);
TALER_amount_ntoh (&coin->blind.amount_with_fee,
&dki->issue.properties.value);
TALER_amount_ntoh (&coin->blind.withdraw_fee,
&dki->issue.properties.fee_withdraw);
coin->blind.reserve_pub = reserve->reserve.pub;
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
&coin->blind.h_coin_envelope);
return coin;
}
/**
* Copies the given coin
*
* @param coin the coin to copy
* @return a copy of coin; NULL if error
*/
struct PERF_TALER_EXCHANGEDB_Coin *
PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin)
{
struct PERF_TALER_EXCHANGEDB_Coin *copy;
copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin);
/* priv */
copy->priv = coin->priv;
/* public_info */
copy->public_info.coin_pub = coin->public_info.coin_pub;
copy->public_info.denom_pub_hash = coin->public_info.denom_pub_hash;
copy->public_info.denom_sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature);
/* blind */
copy->blind.sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (coin->blind.sig.rsa_signature);
copy->blind.denom_pub_hash = coin->blind.denom_pub_hash;
copy->blind.amount_with_fee = coin->blind.amount_with_fee;
copy->blind.withdraw_fee = coin->blind.withdraw_fee;
copy->blind.reserve_pub = coin->blind.reserve_pub;
copy->blind.h_coin_envelope = coin->blind.h_coin_envelope;
copy->blind.reserve_sig = coin->blind.reserve_sig;
return copy;
}
/**
* Free memory of @a coin
*
* @param coin pointer to the structure to free
*/
int
PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin)
{
if (NULL == coin)
return GNUNET_OK;
GNUNET_CRYPTO_rsa_signature_free (coin->public_info.denom_sig.rsa_signature);
GNUNET_CRYPTO_rsa_signature_free (coin->blind.sig.rsa_signature);
GNUNET_free (coin);
return GNUNET_OK;
}
/**
* Create a melt operation
*
* @param rc the commitment of the refresh session
* @param dki the denomination the melted coin uses
* @return a pointer to a #TALER_EXCHANGEDB_RefreshMelt
*/
struct TALER_EXCHANGEDB_RefreshMelt *
PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc,
struct PERF_TALER_EXCHANGEDB_Coin *coin)
{
struct TALER_EXCHANGEDB_RefreshMelt *melt;
struct TALER_CoinSpendSignatureP coin_sig;
struct TALER_Amount amount;
struct TALER_Amount amount_with_fee;
{
struct
{
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
struct TALER_RefreshCommitmentP rc;
} to_sign;
to_sign.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST;
to_sign.purpose.size = htonl (sizeof (to_sign));
to_sign.rc = *rc;
GNUNET_CRYPTO_eddsa_sign (&coin->priv,
&to_sign.purpose,
&coin_sig.eddsa_signature);
}
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.1",
&amount));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.1",
&amount_with_fee));
melt = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt);
melt->session.coin.coin_pub = coin->public_info.coin_pub;
melt->session.coin.denom_sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature);
melt->session.coin.denom_pub_hash = coin->public_info.denom_pub_hash;
GNUNET_assert (NULL != melt->session.coin.denom_sig.rsa_signature);
melt->session.coin_sig = coin_sig;
melt->session.rc = *rc;
melt->session.amount_with_fee = amount;
melt->melt_fee = amount_with_fee;
return melt;
}
/**
* Copies the internals of a #TALER_EXCHANGEDB_RefreshMelt
*
* @param melt the refresh melt to copy
* @return an copy of @ melt
*/
struct TALER_EXCHANGEDB_RefreshMelt *
PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct
TALER_EXCHANGEDB_RefreshMelt *melt)
{
struct TALER_EXCHANGEDB_RefreshMelt *copy;
copy = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt);
*copy = *melt;
copy->session.coin.denom_sig.rsa_signature =
GNUNET_CRYPTO_rsa_signature_dup (
melt->session.coin.denom_sig.rsa_signature);
GNUNET_assert (NULL != copy->session.coin.denom_sig.rsa_signature);
return copy;
}
/**
* Free the internal memory of a #TALER_EXCHANGEDB_RefreshMelt
*
* @param melt the #TALER_EXCHANGEDB_RefreshMelt to free
* @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR
*/
int
PERF_TALER_EXCHANGEDB_refresh_melt_free (struct
TALER_EXCHANGEDB_RefreshMelt *melt)
{
GNUNET_CRYPTO_rsa_signature_free (melt->session.coin.denom_sig.rsa_signature);
GNUNET_free (melt);
return GNUNET_OK;
}

View File

@ -1,215 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015 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, see <http://www.gnu.org/licenses/>
*/
/**
* @file exchangedb/perf_taler_exchangedb_init.h
* @brief Heler function for creating dummy inputs for the exchange database
* @author Nicolas Fournier
*/
#ifndef __PERF_TALER_EXCHANGEDB_INIT_H___
#define __PERF_TALER_EXCHANGEDB_INIT_H___
#include "taler_exchangedb_plugin.h"
#define CURRENCY "EUR"
/**
* All information about a reserve
*/
struct PERF_TALER_EXCHANGEDB_Reserve
{
/**
* Information about a rserve available to the Exchange
*/
struct TALER_EXCHANGEDB_Reserve reserve;
/**
* Private key of a reserve
*/
struct GNUNET_CRYPTO_EddsaPrivateKey private;
};
/**
* All informations about a coin
*/
struct PERF_TALER_EXCHANGEDB_Coin
{
/**
* Blinded coin, known by the exchange
*/
struct TALER_EXCHANGEDB_CollectableBlindcoin blind;
/**
* Public key of the coin and othes informations
*/
struct TALER_CoinPublicInfo public_info;
/**
* Private key of the coin
*/
struct GNUNET_CRYPTO_EddsaPrivateKey priv;
};
/**
* Generate a dummy DenominationKeyInformation for testing purposes
* @return a dummy denomination key
*/
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
PERF_TALER_EXCHANGEDB_denomination_init (void);
/**
* Copies the given denomination
* @param reserve the deposit copy
* @return a copy of @a deposit; NULL if error
*/
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
PERF_TALER_EXCHANGEDB_denomination_copy (const struct
TALER_EXCHANGEDB_DenominationKeyIssueInformation
*dki);
/**
* Free memory of a DenominationKeyIssueInformation
* @param dki pointer to the struct to free
*/
int
PERF_TALER_EXCHANGEDB_denomination_free (struct
TALER_EXCHANGEDB_DenominationKeyIssueInformation
*dki);
/**
* Generate a dummy reserve for testing
* @return a reserve with 1000 EUR in it
*/
struct PERF_TALER_EXCHANGEDB_Reserve *
PERF_TALER_EXCHANGEDB_reserve_init (void);
/**
* Copies the given reserve
* @param reserve the reserve to copy
* @return a copy of @a reserve; NULL if error
*/
struct PERF_TALER_EXCHANGEDB_Reserve *
PERF_TALER_EXCHANGEDB_reserve_copy (const struct
PERF_TALER_EXCHANGEDB_Reserve *reserve);
/**
* Free memory of a reserve
* @param reserve pointer to the structure to be freed
*/
int
PERF_TALER_EXCHANGEDB_reserve_free (struct
PERF_TALER_EXCHANGEDB_Reserve *reserve);
/**
* Generate a dummy deposit for testing purposes
* @param dki the denomination key used to sign the key
*/
struct TALER_EXCHANGEDB_Deposit *
PERF_TALER_EXCHANGEDB_deposit_init (const struct
PERF_TALER_EXCHANGEDB_Coin *coin);
/**
* Copies the given deposit
* @param reserve the deposit copy
* @return a copy of @a deposit; NULL if error
*/
struct TALER_EXCHANGEDB_Deposit *
PERF_TALER_EXCHANGEDB_deposit_copy (const struct
TALER_EXCHANGEDB_Deposit *deposit);
/**
* Free memory of a deposit
* @param deposit pointer to the structure to free
*/
int
PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit);
/**
* Generate a coin for testing purpuses
* @param dki denomination key used to sign the coin
* @param reserve reserve providing the money for the coin
* @return a randomly generated CollectableBlindcoin
*/
struct PERF_TALER_EXCHANGEDB_Coin *
PERF_TALER_EXCHANGEDB_coin_init (const struct
TALER_EXCHANGEDB_DenominationKeyIssueInformation
*dki,
const struct
PERF_TALER_EXCHANGEDB_Reserve *reserve);
/**
* Copies the given coin
* @param coin the coin to copy
* @return a copy of coin; NULL if error
*/
struct PERF_TALER_EXCHANGEDB_Coin *
PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin);
/**
* Liberate memory of @a coin
* @param coin pointer to the structure to free
*/
int
PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin);
/**
* Create a melt operation
*
* @param rc the commitment of the refresh session
* @param dki the denomination the melted coin uses
* @return a pointer to a #TALER_EXCHANGEDB_RefreshMelt
*/
struct TALER_EXCHANGEDB_RefreshMelt *
PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc,
struct PERF_TALER_EXCHANGEDB_Coin *coin);
/**
* Copies the internals of a #TALER_EXCHANGEDB_RefreshMelt
*
* @param melt the refresh melt to copy
* @return an copy of @ melt
*/
struct TALER_EXCHANGEDB_RefreshMelt *
PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct
TALER_EXCHANGEDB_RefreshMelt *melt);
/**
* Free the internal memory of a #TALER_EXCHANGEDB_RefreshMelt
*
* @param melt the #TALER_EXCHANGEDB_RefreshMelt to free
* @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR
*/
int
PERF_TALER_EXCHANGEDB_refresh_melt_free (struct
TALER_EXCHANGEDB_RefreshMelt *melt);
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015 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, see <http://www.gnu.org/licenses/>
*/
/**
* @file exchangedb/perf_taler_exchangedb_values.h
* @brief Values for tweaking the performance analysis
* @author Nicolas Fournier
*/
#ifndef __PERF_TALER_EXCHANGEDB__VALUES_H__
#define __PERF_TALER_EXCHANGEDB__VALUES_H__
#endif

View File

@ -1,188 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014, 2015 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, see <http://www.gnu.org/licenses/>
*/
/**
* @file exchangedb/test_perf_taler_exchangedb.c
* @brief Exchange database performance analysis
* @author Nicolas Fournier
*/
#include "platform.h"
#include "perf_taler_exchangedb_interpreter.h"
#include "perf_taler_exchangedb_init.h"
#define NB_DENOMINATION_INIT 2
#define NB_DENOMINATION_SAVE 2
#define NB_RESERVE_INIT 4
#define NB_RESERVE_SAVE 1
#define NB_DEPOSIT_INIT 1
#define NB_DEPOSIT_SAVE 1
#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
*/
static void
test_allocate ()
{
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;
dki = PERF_TALER_EXCHANGEDB_denomination_init ();
reserve = PERF_TALER_EXCHANGEDB_reserve_init ();
coin = PERF_TALER_EXCHANGEDB_coin_init (dki,
reserve);
deposit = PERF_TALER_EXCHANGEDB_deposit_init (coin);
dki_copy = PERF_TALER_EXCHANGEDB_denomination_copy (dki);
reserve_copy = PERF_TALER_EXCHANGEDB_reserve_copy (reserve);
coin_copy = PERF_TALER_EXCHANGEDB_coin_copy (coin);
deposit_copy = PERF_TALER_EXCHANGEDB_deposit_copy (deposit);
PERF_TALER_EXCHANGEDB_denomination_free (dki);
PERF_TALER_EXCHANGEDB_denomination_free (dki_copy);
PERF_TALER_EXCHANGEDB_reserve_free (reserve);
PERF_TALER_EXCHANGEDB_reserve_free (reserve_copy);
PERF_TALER_EXCHANGEDB_coin_free (coin);
PERF_TALER_EXCHANGEDB_coin_free (coin_copy);
PERF_TALER_EXCHANGEDB_deposit_free (deposit);
PERF_TALER_EXCHANGEDB_deposit_free (deposit_copy);
}
/**
* Runs the performances tests for the exchange database
* and logs the results using Gauger
*/
int
main (int argc, char **argv)
{
int ret = 0;
struct PERF_TALER_EXCHANGEDB_Cmd init[] = {
PERF_TALER_EXCHANGEDB_INIT_CMD_END ("init")
};
struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = {
// Denomination used to create coins
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop",
NB_DENOMINATION_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert",
"01 - denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (
"01 - commit transaction"),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
"01 - denomination loop",
"01 - denomination",
NB_DENOMINATION_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - denomination loop end",
"01 - denomination loop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("01 - init denomination complete"),
// End of initialization
// Reserve initialization
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop",
NB_RESERVE_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert",
"02 - reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
"02 - init reserve loop",
"02 - reserve",
NB_RESERVE_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - init reserve end loop",
"02 - init reserve loop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("02 - reserve init complete"),
// End reserve init
// Withdrawal initialization
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop",
NB_WITHDRAW_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
"03 - init withdraw loop",
"01 - save denomination"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
"03 - init withdraw loop",
"02 - save reserve"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw",
"03 - denomination load",
"03 - reserve load"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert withdraw",
"03 - withdraw"),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (
"03 - commit transaction"),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - coin array",
"03 - init withdraw loop",
"03 - withdraw",
NB_WITHDRAW_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop",
"03 - init withdraw loop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
// End of withdrawal initialization
// Deposit initialization
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time start"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop",
NB_DEPOSIT_INIT),
PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"),
PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load",
"04 - deposit init loop",
"03 - coin array"),
PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit",
"04 - coin load"),
PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert deposit",
"04 - deposit"),
PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (
"04 - commit transaction"),
PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
"04 - deposit init loop",
"04 - deposit",
NB_DEPOSIT_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("04 - deposit init loop end",
"04 - deposit init loop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time stop"),
PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("04 - gauger",
"04 - time start",
"04 - time stop",
"TEST",
"time to insert a deposit",
"deposit/sec",
NB_DEPOSIT_SAVE),
PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("04 - deposit init complete"),
// 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);
if (GNUNET_SYSERR == ret)
return 1;
if (GNUNET_NO == ret)
return 77; /* testcase skipped */
return 0;
}