2016-03-30 22:56:17 +02:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
2020-01-12 18:19:18 +01:00
|
|
|
(C) 2016-2020 Taler Systems SA
|
2016-03-30 22:56:17 +02:00
|
|
|
|
|
|
|
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
|
2016-07-07 17:55:25 +02:00
|
|
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
2016-03-30 22:56:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2020-01-19 15:23:19 +01:00
|
|
|
* @file testing/test_taler_exchange_aggregator.c
|
2016-03-30 22:56:17 +02:00
|
|
|
* @brief Tests for taler-exchange-aggregator logic
|
|
|
|
* @author Christian Grothoff <christian@grothoff.org>
|
2020-01-16 20:43:49 +01:00
|
|
|
* @author Marcello Stanisci
|
2016-03-30 22:56:17 +02:00
|
|
|
*/
|
|
|
|
#include "platform.h"
|
|
|
|
#include "taler_util.h"
|
2016-04-04 14:26:24 +02:00
|
|
|
#include <gnunet/gnunet_json_lib.h>
|
2016-04-04 14:43:42 +02:00
|
|
|
#include "taler_json_lib.h"
|
2020-01-17 00:20:39 +01:00
|
|
|
#include "taler_exchangedb_lib.h"
|
2016-04-04 14:04:44 +02:00
|
|
|
#include <microhttpd.h>
|
2016-06-08 11:35:28 +02:00
|
|
|
#include "taler_fakebank_lib.h"
|
2020-01-16 12:54:05 +01:00
|
|
|
#include "taler_testing_lib.h"
|
2016-04-04 14:04:44 +02:00
|
|
|
|
2016-04-04 14:43:42 +02:00
|
|
|
|
2020-01-16 12:54:05 +01:00
|
|
|
/**
|
|
|
|
* Helper structure to keep exchange configuration values.
|
|
|
|
*/
|
|
|
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bank configuration data.
|
|
|
|
*/
|
|
|
|
static struct TALER_TESTING_BankConfiguration bc;
|
|
|
|
|
2020-01-16 18:37:07 +01:00
|
|
|
/**
|
2021-08-23 00:00:32 +02:00
|
|
|
* Contains plugin.
|
2020-01-16 18:37:07 +01:00
|
|
|
*/
|
|
|
|
static struct TALER_TESTING_DatabaseConnection dbc;
|
|
|
|
|
2016-03-30 22:56:17 +02:00
|
|
|
/**
|
|
|
|
* Return value from main().
|
|
|
|
*/
|
|
|
|
static int result;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Name of the configuration file to use.
|
|
|
|
*/
|
|
|
|
static char *config_filename;
|
|
|
|
|
2020-01-16 18:50:31 +01:00
|
|
|
#define USER42_ACCOUNT "42"
|
2020-01-16 18:37:07 +01:00
|
|
|
|
2020-01-16 12:54:05 +01:00
|
|
|
|
2020-03-12 10:53:49 +01:00
|
|
|
/**
|
|
|
|
* Execute the taler-exchange-aggregator, closer and transfer commands with
|
|
|
|
* our configuration file.
|
|
|
|
*
|
|
|
|
* @param label label to use for the command.
|
|
|
|
* @param cfg_fn configuration file to use
|
|
|
|
*/
|
|
|
|
#define CMD_EXEC_AGGREGATOR(label, cfg_fn) \
|
|
|
|
TALER_TESTING_cmd_exec_aggregator (label "-aggregator", cfg_fn), \
|
|
|
|
TALER_TESTING_cmd_exec_transfer (label "-transfer", cfg_fn)
|
|
|
|
|
|
|
|
|
2020-03-15 00:36:15 +01:00
|
|
|
/**
|
|
|
|
* Function run on shutdown to unload the DB plugin.
|
|
|
|
*
|
|
|
|
* @param cls NULL
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
unload_db (void *cls)
|
|
|
|
{
|
|
|
|
(void) cls;
|
|
|
|
if (NULL != dbc.plugin)
|
|
|
|
{
|
|
|
|
dbc.plugin->drop_tables (dbc.plugin->cls);
|
|
|
|
TALER_EXCHANGEDB_plugin_unload (dbc.plugin);
|
|
|
|
dbc.plugin = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-16 14:40:28 +01:00
|
|
|
/**
|
|
|
|
* Collects all the tests.
|
|
|
|
*/
|
2020-01-16 12:54:05 +01:00
|
|
|
static void
|
|
|
|
run (void *cls,
|
|
|
|
struct TALER_TESTING_Interpreter *is)
|
|
|
|
{
|
2020-01-16 14:40:28 +01:00
|
|
|
struct TALER_TESTING_Command all[] = {
|
2020-12-16 19:31:46 +01:00
|
|
|
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
|
|
|
config_filename,
|
|
|
|
"EUR:0.01",
|
2022-03-05 14:36:49 +01:00
|
|
|
"EUR:0.01",
|
2020-12-16 19:31:46 +01:00
|
|
|
"EUR:0.01"),
|
2020-01-16 19:10:45 +01:00
|
|
|
// check no aggregation happens on a empty database
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty-db",
|
|
|
|
config_filename),
|
2020-01-16 18:37:07 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
|
2020-01-16 19:10:45 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* check aggregation happens on the simplest case:
|
|
|
|
one deposit into the database. */
|
2020-01-16 18:37:07 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-1",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:1",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-on-deposit-1",
|
|
|
|
config_filename),
|
2020-01-16 18:50:31 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.89",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-1"),
|
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* check aggregation accumulates well. */
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-2a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:1",
|
|
|
|
"EUR:0.1"),
|
2020-01-16 19:10:45 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-2b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:1",
|
|
|
|
"EUR:0.1"),
|
2020-01-16 19:10:45 +01:00
|
|
|
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-2",
|
|
|
|
config_filename),
|
2020-01-16 19:10:45 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:1.79",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-2"),
|
2020-01-16 22:40:12 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* check that different merchants stem different aggregations. */
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-3a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
"4",
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:1",
|
|
|
|
"EUR:0.1"),
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-3b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
"5",
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:1",
|
|
|
|
"EUR:0.1"),
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-3c",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"alice",
|
|
|
|
"4",
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:1",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-3",
|
|
|
|
config_filename),
|
2020-01-16 19:10:45 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.89",
|
|
|
|
bc.exchange_payto,
|
2020-01-17 03:39:15 +01:00
|
|
|
"payto://x-taler-bank/localhost/4"),
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.89",
|
|
|
|
bc.exchange_payto,
|
2020-01-17 03:39:15 +01:00
|
|
|
"payto://x-taler-bank/localhost/4"),
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.89",
|
|
|
|
bc.exchange_payto,
|
2020-01-17 03:39:15 +01:00
|
|
|
"payto://x-taler-bank/localhost/5"),
|
2020-01-16 19:10:45 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"),
|
2020-01-16 19:38:38 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* checking that aggregator waits for the deadline. */
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-4a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
5),
|
|
|
|
"EUR:0.2",
|
|
|
|
"EUR:0.1"),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-4b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
5),
|
|
|
|
"EUR:0.2",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-4-early",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-4-fast"),
|
2020-01-16 19:38:38 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_sleep ("wait (5s)", 5),
|
|
|
|
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-4-delayed",
|
|
|
|
config_filename),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.19",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-16 19:38:38 +01:00
|
|
|
|
|
|
|
// test picking all deposits at earliest deadline
|
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-5a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
10),
|
|
|
|
"EUR:0.2",
|
|
|
|
"EUR:0.1"),
|
2020-01-16 19:38:38 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-5b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
5),
|
|
|
|
"EUR:0.2",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-5-early",
|
|
|
|
config_filename),
|
2020-01-16 19:38:38 +01:00
|
|
|
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-5-early"),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_sleep ("wait (5s)", 5),
|
|
|
|
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-5-delayed",
|
|
|
|
config_filename),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.19",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-17 20:27:17 +01:00
|
|
|
/* Test NEVER running 'tiny' unless they make up minimum unit */
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.102",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6a-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-6a-tiny"),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.102",
|
|
|
|
"EUR:0.1"),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6c",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.102",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6c-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-6c-tiny"),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6d",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.102",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6d-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-6d-tiny"),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-6e",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.112",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6e",
|
|
|
|
config_filename),
|
2020-01-16 19:38:38 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.01",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-16 19:38:38 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* Test profiteering if wire deadline is short */
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-7a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.109",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7a-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-7a-tiny"),
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-7b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.119",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-profit",
|
|
|
|
config_filename),
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.01",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-16 20:38:46 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* Now check profit was actually taken */
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-7c",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.122",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-loss",
|
|
|
|
config_filename),
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.01",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-16 20:38:46 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* Test that aggregation would happen fully if wire deadline is long */
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-8a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
5),
|
|
|
|
"EUR:0.109",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8a-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-8a-tiny"),
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-8b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
5),
|
|
|
|
"EUR:0.109",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8b-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-8b-tiny"),
|
2020-01-16 20:38:46 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* now trigger aggregate with large transaction and short deadline */
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-8c",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.122",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8",
|
|
|
|
config_filename),
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.03",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
2020-01-16 20:38:46 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* Test aggregation with fees and rounding profits. */
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-9a",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
5),
|
|
|
|
"EUR:0.104",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-9a-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-9a-tiny"),
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-9b",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_relative_multiply
|
|
|
|
(GNUNET_TIME_UNIT_SECONDS,
|
|
|
|
5),
|
|
|
|
"EUR:0.105",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-9b-tiny",
|
|
|
|
config_filename),
|
2020-01-16 22:40:12 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_empty (
|
|
|
|
"expect-empty-transactions-after-9b-tiny"),
|
2020-01-16 20:38:46 +01:00
|
|
|
|
2020-01-17 20:27:17 +01:00
|
|
|
/* now trigger aggregate with large transaction and short deadline */
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_insert_deposit ("do-deposit-9c",
|
2020-01-16 22:40:12 +01:00
|
|
|
&dbc,
|
|
|
|
"bob",
|
|
|
|
USER42_ACCOUNT,
|
2021-12-14 16:04:32 +01:00
|
|
|
GNUNET_TIME_timestamp_get (),
|
2020-01-16 22:40:12 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
"EUR:0.112",
|
|
|
|
"EUR:0.1"),
|
2020-03-12 10:53:49 +01:00
|
|
|
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-9",
|
|
|
|
config_filename),
|
2020-01-17 20:27:17 +01:00
|
|
|
/* 0.009 + 0.009 + 0.022 - 0.001 - 0.002 - 0.008 = 0.029 => 0.02 */
|
2020-01-16 20:38:46 +01:00
|
|
|
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-9",
|
2020-01-16 22:40:12 +01:00
|
|
|
ec.exchange_url,
|
|
|
|
"EUR:0.01",
|
|
|
|
bc.exchange_payto,
|
|
|
|
bc.user42_payto),
|
|
|
|
TALER_TESTING_cmd_end ()
|
2020-01-16 14:40:28 +01:00
|
|
|
};
|
2020-01-16 22:40:12 +01:00
|
|
|
|
2020-01-16 14:40:28 +01:00
|
|
|
TALER_TESTING_run_with_fakebank (is,
|
2020-01-16 22:40:12 +01:00
|
|
|
all,
|
2020-01-18 04:00:35 +01:00
|
|
|
bc.exchange_auth.wire_gateway_url);
|
2020-01-16 12:54:05 +01:00
|
|
|
}
|
2016-04-04 14:04:44 +02:00
|
|
|
|
2020-01-16 22:40:12 +01:00
|
|
|
|
2020-02-04 21:59:43 +01:00
|
|
|
/**
|
2020-12-16 19:40:33 +01:00
|
|
|
* Prepare database and launch the test.
|
2020-02-04 21:59:43 +01:00
|
|
|
*
|
|
|
|
* @param cls unused
|
2020-12-16 19:40:33 +01:00
|
|
|
* @param is interpreter to use
|
2020-02-04 21:59:43 +01:00
|
|
|
*/
|
2020-12-16 19:40:33 +01:00
|
|
|
static void
|
2020-02-04 21:59:43 +01:00
|
|
|
prepare_database (void *cls,
|
2020-12-16 19:40:33 +01:00
|
|
|
struct TALER_TESTING_Interpreter *is)
|
2020-02-04 21:59:43 +01:00
|
|
|
{
|
2020-12-16 19:40:33 +01:00
|
|
|
dbc.plugin = TALER_EXCHANGEDB_plugin_load (is->cfg);
|
2020-02-04 21:59:43 +01:00
|
|
|
if (NULL == dbc.plugin)
|
|
|
|
{
|
|
|
|
GNUNET_break (0);
|
|
|
|
result = 77;
|
2020-12-16 19:40:33 +01:00
|
|
|
TALER_TESTING_interpreter_fail (is);
|
|
|
|
return;
|
2020-02-04 21:59:43 +01:00
|
|
|
}
|
2021-08-23 00:00:32 +02:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
dbc.plugin->preflight (dbc.plugin->cls))
|
|
|
|
{
|
|
|
|
GNUNET_break (0);
|
|
|
|
result = 77;
|
|
|
|
TALER_TESTING_interpreter_fail (is);
|
|
|
|
return;
|
|
|
|
}
|
2020-12-16 19:58:42 +01:00
|
|
|
GNUNET_SCHEDULER_add_shutdown (&unload_db,
|
|
|
|
NULL);
|
2020-12-16 19:40:33 +01:00
|
|
|
run (NULL,
|
|
|
|
is);
|
2020-02-04 21:59:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-30 22:56:17 +02:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char *const argv[])
|
|
|
|
{
|
|
|
|
const char *plugin_name;
|
|
|
|
char *testname;
|
|
|
|
|
|
|
|
if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
|
|
|
|
{
|
|
|
|
GNUNET_break (0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
plugin_name++;
|
|
|
|
(void) GNUNET_asprintf (&testname,
|
2017-03-02 06:26:12 +01:00
|
|
|
"test-taler-exchange-aggregator-%s",
|
|
|
|
plugin_name);
|
2016-03-30 22:56:17 +02:00
|
|
|
(void) GNUNET_asprintf (&config_filename,
|
2017-03-02 06:26:12 +01:00
|
|
|
"%s.conf",
|
|
|
|
testname);
|
2020-01-16 12:54:05 +01:00
|
|
|
|
2016-04-04 15:07:01 +02:00
|
|
|
GNUNET_log_setup ("test_taler_exchange_aggregator",
|
2020-01-16 12:54:05 +01:00
|
|
|
"DEBUG",
|
2016-04-04 15:07:01 +02:00
|
|
|
NULL);
|
2020-01-16 12:54:05 +01:00
|
|
|
|
2020-01-16 14:40:28 +01:00
|
|
|
/* these might get in the way */
|
|
|
|
unsetenv ("XDG_DATA_HOME");
|
|
|
|
unsetenv ("XDG_CONFIG_HOME");
|
2020-01-16 12:54:05 +01:00
|
|
|
|
|
|
|
TALER_TESTING_cleanup_files (config_filename);
|
2020-01-16 14:40:28 +01:00
|
|
|
|
2020-12-11 23:44:01 +01:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
TALER_TESTING_prepare_exchange (config_filename,
|
|
|
|
GNUNET_YES,
|
|
|
|
&ec))
|
2017-03-04 16:49:33 +01:00
|
|
|
{
|
2020-01-16 14:40:28 +01:00
|
|
|
TALER_LOG_WARNING ("Could not prepare the exchange.\n");
|
2017-03-04 16:49:33 +01:00
|
|
|
return 77;
|
|
|
|
}
|
2020-01-16 12:54:05 +01:00
|
|
|
|
2020-12-11 23:44:01 +01:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
TALER_TESTING_prepare_fakebank (config_filename,
|
|
|
|
"exchange-account-1",
|
|
|
|
&bc))
|
2017-03-24 13:41:21 +01:00
|
|
|
{
|
2020-01-16 12:54:05 +01:00
|
|
|
TALER_LOG_WARNING ("Could not prepare the fakebank\n");
|
2017-03-24 13:41:21 +01:00
|
|
|
return 77;
|
|
|
|
}
|
2020-12-16 19:40:33 +01:00
|
|
|
result = GNUNET_OK;
|
2020-03-15 00:36:15 +01:00
|
|
|
if (GNUNET_OK !=
|
2020-12-16 19:40:33 +01:00
|
|
|
TALER_TESTING_setup_with_exchange (&prepare_database,
|
|
|
|
NULL,
|
|
|
|
config_filename))
|
2020-01-16 14:40:28 +01:00
|
|
|
{
|
|
|
|
TALER_LOG_WARNING ("Could not prepare database for tests.\n");
|
|
|
|
return result;
|
|
|
|
}
|
2016-03-30 22:56:17 +02:00
|
|
|
GNUNET_free (config_filename);
|
|
|
|
GNUNET_free (testname);
|
2020-01-16 12:54:05 +01:00
|
|
|
return GNUNET_OK == result ? 0 : 1;
|
2016-03-30 22:56:17 +02:00
|
|
|
}
|
|
|
|
|
2019-10-31 12:59:50 +01:00
|
|
|
|
2016-03-30 22:56:17 +02:00
|
|
|
/* end of test_taler_exchange_aggregator.c */
|