move function to libtalerexchangedb, as planned
This commit is contained in:
parent
0a415262da
commit
0305cf5f9e
@ -39,7 +39,7 @@
|
|||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "taler_auditordb_plugin.h"
|
#include "taler_auditordb_plugin.h"
|
||||||
#include "taler_exchangedb_plugin.h"
|
#include "taler_exchangedb_lib.h"
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <gnunet/gnunet_curl_lib.h>
|
#include <gnunet/gnunet_curl_lib.h>
|
||||||
#include "taler_auditordb_plugin.h"
|
#include "taler_auditordb_plugin.h"
|
||||||
#include "taler_exchangedb_plugin.h"
|
#include "taler_exchangedb_lib.h"
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
|
@ -1293,6 +1293,7 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h)
|
|||||||
h);
|
h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/**
|
/**
|
||||||
* Schedule MHD. This function should be called initially when an
|
* Schedule MHD. This function should be called initially when an
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "taler_exchangedb_plugin.h"
|
#include "taler_exchangedb_lib.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1835,7 +1835,7 @@ run_transfers (void *cls)
|
|||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
db_plugin->start (db_plugin->cls,
|
db_plugin->start (db_plugin->cls,
|
||||||
session,
|
session,
|
||||||
"aggregator run transfer"))
|
"aggregator run transfer"))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Failed to start database transaction!\n");
|
"Failed to start database transaction!\n");
|
||||||
|
@ -165,123 +165,4 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the total value of all transactions performed.
|
|
||||||
* Stores @a off plus the cost of all transactions in @a tl
|
|
||||||
* in @a ret.
|
|
||||||
*
|
|
||||||
* @param tl transaction list to process
|
|
||||||
* @param off offset to use as the starting value
|
|
||||||
* @param[out] ret where the resulting total is to be stored
|
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
|
|
||||||
*/
|
|
||||||
// FIXME: maybe move to another module, i.e. exchangedb???
|
|
||||||
int
|
|
||||||
TEH_DB_calculate_transaction_list_totals (struct
|
|
||||||
TALER_EXCHANGEDB_TransactionList *tl,
|
|
||||||
const struct TALER_Amount *off,
|
|
||||||
struct TALER_Amount *ret)
|
|
||||||
{
|
|
||||||
struct TALER_Amount spent = *off;
|
|
||||||
struct TALER_Amount refunded;
|
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
|
||||||
TALER_amount_get_zero (spent.currency,
|
|
||||||
&refunded));
|
|
||||||
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos =
|
|
||||||
pos->next)
|
|
||||||
{
|
|
||||||
switch (pos->type)
|
|
||||||
{
|
|
||||||
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
|
||||||
/* spent += pos->amount_with_fee */
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_amount_add (&spent,
|
|
||||||
&spent,
|
|
||||||
&pos->details.deposit->amount_with_fee))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TALER_EXCHANGEDB_TT_REFRESH_MELT:
|
|
||||||
/* spent += pos->amount_with_fee */
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_amount_add (&spent,
|
|
||||||
&spent,
|
|
||||||
&pos->details.melt->session.amount_with_fee))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TALER_EXCHANGEDB_TT_REFUND:
|
|
||||||
/* refunded += pos->refund_amount - pos->refund_fee */
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_amount_add (&refunded,
|
|
||||||
&refunded,
|
|
||||||
&pos->details.refund->refund_amount))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_amount_subtract (&refunded,
|
|
||||||
&refunded,
|
|
||||||
&pos->details.refund->refund_fee))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK:
|
|
||||||
/* refunded += pos->value */
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_amount_add (&refunded,
|
|
||||||
&refunded,
|
|
||||||
&pos->details.old_coin_payback->value))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TALER_EXCHANGEDB_TT_PAYBACK:
|
|
||||||
/* spent += pos->value */
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_amount_add (&spent,
|
|
||||||
&spent,
|
|
||||||
&pos->details.payback->value))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH:
|
|
||||||
/* spent += pos->value */
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_amount_add (&spent,
|
|
||||||
&spent,
|
|
||||||
&pos->details.payback_refresh->value))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* spent = spent - refunded */
|
|
||||||
if (GNUNET_SYSERR ==
|
|
||||||
TALER_amount_subtract (&spent,
|
|
||||||
&spent,
|
|
||||||
&refunded))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ret = spent;
|
|
||||||
return GNUNET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* end of taler-exchange-httpd_db.c */
|
/* end of taler-exchange-httpd_db.c */
|
||||||
|
@ -107,23 +107,5 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
|
|||||||
void *cb_cls);
|
void *cb_cls);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the total value of all transactions performed.
|
|
||||||
* Stores @a off plus the cost of all transactions in @a tl
|
|
||||||
* in @a ret.
|
|
||||||
*
|
|
||||||
* @param tl transaction list to process
|
|
||||||
* @param off offset to use as the starting value
|
|
||||||
* @param[out] ret where the resulting total is to be stored
|
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
|
|
||||||
*/
|
|
||||||
// FIXME: maybe move to another module, i.e. exchangedb???
|
|
||||||
int
|
|
||||||
TEH_DB_calculate_transaction_list_totals (struct
|
|
||||||
TALER_EXCHANGEDB_TransactionList *tl,
|
|
||||||
const struct TALER_Amount *off,
|
|
||||||
struct TALER_Amount *ret);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* TALER_EXCHANGE_HTTPD_DB_H */
|
/* TALER_EXCHANGE_HTTPD_DB_H */
|
||||||
|
@ -193,9 +193,9 @@ deposit_transaction (void *cls,
|
|||||||
if (0 > qs)
|
if (0 > qs)
|
||||||
return qs;
|
return qs;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TEH_DB_calculate_transaction_list_totals (tl,
|
TALER_EXCHANGEDB_calculate_transaction_list_totals (tl,
|
||||||
&spent,
|
&spent,
|
||||||
&spent))
|
&spent))
|
||||||
{
|
{
|
||||||
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
||||||
tl);
|
tl);
|
||||||
|
@ -312,9 +312,9 @@ payback_transaction (void *cls,
|
|||||||
TALER_amount_get_zero (pc->value.currency,
|
TALER_amount_get_zero (pc->value.currency,
|
||||||
&spent));
|
&spent));
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TEH_DB_calculate_transaction_list_totals (tl,
|
TALER_EXCHANGEDB_calculate_transaction_list_totals (tl,
|
||||||
&spent,
|
&spent,
|
||||||
&spent))
|
&spent))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
||||||
|
@ -225,9 +225,9 @@ refresh_check_melt (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TEH_DB_calculate_transaction_list_totals (tl,
|
TALER_EXCHANGEDB_calculate_transaction_list_totals (tl,
|
||||||
&spent,
|
&spent,
|
||||||
&spent))
|
&spent))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
||||||
|
@ -46,8 +46,9 @@ libtalerexchangedb_la_SOURCES = \
|
|||||||
exchangedb_auditorkeys.c \
|
exchangedb_auditorkeys.c \
|
||||||
exchangedb_denomkeys.c \
|
exchangedb_denomkeys.c \
|
||||||
exchangedb_fees.c \
|
exchangedb_fees.c \
|
||||||
|
exchangedb_plugin.c \
|
||||||
exchangedb_signkeys.c \
|
exchangedb_signkeys.c \
|
||||||
exchangedb_plugin.c
|
exchangedb_transactions.c
|
||||||
|
|
||||||
libtalerexchangedb_la_LIBADD = \
|
libtalerexchangedb_la_LIBADD = \
|
||||||
$(top_builddir)/src/util/libtalerutil.la \
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2017 GNUnet e.V.
|
Copyright (C) 2017 Taler Systems SA
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
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
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
142
src/exchangedb/exchangedb_transactions.c
Normal file
142
src/exchangedb/exchangedb_transactions.c
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
Copyright (C) 2017-2020 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/exchangedb_transactions.c
|
||||||
|
* @brief Logic to compute transaction totals of a transaction list for a coin
|
||||||
|
* @author Christian Grothoff
|
||||||
|
*/
|
||||||
|
#include "platform.h"
|
||||||
|
#include "taler_exchangedb_lib.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the total value of all transactions performed.
|
||||||
|
* Stores @a off plus the cost of all transactions in @a tl
|
||||||
|
* in @a ret.
|
||||||
|
*
|
||||||
|
* @param tl transaction list to process
|
||||||
|
* @param off offset to use as the starting value
|
||||||
|
* @param[out] ret where the resulting total is to be stored
|
||||||
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_EXCHANGEDB_calculate_transaction_list_totals (struct
|
||||||
|
TALER_EXCHANGEDB_TransactionList
|
||||||
|
*tl,
|
||||||
|
const struct
|
||||||
|
TALER_Amount *off,
|
||||||
|
struct TALER_Amount *ret)
|
||||||
|
{
|
||||||
|
struct TALER_Amount spent = *off;
|
||||||
|
struct TALER_Amount refunded;
|
||||||
|
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_amount_get_zero (spent.currency,
|
||||||
|
&refunded));
|
||||||
|
for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos =
|
||||||
|
pos->next)
|
||||||
|
{
|
||||||
|
switch (pos->type)
|
||||||
|
{
|
||||||
|
case TALER_EXCHANGEDB_TT_DEPOSIT:
|
||||||
|
/* spent += pos->amount_with_fee */
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_add (&spent,
|
||||||
|
&spent,
|
||||||
|
&pos->details.deposit->amount_with_fee))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_TT_REFRESH_MELT:
|
||||||
|
/* spent += pos->amount_with_fee */
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_add (&spent,
|
||||||
|
&spent,
|
||||||
|
&pos->details.melt->session.amount_with_fee))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_TT_REFUND:
|
||||||
|
/* refunded += pos->refund_amount - pos->refund_fee */
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_add (&refunded,
|
||||||
|
&refunded,
|
||||||
|
&pos->details.refund->refund_amount))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_subtract (&refunded,
|
||||||
|
&refunded,
|
||||||
|
&pos->details.refund->refund_fee))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK:
|
||||||
|
/* refunded += pos->value */
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_add (&refunded,
|
||||||
|
&refunded,
|
||||||
|
&pos->details.old_coin_payback->value))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_TT_PAYBACK:
|
||||||
|
/* spent += pos->value */
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_add (&spent,
|
||||||
|
&spent,
|
||||||
|
&pos->details.payback->value))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH:
|
||||||
|
/* spent += pos->value */
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_amount_add (&spent,
|
||||||
|
&spent,
|
||||||
|
&pos->details.payback_refresh->value))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* spent = spent - refunded */
|
||||||
|
if (GNUNET_SYSERR ==
|
||||||
|
TALER_amount_subtract (&spent,
|
||||||
|
&spent,
|
||||||
|
&refunded))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ret = spent;
|
||||||
|
return GNUNET_OK;
|
||||||
|
}
|
@ -23,9 +23,8 @@
|
|||||||
#ifndef TALER_EXCHANGEDB_LIB_H
|
#ifndef TALER_EXCHANGEDB_LIB_H
|
||||||
#define TALER_EXCHANGEDB_LIB_H
|
#define TALER_EXCHANGEDB_LIB_H
|
||||||
|
|
||||||
|
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
|
#include "taler_exchangedb_plugin.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subdirectroy under the exchange's base directory which contains
|
* Subdirectroy under the exchange's base directory which contains
|
||||||
@ -40,81 +39,6 @@
|
|||||||
#define TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS "denomkeys"
|
#define TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS "denomkeys"
|
||||||
|
|
||||||
|
|
||||||
GNUNET_NETWORK_STRUCT_BEGIN
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief On disk format used for a exchange signing key. Signing keys are used
|
|
||||||
* by the exchange to affirm its messages, but not to create coins.
|
|
||||||
* Includes the private key followed by the public information about
|
|
||||||
* the signing key.
|
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Private key part of the exchange's signing key.
|
|
||||||
*/
|
|
||||||
struct TALER_ExchangePrivateKeyP signkey_priv;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signature over @e issue
|
|
||||||
*/
|
|
||||||
struct TALER_MasterSignatureP master_sig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Public information about a exchange signing key.
|
|
||||||
*/
|
|
||||||
struct TALER_ExchangeSigningKeyValidityPS issue;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Information about a denomination key.
|
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGEDB_DenominationKeyInformationP
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signature over this struct to affirm the validity of the key.
|
|
||||||
*/
|
|
||||||
struct TALER_MasterSignatureP signature;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signed properties of the denomination key.
|
|
||||||
*/
|
|
||||||
struct TALER_DenominationKeyValidityPS properties;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GNUNET_NETWORK_STRUCT_END
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief All information about a denomination key (which is used to
|
|
||||||
* sign coins into existence).
|
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The private key of the denomination. Will be NULL if the private
|
|
||||||
* key is not available (this is the case after the key has expired
|
|
||||||
* for signing coins, but is still valid for depositing coins).
|
|
||||||
*/
|
|
||||||
struct TALER_DenominationPrivateKey denom_priv;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decoded denomination public key (the hash of it is in
|
|
||||||
* @e issue, but we sometimes need the full public key as well).
|
|
||||||
*/
|
|
||||||
struct TALER_DenominationPublicKey denom_pub;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signed public information about a denomination key.
|
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Iterator over signing keys.
|
* @brief Iterator over signing keys.
|
||||||
*
|
*
|
||||||
@ -525,4 +449,23 @@ TALER_EXCHANGEDB_find_accounts (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
void *cb_cls);
|
void *cb_cls);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the total value of all transactions performed.
|
||||||
|
* Stores @a off plus the cost of all transactions in @a tl
|
||||||
|
* in @a ret.
|
||||||
|
*
|
||||||
|
* @param tl transaction list to process
|
||||||
|
* @param off offset to use as the starting value
|
||||||
|
* @param[out] ret where the resulting total is to be stored
|
||||||
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on errors
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_EXCHANGEDB_calculate_transaction_list_totals (struct
|
||||||
|
TALER_EXCHANGEDB_TransactionList
|
||||||
|
*tl,
|
||||||
|
const struct
|
||||||
|
TALER_Amount *off,
|
||||||
|
struct TALER_Amount *ret);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,82 @@
|
|||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <gnunet/gnunet_db_lib.h>
|
#include <gnunet/gnunet_db_lib.h>
|
||||||
#include "taler_exchangedb_lib.h"
|
#include "taler_signatures.h"
|
||||||
|
|
||||||
|
|
||||||
|
GNUNET_NETWORK_STRUCT_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief On disk format used for a exchange signing key. Signing keys are used
|
||||||
|
* by the exchange to affirm its messages, but not to create coins.
|
||||||
|
* Includes the private key followed by the public information about
|
||||||
|
* the signing key.
|
||||||
|
*/
|
||||||
|
struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Private key part of the exchange's signing key.
|
||||||
|
*/
|
||||||
|
struct TALER_ExchangePrivateKeyP signkey_priv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signature over @e issue
|
||||||
|
*/
|
||||||
|
struct TALER_MasterSignatureP master_sig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public information about a exchange signing key.
|
||||||
|
*/
|
||||||
|
struct TALER_ExchangeSigningKeyValidityPS issue;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about a denomination key.
|
||||||
|
*/
|
||||||
|
struct TALER_EXCHANGEDB_DenominationKeyInformationP
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signature over this struct to affirm the validity of the key.
|
||||||
|
*/
|
||||||
|
struct TALER_MasterSignatureP signature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signed properties of the denomination key.
|
||||||
|
*/
|
||||||
|
struct TALER_DenominationKeyValidityPS properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GNUNET_NETWORK_STRUCT_END
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief All information about a denomination key (which is used to
|
||||||
|
* sign coins into existence).
|
||||||
|
*/
|
||||||
|
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The private key of the denomination. Will be NULL if the private
|
||||||
|
* key is not available (this is the case after the key has expired
|
||||||
|
* for signing coins, but is still valid for depositing coins).
|
||||||
|
*/
|
||||||
|
struct TALER_DenominationPrivateKey denom_priv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decoded denomination public key (the hash of it is in
|
||||||
|
* @e issue, but we sometimes need the full public key as well).
|
||||||
|
*/
|
||||||
|
struct TALER_DenominationPublicKey denom_pub;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signed public information about a denomination key.
|
||||||
|
*/
|
||||||
|
struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1679,6 +1679,7 @@ TALER_TESTING_cmd_serialize_keys (const char *label);
|
|||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_connect_with_state (const char *label,
|
TALER_TESTING_cmd_connect_with_state (const char *label,
|
||||||
const char *state_reference);
|
const char *state_reference);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the "insert-deposit" CMD.
|
* Make the "insert-deposit" CMD.
|
||||||
*
|
*
|
||||||
@ -1694,12 +1695,13 @@ TALER_TESTING_cmd_connect_with_state (const char *label,
|
|||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_insert_deposit (const char *label,
|
TALER_TESTING_cmd_insert_deposit (const char *label,
|
||||||
const struct TALER_TESTING_DatabaseConnection *dbc,
|
const struct
|
||||||
const char *merchant_name,
|
TALER_TESTING_DatabaseConnection *dbc,
|
||||||
const char *merchant_account,
|
const char *merchant_name,
|
||||||
struct GNUNET_TIME_Relative wire_deadline,
|
const char *merchant_account,
|
||||||
const char *amount_with_fee,
|
struct GNUNET_TIME_Relative wire_deadline,
|
||||||
const char *deposit_fee);
|
const char *amount_with_fee,
|
||||||
|
const char *deposit_fee);
|
||||||
|
|
||||||
/* *** Generic trait logic for implementing traits ********* */
|
/* *** Generic trait logic for implementing traits ********* */
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ static char *config_filename;
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
prepare_database (void *cls,
|
prepare_database (void *cls,
|
||||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||||
{
|
{
|
||||||
|
|
||||||
// connect to the database.
|
// connect to the database.
|
||||||
@ -103,424 +103,436 @@ run (void *cls,
|
|||||||
|
|
||||||
// check no aggregation happens on a empty database
|
// check no aggregation happens on a empty database
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-on-empty-db",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-on-empty-db",
|
||||||
config_filename),
|
config_filename),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
|
||||||
|
|
||||||
// check aggregation happens on the simplest case:
|
// check aggregation happens on the simplest case:
|
||||||
// one deposit into the database.
|
// one deposit into the database.
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-1",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-1",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-on-deposit-1",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-on-deposit-1",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.89",
|
"EUR:0.89",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-1"),
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-1"),
|
||||||
|
|
||||||
// check aggregation accumulates well.
|
// check aggregation accumulates well.
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-2a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-2a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-2b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-2b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-2",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-2",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:1.79",
|
"EUR:1.79",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-2"),
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-2"),
|
||||||
|
|
||||||
// check that different merchants stem different aggregations.
|
// check that different merchants stem different aggregations.
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-3a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
"4",
|
"4",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-3b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
"5",
|
"5",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3c",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-3c",
|
||||||
&dbc,
|
&dbc,
|
||||||
"alice",
|
"alice",
|
||||||
"4",
|
"4",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-3",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-3",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.89",
|
"EUR:0.89",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
TALER_payto_xtalerbank_make (bc.bank_url, "4")),
|
TALER_payto_xtalerbank_make (
|
||||||
|
bc.bank_url, "4")),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.89",
|
"EUR:0.89",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
TALER_payto_xtalerbank_make (bc.bank_url, "4")),
|
TALER_payto_xtalerbank_make (
|
||||||
|
bc.bank_url, "4")),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.89",
|
"EUR:0.89",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
TALER_payto_xtalerbank_make (bc.bank_url, "5")),
|
TALER_payto_xtalerbank_make (
|
||||||
|
bc.bank_url, "5")),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"),
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"),
|
||||||
|
|
||||||
// checking that aggregator waits for the deadline.
|
// checking that aggregator waits for the deadline.
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-4a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-4a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
|
|
||||||
"EUR:0.2",
|
"EUR:0.2",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-4b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-4b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
|
|
||||||
"EUR:0.2",
|
"EUR:0.2",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-4-early",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-4-early",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-4-fast"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-4-fast"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_sleep ("wait (5s)", 5),
|
TALER_TESTING_cmd_sleep ("wait (5s)", 5),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-4-delayed",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-4-delayed",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.19",
|
"EUR:0.19",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
|
|
||||||
// test picking all deposits at earliest deadline
|
// test picking all deposits at earliest deadline
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-5a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-5a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
10),
|
10),
|
||||||
|
|
||||||
"EUR:0.2",
|
"EUR:0.2",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-5b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-5b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
|
|
||||||
"EUR:0.2",
|
"EUR:0.2",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-5-early",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-5-early",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-5-early"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-5-early"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_sleep ("wait (5s)", 5),
|
TALER_TESTING_cmd_sleep ("wait (5s)", 5),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-5-delayed",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-5-delayed",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.19",
|
"EUR:0.19",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
|
|
||||||
// Test NEVER running 'tiny' unless they make up minimum unit
|
// Test NEVER running 'tiny' unless they make up minimum unit
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.102",
|
"EUR:0.102",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6a-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6a-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-6a-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-6a-tiny"),
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.102",
|
"EUR:0.102",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6c",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6c",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.102",
|
"EUR:0.102",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6c-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6c-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-6c-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-6c-tiny"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6d",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6d",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.102",
|
"EUR:0.102",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6d-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6d-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-6d-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-6d-tiny"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6e",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6e",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.112",
|
"EUR:0.112",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6e",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-6e",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.01",
|
"EUR:0.01",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
|
|
||||||
|
|
||||||
// Test profiteering if wire deadline is short
|
// Test profiteering if wire deadline is short
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-7a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.109",
|
"EUR:0.109",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-7a-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-7a-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-7a-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-7a-tiny"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-7b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.119",
|
"EUR:0.119",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-7-profit",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-7-profit",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.01",
|
"EUR:0.01",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
|
|
||||||
// Now check profit was actually taken
|
// Now check profit was actually taken
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7c",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-7c",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.122",
|
"EUR:0.122",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-7-loss",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-7-loss",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.01",
|
"EUR:0.01",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
|
|
||||||
// Test that aggregation would happen fully if wire deadline is long
|
// Test that aggregation would happen fully if wire deadline is long
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-8a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
|
|
||||||
"EUR:0.109",
|
"EUR:0.109",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-8a-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-8a-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-8a-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-8a-tiny"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-8b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
|
|
||||||
"EUR:0.109",
|
"EUR:0.109",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-8b-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-8b-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-8b-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-8b-tiny"),
|
||||||
|
|
||||||
|
|
||||||
// now trigger aggregate with large transaction and short deadline
|
// now trigger aggregate with large transaction and short deadline
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8c",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-8c",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.122",
|
"EUR:0.122",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-8",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-8",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.03",
|
"EUR:0.03",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
|
|
||||||
|
|
||||||
// Test aggregation with fees and rounding profits.
|
// Test aggregation with fees and rounding profits.
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9a",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-9a",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
|
|
||||||
"EUR:0.104",
|
"EUR:0.104",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-9a-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-9a-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-9a-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-9a-tiny"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9b",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-9b",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
|
|
||||||
GNUNET_TIME_relative_multiply
|
GNUNET_TIME_relative_multiply
|
||||||
(GNUNET_TIME_UNIT_SECONDS,
|
(GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
|
|
||||||
"EUR:0.105",
|
"EUR:0.105",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-9b-tiny",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-9b-tiny",
|
||||||
config_filename),
|
config_filename),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-9b-tiny"),
|
TALER_TESTING_cmd_check_bank_empty (
|
||||||
|
"expect-empty-transactions-after-9b-tiny"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// now trigger aggregate with large transaction and short deadline
|
// now trigger aggregate with large transaction and short deadline
|
||||||
|
|
||||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9c",
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-9c",
|
||||||
&dbc,
|
&dbc,
|
||||||
"bob",
|
"bob",
|
||||||
USER42_ACCOUNT,
|
USER42_ACCOUNT,
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:0.112",
|
"EUR:0.112",
|
||||||
"EUR:0.1"),
|
"EUR:0.1"),
|
||||||
|
|
||||||
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-9",
|
TALER_TESTING_cmd_exec_aggregator ("run-aggregator-deposit-9",
|
||||||
config_filename),
|
config_filename),
|
||||||
|
|
||||||
// 0.009 + 0.009 + 0.022 - 0.001 - 0.002 - 0.008 = 0.029 => 0.02
|
// 0.009 + 0.009 + 0.022 - 0.001 - 0.002 - 0.008 = 0.029 => 0.02
|
||||||
|
|
||||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-9",
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-9",
|
||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:0.01",
|
"EUR:0.01",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user42_payto),
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
TALER_TESTING_run_with_fakebank (is,
|
TALER_TESTING_run_with_fakebank (is,
|
||||||
all,
|
all,
|
||||||
bc.bank_url);
|
bc.bank_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
@ -552,22 +564,22 @@ main (int argc,
|
|||||||
TALER_TESTING_cleanup_files (config_filename);
|
TALER_TESTING_cleanup_files (config_filename);
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_TESTING_prepare_exchange (config_filename,
|
if (GNUNET_OK != TALER_TESTING_prepare_exchange (config_filename,
|
||||||
&ec))
|
&ec))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Could not prepare the exchange.\n");
|
TALER_LOG_WARNING ("Could not prepare the exchange.\n");
|
||||||
return 77;
|
return 77;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_TESTING_prepare_fakebank (config_filename,
|
if (GNUNET_OK != TALER_TESTING_prepare_fakebank (config_filename,
|
||||||
"account-1",
|
"account-1",
|
||||||
&bc))
|
&bc))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Could not prepare the fakebank\n");
|
TALER_LOG_WARNING ("Could not prepare the fakebank\n");
|
||||||
return 77;
|
return 77;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK != GNUNET_CONFIGURATION_parse_and_run (config_filename,
|
if (GNUNET_OK != GNUNET_CONFIGURATION_parse_and_run (config_filename,
|
||||||
&prepare_database,
|
&prepare_database,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Could not prepare database for tests.\n");
|
TALER_LOG_WARNING ("Could not prepare database for tests.\n");
|
||||||
@ -575,10 +587,10 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = TALER_TESTING_setup (&run,
|
result = TALER_TESTING_setup (&run,
|
||||||
NULL,
|
NULL,
|
||||||
config_filename,
|
config_filename,
|
||||||
NULL, // no exchange process handle.
|
NULL, // no exchange process handle.
|
||||||
GNUNET_NO); // do not try to connect to the exchange
|
GNUNET_NO); // do not try to connect to the exchange
|
||||||
|
|
||||||
GNUNET_free (config_filename);
|
GNUNET_free (config_filename);
|
||||||
GNUNET_free (testname);
|
GNUNET_free (testname);
|
||||||
|
@ -98,8 +98,6 @@ fake_issue (struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the command.
|
* Run the command.
|
||||||
*
|
*
|
||||||
@ -147,7 +145,7 @@ insert_deposit_run (void *cls,
|
|||||||
// prepare and store deposit now.
|
// prepare and store deposit now.
|
||||||
memset (&deposit,
|
memset (&deposit,
|
||||||
0,
|
0,
|
||||||
sizeof (deposit));
|
sizeof (deposit));
|
||||||
|
|
||||||
GNUNET_CRYPTO_kdf (&merchant_priv,
|
GNUNET_CRYPTO_kdf (&merchant_priv,
|
||||||
sizeof (struct TALER_MerchantPrivateKeyP),
|
sizeof (struct TALER_MerchantPrivateKeyP),
|
||||||
@ -156,7 +154,7 @@ insert_deposit_run (void *cls,
|
|||||||
ids->merchant_name,
|
ids->merchant_name,
|
||||||
strlen (ids->merchant_name),
|
strlen (ids->merchant_name),
|
||||||
NULL,
|
NULL,
|
||||||
0);
|
0);
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&merchant_priv.eddsa_priv,
|
GNUNET_CRYPTO_eddsa_key_get_public (&merchant_priv.eddsa_priv,
|
||||||
&deposit.merchant_pub.eddsa_pub);
|
&deposit.merchant_pub.eddsa_pub);
|
||||||
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
@ -173,7 +171,7 @@ insert_deposit_run (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_CRYPTO_rsa_public_key_hash (dpk.rsa_public_key,
|
GNUNET_CRYPTO_rsa_public_key_hash (dpk.rsa_public_key,
|
||||||
&deposit.coin.denom_pub_hash);
|
&deposit.coin.denom_pub_hash);
|
||||||
|
|
||||||
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
&hc);
|
&hc);
|
||||||
@ -283,12 +281,13 @@ insert_deposit_traits (void *cls,
|
|||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Command
|
struct TALER_TESTING_Command
|
||||||
TALER_TESTING_cmd_insert_deposit (const char *label,
|
TALER_TESTING_cmd_insert_deposit (const char *label,
|
||||||
const struct TALER_TESTING_DatabaseConnection *dbc,
|
const struct
|
||||||
const char *merchant_name,
|
TALER_TESTING_DatabaseConnection *dbc,
|
||||||
const char *merchant_account,
|
const char *merchant_name,
|
||||||
struct GNUNET_TIME_Relative wire_deadline,
|
const char *merchant_account,
|
||||||
const char *amount_with_fee,
|
struct GNUNET_TIME_Relative wire_deadline,
|
||||||
const char *deposit_fee)
|
const char *amount_with_fee,
|
||||||
|
const char *deposit_fee)
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Command cmd;
|
struct TALER_TESTING_Command cmd;
|
||||||
struct InsertDepositState *ids;
|
struct InsertDepositState *ids;
|
||||||
|
Loading…
Reference in New Issue
Block a user