#5746, more cases.
This commit is contained in:
parent
f4ee88a175
commit
319bf24664
@ -2,17 +2,21 @@
|
|||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
(C) 2015-2018 Taler Systems SA
|
(C) 2015-2018 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
|
||||||
terms of the GNU General Public License as published by the Free Software
|
it under the terms of the GNU General Public License as
|
||||||
Foundation; either version 3, or (at your option) any later version.
|
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
|
TALER is distributed in the hope that it will be useful, but
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
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
|
You should have received a copy of the GNU General Public
|
||||||
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
License along with TALER; see the file COPYING. If not,
|
||||||
|
see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file wire/test_wire_plugin_legacy_taler-bank.c
|
* @file wire/test_wire_plugin_legacy_taler-bank.c
|
||||||
* @brief Tests legacy history-range API against the Fakebank.
|
* @brief Tests legacy history-range API against the Fakebank.
|
||||||
@ -87,7 +91,14 @@ static struct TALER_WireTransferIdentifierRawP wtid;
|
|||||||
/**
|
/**
|
||||||
* Number of total transaction to make it happen in the test.
|
* Number of total transaction to make it happen in the test.
|
||||||
*/
|
*/
|
||||||
|
static int Ntransactions = NTRANSACTIONS;
|
||||||
static int ntransactions = NTRANSACTIONS;
|
static int ntransactions = NTRANSACTIONS;
|
||||||
|
static int ztransactions = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamp used as the oldest extreme in the query range.
|
||||||
|
*/
|
||||||
|
static struct GNUNET_TIME_Absolute first_timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called on shutdown (regular, error or CTRL-C).
|
* Function called on shutdown (regular, error or CTRL-C).
|
||||||
@ -119,7 +130,6 @@ do_shutdown (void *cls)
|
|||||||
hhr = NULL;
|
hhr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TALER_WIRE_plugin_unload (plugin);
|
TALER_WIRE_plugin_unload (plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,12 +151,13 @@ do_shutdown (void *cls)
|
|||||||
static int
|
static int
|
||||||
history_result_cb
|
history_result_cb
|
||||||
(void *cls,
|
(void *cls,
|
||||||
enum TALER_ErrorCode ec,
|
enum TALER_ErrorCode ec,
|
||||||
enum TALER_BANK_Direction dir,
|
enum TALER_BANK_Direction dir,
|
||||||
const void *row_off,
|
const void *row_off,
|
||||||
size_t row_off_size,
|
size_t row_off_size,
|
||||||
const struct TALER_WIRE_TransferDetails *details)
|
const struct TALER_WIRE_TransferDetails *details)
|
||||||
{
|
{
|
||||||
|
int *expected_number = cls;
|
||||||
static int accumulator = 0;
|
static int accumulator = 0;
|
||||||
|
|
||||||
if ( (TALER_BANK_DIRECTION_NONE == dir) &&
|
if ( (TALER_BANK_DIRECTION_NONE == dir) &&
|
||||||
@ -155,16 +166,42 @@ history_result_cb
|
|||||||
/* End-of-list, check all the transactions got accounted
|
/* End-of-list, check all the transactions got accounted
|
||||||
* into the history. */
|
* into the history. */
|
||||||
|
|
||||||
if (NTRANSACTIONS != accumulator)
|
if (*expected_number != accumulator)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TALER_LOG_ERROR
|
TALER_LOG_ERROR
|
||||||
("Unexpected # of transactions: %d, %d were expected.\n",
|
("Unexpected # of transactions: %d, %d were expected.\n",
|
||||||
accumulator,
|
accumulator,
|
||||||
NTRANSACTIONS);
|
*expected_number);
|
||||||
global_ret = GNUNET_NO;
|
global_ret = GNUNET_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ztransactions != *expected_number)
|
||||||
|
{
|
||||||
|
/* Call the second test, under the assumption that after
|
||||||
|
* running the test with ztransactions expected entries,
|
||||||
|
* we shut the test down. */
|
||||||
|
|
||||||
|
accumulator = 0;
|
||||||
|
GNUNET_assert
|
||||||
|
(NULL != (hhr = plugin->get_history_range
|
||||||
|
(plugin->cls,
|
||||||
|
my_account,
|
||||||
|
TALER_BANK_DIRECTION_BOTH,
|
||||||
|
GNUNET_TIME_UNIT_ZERO_ABS,
|
||||||
|
GNUNET_TIME_absolute_subtract
|
||||||
|
(first_timestamp,
|
||||||
|
GNUNET_TIME_UNIT_HOURS),
|
||||||
|
&history_result_cb,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zero results are expected from 1970 up to 1 hour ago.
|
||||||
|
*/
|
||||||
|
&ztransactions)));
|
||||||
|
|
||||||
|
return GNUNET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
GNUNET_SCHEDULER_shutdown ();
|
GNUNET_SCHEDULER_shutdown ();
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
@ -191,7 +228,6 @@ confirmation_cb (void *cls,
|
|||||||
size_t row_id_size,
|
size_t row_id_size,
|
||||||
const char *emsg);
|
const char *emsg);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback with prepared transaction.
|
* Callback with prepared transaction.
|
||||||
*
|
*
|
||||||
@ -247,7 +283,7 @@ confirmation_cb (void *cls,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 >= --ntransactions)
|
if (0 >= --Ntransactions)
|
||||||
{
|
{
|
||||||
GNUNET_assert
|
GNUNET_assert
|
||||||
(NULL != (hhr = plugin->get_history_range
|
(NULL != (hhr = plugin->get_history_range
|
||||||
@ -257,14 +293,15 @@ confirmation_cb (void *cls,
|
|||||||
GNUNET_TIME_UNIT_ZERO_ABS,
|
GNUNET_TIME_UNIT_ZERO_ABS,
|
||||||
GNUNET_TIME_UNIT_FOREVER_ABS,
|
GNUNET_TIME_UNIT_FOREVER_ABS,
|
||||||
&history_result_cb,
|
&history_result_cb,
|
||||||
NULL)));
|
&ntransactions)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Issue a new wire transfer! */
|
/* Issue a new wire transfer! */
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert
|
||||||
TALER_string_to_amount ("KUDOS:5.01",
|
(GNUNET_OK == TALER_string_to_amount ("KUDOS:5.01",
|
||||||
&amount));
|
&amount));
|
||||||
|
|
||||||
ph = plugin->prepare_wire_transfer (plugin->cls,
|
ph = plugin->prepare_wire_transfer (plugin->cls,
|
||||||
my_account,
|
my_account,
|
||||||
dest_account,
|
dest_account,
|
||||||
@ -291,11 +328,13 @@ run (void *cls)
|
|||||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
&wtid,
|
&wtid,
|
||||||
sizeof (wtid));
|
sizeof (wtid));
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert
|
||||||
TALER_string_to_amount ("KUDOS:5.01",
|
(GNUNET_OK == TALER_string_to_amount ("KUDOS:5.01",
|
||||||
&amount));
|
&amount));
|
||||||
fb = TALER_FAKEBANK_start (8088);
|
fb = TALER_FAKEBANK_start (8088);
|
||||||
|
|
||||||
|
|
||||||
|
first_timestamp = GNUNET_TIME_absolute_get ();
|
||||||
ph = plugin->prepare_wire_transfer (plugin->cls,
|
ph = plugin->prepare_wire_transfer (plugin->cls,
|
||||||
my_account,
|
my_account,
|
||||||
dest_account,
|
dest_account,
|
||||||
@ -311,14 +350,14 @@ int
|
|||||||
main (int argc,
|
main (int argc,
|
||||||
const char *const argv[])
|
const char *const argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
GNUNET_log_setup ("test-wire-plugin-legacy-test",
|
GNUNET_log_setup ("test-wire-plugin-legacy-test",
|
||||||
"WARNING",
|
"WARNING",
|
||||||
NULL);
|
NULL);
|
||||||
cfg = GNUNET_CONFIGURATION_create ();
|
cfg = GNUNET_CONFIGURATION_create ();
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert
|
||||||
GNUNET_CONFIGURATION_load (cfg,
|
(GNUNET_OK == GNUNET_CONFIGURATION_load
|
||||||
"test_wire_plugin_legacy_taler-bank.conf"));
|
(cfg,
|
||||||
|
"test_wire_plugin_legacy_taler-bank.conf"));
|
||||||
global_ret = GNUNET_OK;
|
global_ret = GNUNET_OK;
|
||||||
plugin = TALER_WIRE_plugin_load (cfg,
|
plugin = TALER_WIRE_plugin_load (cfg,
|
||||||
"taler_bank");
|
"taler_bank");
|
||||||
|
Loading…
Reference in New Issue
Block a user