Compare commits

...

5 Commits

Author SHA1 Message Date
ddedf03a81
[age-withdraw] age-withdraw commit- and reveal-handlers implemented, 12/n
The handlers for the commit- and reveal-phases of the age-withdraw
HTTP-endpoints are implemented, yet not active.

Still missing:

- support for age-withdraw is missing in lib/.
- tests
2023-06-26 00:01:31 +02:00
70bfe0ed1b
Merge branch 'master' into age-withdraw 2023-06-10 11:07:06 +02:00
Christian Grothoff
d8f8c550bd
-fix FTBFS 2023-06-09 17:52:16 +02:00
Christian Grothoff
a2dde02b64
major libtalertesting API refactoring, including no longer having taler-specific logic in the test engine core 2023-06-07 23:11:05 +02:00
Christian Grothoff
015b08b048
new command to use taler-benchmark-setup.sh 2023-06-05 17:01:23 +02:00
156 changed files with 7599 additions and 7423 deletions

@ -1 +1 @@
Subproject commit f9ea79a6aae074928f44960f69bc3c2d0c9c7e1d
Subproject commit 31b74264e62c4a7f4a671033e214c43fa2f304c0

View File

@ -17,7 +17,7 @@ AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
# What is the Web site of the auditor (i.e. to file complaints about
# a misbehaving exchange)?
# BASE_URL = https://auditor.taler.net/
BASE_URL = http://localhost:8083/
# Network configuration for the normal API/service HTTP server

View File

@ -132,7 +132,7 @@ handle_mhd_completion_callback (void *cls,
/**
* Handle a "/version" request.
* Handle a "/config" request.
*
* @param rh context of the handler
* @param connection the MHD connection to handle
@ -142,7 +142,7 @@ handle_mhd_completion_callback (void *cls,
* @return MHD result code
*/
static MHD_RESULT
handle_version (struct TAH_RequestHandler *rh,
handle_config (struct TAH_RequestHandler *rh,
struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
@ -207,9 +207,9 @@ handle_mhd_request (void *cls,
{ "/exchanges", MHD_HTTP_METHOD_GET, "application/json",
NULL, 0,
&TAH_EXCHANGES_handler, MHD_HTTP_OK },
{ "/version", MHD_HTTP_METHOD_GET, "application/json",
{ "/config", MHD_HTTP_METHOD_GET, "application/json",
NULL, 0,
&handle_version, MHD_HTTP_OK },
&handle_config, MHD_HTTP_OK },
/* Landing page, for now tells humans to go away
* (NOTE: ideally, the reverse proxy will respond with a nicer page) */
{ "/", MHD_HTTP_METHOD_GET, "text/plain",

View File

@ -1,4 +1,5 @@
#!/bin/bash
# This file is in the public domain.
set -eu

View File

@ -12,11 +12,9 @@ endif
bin_PROGRAMS = \
taler-aggregator-benchmark \
taler-bank-benchmark \
taler-exchange-benchmark
taler-bank-benchmark
bin_SCRIPTS = \
taler-benchmark-setup.sh
# taler-exchange-benchmark
taler_aggregator_benchmark_SOURCES = \
@ -75,5 +73,4 @@ EXTRA_DIST = \
bank-benchmark-rsa.conf \
coins-cs.conf \
coins-rsa.conf \
$(bin_SCRIPTS) \
exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv

View File

@ -58,11 +58,11 @@ MAX_DEBT_BANK=EUR:1000000000000000.0
DATABASE=bank-db.sqlite3
[libeufin-nexus]
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
[libeufin-sandbox]
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
[auditor]

View File

@ -322,11 +322,8 @@ launch_clients (void)
if (1 == howmany_clients)
{
/* do everything in this process */
result = TALER_TESTING_setup (&run,
NULL,
cfg,
NULL,
GNUNET_NO);
result = TALER_TESTING_loop (&run,
NULL);
if (verbose)
print_stats ();
return result;
@ -340,11 +337,8 @@ launch_clients (void)
GNUNET_log_setup ("benchmark-worker",
NULL == loglev ? "INFO" : loglev,
logfile);
result = TALER_TESTING_setup (&run,
NULL,
cfg,
NULL,
GNUNET_NO);
result = TALER_TESTING_loop (&run,
NULL);
if (verbose)
print_stats ();
if (GNUNET_OK != result)

View File

@ -85,11 +85,6 @@ enum BenchmarkMode
*/
static const struct TALER_EXCHANGEDB_AccountInfo *exchange_bank_account;
/**
* Configuration of our exchange.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Hold information about a user at the bank.
*/
@ -146,11 +141,6 @@ static unsigned int refresh_rate = 10;
*/
static unsigned int howmany_clients = 1;
/**
* Bank configuration to use.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Log level used during the run.
*/
@ -474,45 +464,6 @@ print_stats (void)
}
/**
* Stop the fakebank.
*
* @param cls fakebank handle
*/
static void
stop_fakebank (void *cls)
{
struct TALER_FAKEBANK_Handle *fakebank = cls;
TALER_FAKEBANK_stop (fakebank);
}
/**
* Start the fakebank.
*
* @param cls NULL
*/
static void
launch_fakebank (void *cls)
{
struct TALER_FAKEBANK_Handle *fakebank;
(void) cls;
fakebank
= TALER_TESTING_run_fakebank (
exchange_bank_account->auth->wire_gateway_url,
currency);
if (NULL == fakebank)
{
GNUNET_break (0);
return;
}
GNUNET_SCHEDULER_add_shutdown (&stop_fakebank,
fakebank);
}
/**
* Run the benchmark in parallel in many (client) processes
* and summarize result.
@ -531,148 +482,6 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
pid_t cpids[howmany_clients];
pid_t fakebank = -1;
int wstatus;
struct GNUNET_OS_Process *bankd = NULL;
struct GNUNET_OS_Process *auditord = NULL;
struct GNUNET_OS_Process *exchanged = NULL;
struct GNUNET_OS_Process *wirewatch = NULL;
struct GNUNET_OS_Process *exchange_slave = NULL;
struct GNUNET_DISK_PipeHandle *exchange_slave_pipe;
if ( (MODE_CLIENT == mode) ||
(MODE_BOTH == mode) )
{
if (use_fakebank)
{
/* start fakebank */
fakebank = fork ();
if (0 == fakebank)
{
GNUNET_log_setup ("benchmark-fakebank",
NULL == loglev ? "INFO" : loglev,
logfile);
GNUNET_SCHEDULER_run (&launch_fakebank,
NULL);
exit (0);
}
if (-1 == fakebank)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
"fork");
return GNUNET_SYSERR;
}
}
else
{
/* start bank */
if (GNUNET_OK !=
TALER_TESTING_prepare_bank (cfg_filename,
GNUNET_NO,
"exchange-account-test",
&bc))
{
return 1;
}
bankd = TALER_TESTING_run_bank (cfg_filename,
"http://localhost:8082/");
if (NULL == bankd)
return 77;
}
}
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
{
/* start exchange */
exchanged = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-exchange-httpd",
"taler-exchange-httpd",
"-c", config_file,
"-C",
NULL);
if ( (NULL == exchanged) &&
(MODE_BOTH == mode) )
{
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
return 77;
}
/* start auditor */
auditord = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-auditor-httpd",
"taler-auditor-httpd",
"-c", config_file,
NULL);
if (NULL == auditord)
{
GNUNET_OS_process_kill (exchanged,
SIGTERM);
if (MODE_BOTH == mode)
{
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
GNUNET_OS_process_destroy (exchanged);
return 77;
}
/* start exchange wirewatch */
wirewatch = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-exchange-wirewatch",
"taler-exchange-wirewatch",
"-c", config_file,
NULL);
if (NULL == wirewatch)
{
GNUNET_OS_process_kill (auditord,
SIGTERM);
GNUNET_OS_process_kill (exchanged,
SIGTERM);
if (MODE_BOTH == mode)
{
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
GNUNET_OS_process_destroy (exchanged);
return 77;
}
}
if (MODE_CLIENT == mode)
{
@ -710,58 +519,16 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to detect running exchange at `%s'\n",
ec.exchange_url);
GNUNET_OS_process_kill (exchanged,
SIGTERM);
if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
{
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
GNUNET_OS_process_wait (exchanged);
GNUNET_OS_process_destroy (exchanged);
if (NULL != wirewatch)
{
GNUNET_OS_process_kill (wirewatch,
SIGTERM);
GNUNET_OS_process_wait (wirewatch);
GNUNET_OS_process_destroy (wirewatch);
}
if (NULL != auditord)
{
GNUNET_OS_process_kill (auditord,
SIGTERM);
GNUNET_OS_process_wait (auditord);
GNUNET_OS_process_destroy (auditord);
}
return 77;
}
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
{
if (-1 != fakebank)
sleep (1); /* make sure fakebank process is ready before continuing */
start_time = GNUNET_TIME_absolute_get ();
result = GNUNET_OK;
if (1 == howmany_clients)
{
result = TALER_TESTING_setup (main_cb,
main_cb_cls,
cfg,
exchanged,
GNUNET_YES);
result = TALER_TESTING_run (main_cb,
main_cb_cls);
print_stats ();
}
else
@ -775,11 +542,8 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
NULL == loglev ? "INFO" : loglev,
logfile);
result = TALER_TESTING_setup (main_cb,
main_cb_cls,
cfg,
exchanged,
GNUNET_YES);
result = TALER_TESTING_run (main_cb,
main_cb_cls);
print_stats ();
if (GNUNET_OK != result)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@ -845,58 +609,6 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
GNUNET_OS_process_destroy (exchange_slave);
}
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
{
GNUNET_assert (NULL != wirewatch);
GNUNET_assert (NULL != exchanged);
GNUNET_assert (NULL != auditord);
/* stop wirewatch */
GNUNET_break (0 ==
GNUNET_OS_process_kill (wirewatch,
SIGTERM));
GNUNET_break (GNUNET_OK ==
GNUNET_OS_process_wait (wirewatch));
GNUNET_OS_process_destroy (wirewatch);
/* stop auditor */
GNUNET_break (0 ==
GNUNET_OS_process_kill (auditord,
SIGTERM));
GNUNET_break (GNUNET_OK ==
GNUNET_OS_process_wait (auditord));
GNUNET_OS_process_destroy (auditord);
/* stop exchange */
GNUNET_break (0 ==
GNUNET_OS_process_kill (exchanged,
SIGTERM));
GNUNET_break (GNUNET_OK ==
GNUNET_OS_process_wait (exchanged));
GNUNET_OS_process_destroy (exchanged);
}
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
{
/* stop fakebank */
if (-1 != fakebank)
{
kill (fakebank,
SIGTERM);
waitpid (fakebank,
&wstatus,
0);
if ( (! WIFEXITED (wstatus)) ||
(0 != WEXITSTATUS (wstatus)) )
{
GNUNET_break (0);
result = GNUNET_SYSERR;
}
}
if (NULL != bankd)
{
GNUNET_OS_process_kill (bankd,
SIGTERM);
GNUNET_OS_process_destroy (bankd);
}
}
return result;
}
@ -1066,39 +778,8 @@ main (int argc,
GNUNET_free (cfg_filename);
return BAD_CONFIG_FILE;
}
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
{
/* If we use the fakebank, we MUST reset the database as the fakebank
will have forgotten everything... */
if (GNUNET_OK !=
TALER_TESTING_prepare_exchange (cfg_filename,
(GNUNET_YES == use_fakebank)
? GNUNET_YES
: GNUNET_NO,
&ec))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to prepare the exchange for launch\n");
GNUNET_free (cfg_filename);
return BAD_CONFIG_FILE;
}
}
else
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"exchange",
"BASE_URL",
&ec.exchange_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"base_url");
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free (cfg_filename);
return BAD_CONFIG_FILE;
}
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"benchmark-remote-exchange",

View File

@ -3,10 +3,10 @@
[exchange-offline]
# Where do we store the offline master private key of the exchange?
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange-offline/master.priv
MASTER_PRIV_FILE = ${TALER_DATA_HOME}exchange-offline/master.priv
# Where do we store the TOFU key material?
SECM_TOFU_FILE = ${TALER_DATA_HOME}/exchange-offline/secm_tofus.pub
SECM_TOFU_FILE = ${TALER_DATA_HOME}exchange-offline/secm_tofus.pub
# Base32-encoded public key of the RSA helper.
# SECM_DENOM_PUBKEY =

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -26,12 +26,14 @@
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
#include <jansson.h>
#include "taler-exchange-httpd.h"
#include "taler_json_lib.h"
#include "taler_kyclogic_lib.h"
#include "taler_mhd_lib.h"
#include "taler-exchange-httpd_batch-withdraw.h"
#include "taler-exchange-httpd_responses.h"
#include "taler-exchange-httpd_keys.h"
#include "taler_util.h"
/**
@ -306,8 +308,10 @@ batch_withdraw_transaction (void *cls,
struct BatchWithdrawContext *wc = cls;
uint64_t ruuid;
enum GNUNET_DB_QueryStatus qs;
bool balance_ok = false;
bool found = false;
bool balance_ok = false;
bool age_ok = false;
uint16_t required_age = 0;
char *kyc_required;
struct TALER_PaytoHashP reserve_h_payto;
@ -471,9 +475,11 @@ batch_withdraw_transaction (void *cls,
wc->now,
wc->reserve_pub,
&wc->batch_total,
/* TODO[oec]: add parameter for maximum age and [out]parameter for required age */
TEH_age_restriction_enabled,
&found,
&balance_ok,
&age_ok,
&required_age,
&ruuid);
if (0 > qs)
{
@ -496,7 +502,20 @@ batch_withdraw_transaction (void *cls,
return GNUNET_DB_STATUS_HARD_ERROR;
}
/* TODO[oec]: add error handling for age restriction requirements */
if (! age_ok)
{
/* We respond with the lowest age in the corresponding age group
* of the required age */
uint16_t lowest_age = TALER_get_lowest_age (
&TEH_age_restriction_config.mask,
required_age);
TEH_plugin->rollback (TEH_plugin->cls);
*mhd_ret = TEH_RESPONSE_reply_reserve_age_restriction_required (
connection,
lowest_age);
return GNUNET_DB_STATUS_HARD_ERROR;
}
if (! balance_ok)
{
@ -722,10 +741,12 @@ parse_planchets (const struct TEH_RequestContext *rc,
struct PlanchetContext *pc = &wc->planchets[i];
struct TEH_DenominationKey *dk;
dk = TEH_keys_denomination_by_hash2 (ksh,
dk = TEH_keys_denomination_by_hash_from_state (
ksh,
&pc->collectable.denom_pub_hash,
NULL,
NULL);
if (NULL == dk)
{
if (! check_request_idempotent (wc,

View File

@ -127,7 +127,7 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING,
NULL);
}
dk = TEH_keys_denomination_by_hash2 (ksh,
dk = TEH_keys_denomination_by_hash_from_state (ksh,
denom_pub_hash,
NULL,
NULL);
@ -262,7 +262,7 @@ TEH_handler_csr_withdraw (struct TEH_RequestContext *rc,
TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING,
NULL);
}
dk = TEH_keys_denomination_by_hash2 (ksh,
dk = TEH_keys_denomination_by_hash_from_state (ksh,
&denom_pub_hash,
NULL,
NULL);

View File

@ -148,7 +148,7 @@ extension_update_event_cb (void *cls,
TEH_age_restriction_enabled = false;
if (NULL != conf)
{
TEH_age_restriction_enabled = true;
TEH_age_restriction_enabled = extension->enabled;
TEH_age_restriction_config = *conf;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"[age restriction] DB event has changed the config to %s with mask: %s\n",

View File

@ -1364,7 +1364,6 @@ denomination_info_cb (
&dk->h_denom_pub.hash,
dk,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
@ -1753,7 +1752,7 @@ wallet_threshold_cb (void *cls,
*
* @param[in,out] ksh key state handle we build @a krd for
* @param[in] denom_keys_hash hash over all the denomination keys in @a denoms
* @param last_cpd timestamp to use
* @param last_cherry_pick_date timestamp to use
* @param signkeys list of sign keys to return
* @param recoup list of revoked keys to return
* @param denoms list of denominations to return
@ -1764,7 +1763,7 @@ wallet_threshold_cb (void *cls,
static enum GNUNET_GenericReturnValue
create_krd (struct TEH_KeyStateHandle *ksh,
const struct GNUNET_HashCode *denom_keys_hash,
struct GNUNET_TIME_Timestamp last_cpd,
struct GNUNET_TIME_Timestamp last_cherry_pick_date,
json_t *signkeys,
json_t *recoup,
json_t *denoms,
@ -1778,7 +1777,8 @@ create_krd (struct TEH_KeyStateHandle *ksh,
struct TALER_ExchangeSignatureP grouped_exchange_sig;
json_t *keys;
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (last_cpd.abs_time));
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
last_cherry_pick_date.abs_time));
GNUNET_assert (NULL != signkeys);
GNUNET_assert (NULL != recoup);
GNUNET_assert (NULL != denoms);
@ -1788,7 +1788,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
GNUNET_assert (NULL != TEH_currency);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Creating /keys at cherry pick date %s\n",
GNUNET_TIME_timestamp2s (last_cpd));
GNUNET_TIME_timestamp2s (last_cherry_pick_date));
/* Sign hash over denomination keys */
{
@ -1799,7 +1799,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
TALER_exchange_online_key_set_sign (
&TEH_keys_exchange_sign2_,
ksh,
last_cpd,
last_cherry_pick_date,
denom_keys_hash,
&exchange_pub,
&exchange_sig)))
@ -1820,7 +1820,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
TALER_exchange_online_key_set_sign (
&TEH_keys_exchange_sign2_,
ksh,
last_cpd,
last_cherry_pick_date,
h_grouped,
&grouped_exchange_pub,
&grouped_exchange_sig)))
@ -1876,7 +1876,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
GNUNET_JSON_pack_array_incref ("global_fees",
ksh->global_fees),
GNUNET_JSON_pack_timestamp ("list_issue_date",
last_cpd),
last_cherry_pick_date),
GNUNET_JSON_pack_data_auto ("eddsa_pub",
&exchange_pub),
GNUNET_JSON_pack_data_auto ("eddsa_sig",
@ -2034,7 +2034,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
etag));
krd.etag = GNUNET_strdup (etag);
}
krd.cherry_pick_date = last_cpd;
krd.cherry_pick_date = last_cherry_pick_date;
GNUNET_array_append (ksh->krd_array,
ksh->krd_array_length,
krd);
@ -2054,14 +2054,17 @@ create_krd (struct TEH_KeyStateHandle *ksh,
static enum GNUNET_GenericReturnValue
finish_keys_response (struct TEH_KeyStateHandle *ksh)
{
enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR;
json_t *recoup;
struct SignKeyCtx sctx;
json_t *denoms = NULL;
json_t *grouped_denominations = NULL;
struct GNUNET_TIME_Timestamp last_cpd;
struct GNUNET_TIME_Timestamp last_cherry_pick_date;
struct GNUNET_CONTAINER_Heap *heap;
struct GNUNET_HashContext *hash_context = NULL;
struct GNUNET_HashCode grouped_hash_xor = {0};
/* Remember if we have any denomination with age restriction */
bool has_age_restricted_denomination = false;
sctx.signkeys = json_array ();
GNUNET_assert (NULL != sctx.signkeys);
@ -2094,7 +2097,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
grouped_denominations = json_array ();
GNUNET_assert (NULL != grouped_denominations);
last_cpd = GNUNET_TIME_UNIT_ZERO_TS;
last_cherry_pick_date = GNUNET_TIME_UNIT_ZERO_TS;
// FIXME: This block contains the implementation of the DEPRECATED
// "denom_pubs" array along with the new grouped "denominations".
@ -2124,13 +2127,13 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
/* heap = min heap, sorted by start time */
while (NULL != (dk = GNUNET_CONTAINER_heap_remove_root (heap)))
{
if (GNUNET_TIME_timestamp_cmp (last_cpd,
if (GNUNET_TIME_timestamp_cmp (last_cherry_pick_date,
!=,
dk->meta.start) &&
(! GNUNET_TIME_absolute_is_zero (last_cpd.abs_time)) )
(! GNUNET_TIME_absolute_is_zero (last_cherry_pick_date.abs_time)) )
{
/*
* This is not the first entry in the heap (because last_cpd !=
* This is not the first entry in the heap (because last_cherry_pick_date !=
* GNUNET_TIME_UNIT_ZERO_TS) and the previous entry had a different
* start time. Therefore, we create a new entry in ksh.
*/
@ -2143,7 +2146,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
if (GNUNET_OK !=
create_krd (ksh,
&hc,
last_cpd,
last_cherry_pick_date,
sctx.signkeys,
recoup,
denoms,
@ -2152,21 +2155,17 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to generate key response data for %s\n",
GNUNET_TIME_timestamp2s (last_cpd));
GNUNET_TIME_timestamp2s (last_cherry_pick_date));
GNUNET_CRYPTO_hash_context_abort (hash_context);
/* drain heap before destroying it */
while (NULL != (dk = GNUNET_CONTAINER_heap_remove_root (heap)))
/* intentionally empty */;
GNUNET_CONTAINER_heap_destroy (heap);
json_decref (denoms);
json_decref (grouped_denominations);
json_decref (sctx.signkeys);
json_decref (recoup);
return GNUNET_SYSERR;
goto CLEANUP;
}
}
last_cpd = dk->meta.start;
last_cherry_pick_date = dk->meta.start;
{
json_t *denom;
@ -2264,7 +2263,11 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
int r = json_object_set_new (group->json,
"age_mask",
json_integer (meta.age_mask.bits));
GNUNET_assert (0 == r);
/* Remember that we have found at least _one_ age restricted denomination */
has_age_restricted_denomination = true;
}
/* Create a new array for the denominations in this group */
@ -2386,7 +2389,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
}
GNUNET_CONTAINER_heap_destroy (heap);
if (! GNUNET_TIME_absolute_is_zero (last_cpd.abs_time))
if (! GNUNET_TIME_absolute_is_zero (last_cherry_pick_date.abs_time))
{
struct GNUNET_HashCode hc;
@ -2395,7 +2398,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
if (GNUNET_OK !=
create_krd (ksh,
&hc,
last_cpd,
last_cherry_pick_date,
sctx.signkeys,
recoup,
denoms,
@ -2404,14 +2407,25 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to generate key response data for %s\n",
GNUNET_TIME_timestamp2s (last_cpd));
json_decref (denoms);
json_decref (grouped_denominations);
json_decref (sctx.signkeys);
json_decref (recoup);
return GNUNET_SYSERR;
GNUNET_TIME_timestamp2s (last_cherry_pick_date));
goto CLEANUP;
}
ksh->management_only = false;
/* Sanity check: Make sure that age restriction is enabled IFF at least
* one age restricted denomination exist */
if (! has_age_restricted_denomination && TEH_age_restriction_enabled)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Age restriction is enabled, but NO denominations with age restriction found!\n");
goto CLEANUP;
}
else if (has_age_restricted_denomination && ! TEH_age_restriction_enabled)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Age restriction is NOT enabled, but denominations with age restriction found!\n");
goto CLEANUP;
}
}
else
{
@ -2419,11 +2433,15 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
"No denomination keys available. Refusing to generate /keys response.\n");
GNUNET_CRYPTO_hash_context_abort (hash_context);
}
ret = GNUNET_OK;
CLEANUP:
json_decref (grouped_denominations);
json_decref (sctx.signkeys);
json_decref (recoup);
json_decref (denoms);
return GNUNET_OK;
return ret;
}
@ -2733,7 +2751,7 @@ TEH_keys_denomination_by_hash (
return NULL;
}
return TEH_keys_denomination_by_hash2 (ksh,
return TEH_keys_denomination_by_hash_from_state (ksh,
h_denom_pub,
conn,
mret);
@ -2741,8 +2759,8 @@ TEH_keys_denomination_by_hash (
struct TEH_DenominationKey *
TEH_keys_denomination_by_hash2 (
struct TEH_KeyStateHandle *ksh,
TEH_keys_denomination_by_hash_from_state (
const struct TEH_KeyStateHandle *ksh,
const struct TALER_DenominationHashP *h_denom_pub,
struct MHD_Connection *conn,
MHD_RESULT *mret)

View File

@ -234,8 +234,8 @@ TEH_keys_denomination_by_hash (
* or NULL if @a h_denom_pub could not be found
*/
struct TEH_DenominationKey *
TEH_keys_denomination_by_hash2 (
struct TEH_KeyStateHandle *ksh,
TEH_keys_denomination_by_hash_from_state (
const struct TEH_KeyStateHandle *ksh,
const struct TALER_DenominationHashP *h_denom_pub,
struct MHD_Connection *conn,
MHD_RESULT *mret);

View File

@ -511,7 +511,7 @@ resolve_refreshes_reveal_denominations (
}
}
old_dk = TEH_keys_denomination_by_hash2 (
old_dk = TEH_keys_denomination_by_hash_from_state (
ksh,
&rctx->melt.session.coin.denom_pub_hash,
connection,
@ -536,7 +536,7 @@ resolve_refreshes_reveal_denominations (
-1);
if (GNUNET_OK != res)
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
dks[i] = TEH_keys_denomination_by_hash2 (ksh,
dks[i] = TEH_keys_denomination_by_hash_from_state (ksh,
&rrcs[i].h_denom_pub,
connection,
&ret);

View File

@ -1084,6 +1084,20 @@ TEH_RESPONSE_reply_reserve_insufficient_balance (
}
MHD_RESULT
TEH_RESPONSE_reply_reserve_age_restriction_required (
struct MHD_Connection *connection,
uint16_t maximum_allowed_age)
{
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_BAD_REQUEST,
TALER_JSON_pack_ec (TALER_EC_EXCHANGE_RESERVES_AGE_RESTRICTION_REQUIRED),
GNUNET_JSON_pack_uint64 ("maximum_allowed_age",
maximum_allowed_age));
}
MHD_RESULT
TEH_RESPONSE_reply_purse_created (
struct MHD_Connection *connection,

View File

@ -75,6 +75,20 @@ TEH_RESPONSE_reply_reserve_insufficient_balance (
const struct TALER_Amount *balance_required,
const struct TALER_ReservePublicKeyP *reserve_pub);
/**
* Return error message indicating that a reserve requires age
* restriction to be set during withdraw, that is: the age-withdraw
* protocol MUST be used with commitment to an admissible age.
*
* @param connection connection to the client
* @param maximum_allowed_age the balance required for the operation
* @return MHD result code
*/
MHD_RESULT
TEH_RESPONSE_reply_reserve_age_restriction_required (
struct MHD_Connection *connection,
uint16_t maximum_allowed_age);
/**
* Send information that a KYC check must be

View File

@ -488,10 +488,13 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
GNUNET_JSON_parse_free (spec);
return mret;
}
dk = TEH_keys_denomination_by_hash2 (ksh,
dk = TEH_keys_denomination_by_hash_from_state (
ksh,
&wc.collectable.denom_pub_hash,
NULL,
NULL);
if (NULL == dk)
{
if (! check_request_idempotent (rc,

View File

@ -31,7 +31,7 @@ BEGIN
',current_balance_frac INT4 NOT NULL DEFAULT(0)'
',purses_active INT8 NOT NULL DEFAULT(0)'
',purses_allowed INT8 NOT NULL DEFAULT(0)'
',max_age INT4 NOT NULL DEFAULT(0)'
',birthdate INT4 NOT NULL DEFAULT(0)'
',expiration_date INT8 NOT NULL'
',gc_date INT8 NOT NULL'
') %s ;'
@ -82,7 +82,7 @@ BEGIN
);
PERFORM comment_partitioned_column(
'Birthday of the user in days after 1970, or 0 if user is an adult and is not subject to age restrictions'
,'max_age'
,'birthdate'
,table_name
,partition_suffix
);

View File

@ -1,6 +1,6 @@
--
-- This file is part of TALER
-- Copyright (C) 2022 Taler Systems SA
-- Copyright (C) 2023 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
@ -13,26 +13,28 @@
-- 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/>
--
-- @author Özgür Kesim
CREATE FUNCTION create_table_age_withdraw_commitments(
CREATE FUNCTION create_table_age_withdraw(
IN partition_suffix VARCHAR DEFAULT NULL
)
RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
table_name VARCHAR DEFAULT 'age_withdraw_commitments';
table_name VARCHAR DEFAULT 'age_withdraw';
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
'(age_withdraw_commitment_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
'(age_withdraw_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
',h_commitment BYTEA NOT NULL CONSTRAINT h_commitment_length CHECK(LENGTH(h_commitment)=64)'
',max_age SMALLINT NOT NULL CONSTRAINT max_age_positive CHECK(max_age>=0)'
',reserve_pub BYTEA NOT NULL CONSTRAINT reserve_pub_length CHECK(LENGTH(reserve_pub)=32)'
',reserve_sig BYTEA NOT NULL CONSTRAINT reserve_sig_length CHECK(LENGTH(reserve_sig)=64)'
',noreveal_index SMALLINT NOT NULL CONSTRAINT noreveal_index_positive CHECK(noreveal_index>=0)'
',denominations_serials INT8[] NOT NULL CONSTRAINT denominations_serial_array_length CHECK(cardinality(denominations_serials)=cardinality(denom_sigs))'
',denom_sigs BYTEA[] NOT NULL CONSTRAINT denom_sigs_array_length CHECK(cardinality(denom_sigs)=cardinality(denominations_serials))'
',h_blind_evs BYTEA[] NOT NULL CONSTRAINT h_blind_evs_length CHECK(cardinality(h_blind_evs)=cardinality(denomination_serials))'
',denom_serials INT8[] NOT NULL CONSTRAINT denominations_serial_array_length CHECK(cardinality(denom_serials)=cardinality(denom_sigs))'
',denom_sigs BYTEA[] NOT NULL CONSTRAINT denom_sigs_array_length CHECK(cardinality(denom_sigs)=cardinality(denom_serials))'
') %s ;'
,table_name
,'PARTITION BY HASH (reserve_pub)'
@ -40,7 +42,7 @@ BEGIN
);
PERFORM comment_partitioned_table(
'Commitments made when withdrawing coins with age restriction and the gamma value chosen by the exchange. '
'It also contains the blindly signed coins and related denominations.'
'It also contains the blindly signed coins, their signatures and denominations.'
,table_name
,partition_suffix
);
@ -76,12 +78,18 @@ BEGIN
);
PERFORM comment_partitioned_column(
'Array of references to the denominations'
,'denominations_serials'
,'denom_serials'
,table_name
,partition_suffix
);
PERFORM comment_partitioned_column(
'Array of signatures over the blinded envelopes'
'Array of the blinded envelopes of the chosen fresh coins, with value as given by the denomination in the corresponding slot in denom_serials'
,'h_blind_evs'
,table_name
,partition_suffix
);
PERFORM comment_partitioned_column(
'Array of signatures over each blinded envelope'
,'denom_sigs'
,table_name
,partition_suffix
@ -90,14 +98,14 @@ END
$$;
CREATE FUNCTION constrain_table_age_withdraw_commitments(
CREATE FUNCTION constrain_table_age_withdraw(
IN partition_suffix VARCHAR
)
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
table_name VARCHAR DEFAULT 'age_withdraw_commitments';
table_name VARCHAR DEFAULT 'age_withdraw';
BEGIN
table_name = concat_ws('_', table_name, partition_suffix);
EXECUTE FORMAT (
@ -111,25 +119,25 @@ BEGIN
);
EXECUTE FORMAT (
'ALTER TABLE ' || table_name ||
' ADD CONSTRAINT ' || table_name || '_age_withdraw_commitment_id_key'
' UNIQUE (age_withdraw_commitment_id);'
' ADD CONSTRAINT ' || table_name || '_age_withdraw_id_key'
' UNIQUE (age_withdraw_id);'
);
END
$$;
CREATE FUNCTION foreign_table_age_withdraw_commitments()
CREATE FUNCTION foreign_table_age_withdraw()
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
table_name VARCHAR DEFAULT 'age_withdraw_commitments';
table_name VARCHAR DEFAULT 'age_withdraw';
BEGIN
EXECUTE FORMAT (
'ALTER TABLE ' || table_name ||
' ADD CONSTRAINT ' || table_name || '_foreign_reserve_pub'
' FOREIGN KEY (reserve_pub)'
' REFERENCES reserves(reserve_pub) ON DELETE CASCADE;'
' REFERENCES reserves(reserve_pub);' -- ON DELETE CASCADE;'
);
END
$$;
@ -142,6 +150,6 @@ INSERT INTO exchange_tables
,partitioned
,by_range)
VALUES
('age_withdraw_commitments', 'exchange-0003', 'create', TRUE ,FALSE),
('age_withdraw_commitments', 'exchange-0003', 'constrain',TRUE ,FALSE),
('age_withdraw_commitments', 'exchange-0003', 'foreign', TRUE ,FALSE);
('age_withdraw', 'exchange-0003', 'create', TRUE ,FALSE),
('age_withdraw', 'exchange-0003', 'constrain',TRUE ,FALSE),
('age_withdraw', 'exchange-0003', 'foreign', TRUE ,FALSE);

View File

@ -1,125 +0,0 @@
--
-- This file is part of TALER
-- Copyright (C) 2022 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/>
--
CREATE FUNCTION create_table_age_withdraw_revealed_coins(
IN partition_suffix VARCHAR DEFAULT NULL
)
RETURNS VOID
LANGUAGE plpgsql
AS $$
DECLARE
table_name VARCHAR DEFAULT 'age_withdraw_revealed_coins';
BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
'(age_withdraw_revealed_coins_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE
',h_commitment BYTEA NOT NULL CHECK (LENGTH(h_commitment)=64)'
',coin_index INT4 NOT NULL'
',h_coin_ev BYTEA CHECK (LENGTH(h_coin_ev)=64)'
') %s ;'
,table_name
,'PARTITION BY HASH (h_coin_ev)'
,partition_suffix
);
PERFORM comment_partitioned_table(
'Reveal of proofs of the correct age restriction after the commitment when withdrawing coins with age restriction'
,table_name
,partition_suffix
);
PERFORM comment_partitioned_column(
'Foreign key reference to the corresponding commitment'
,'h_commitment'
,table_name
,partition_suffix
);
PERFORM comment_partitioned_column(
'Index of the coin in the age-withdraw request, which is implicitly a batch request'
,'coin_index'
,table_name
,partition_suffix
);
PERFORM comment_partitioned_column(
'Hash of the envelope of the new coin to be signed (for lookups). The corresponding signatures are stores in age_withdraw_commitments.denom_sigs.'
,'h_coin_ev'
,table_name
,partition_suffix
);
END
$$;
CREATE FUNCTION constrain_table_age_withdraw_revealed_coins(
IN partition_suffix VARCHAR
)
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
table_name VARCHAR DEFAULT 'age_withdraw_revealed_coins';
BEGIN
table_name = concat_ws('_', table_name, partition_suffix);
EXECUTE FORMAT (
'ALTER TABLE ' || table_name ||
' ADD CONSTRAINT ' || table_name || '_age_withdraw_revealed_coins_id_key'
' UNIQUE (age_withdraw_revealed_coins_id);'
);
EXECUTE FORMAT (
'ALTER TABLE ' || table_name ||
' ADD CONSTRAINT ' || table_name || '_freshcoin_index_and_h_commitment_uniqueness'
' UNIQUE (freshcoin_index, h_commitment);'
);
END
$$;
CREATE FUNCTION foreign_table_age_withdraw_revealed_coins()
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
table_name VARCHAR DEFAULT 'age_withdraw_revealed_coins';
BEGIN
EXECUTE FORMAT (
'ALTER TABLE ' || table_name ||
' ADD CONSTRAINT ' || table_name || '_foreign_h_commitment'
' FOREIGN KEY (h_commitment)'
' REFERENCES age_withdraw_commitments (h_commitment) ON DELETE CASCADE;'
);
END
$$;
INSERT INTO exchange_tables
(name
,version
,action
,partitioned
,by_range)
VALUES
('age_withdraw_revealed_coins'
,'exchange-0003'
,'create'
,TRUE
,FALSE),
('age_withdraw_revealed_coins'
,'exchange-0003'
,'constrain'
,TRUE
,FALSE),
('age_withdraw_revealed_coins'
,'exchange-0003'
,'foreign'
,TRUE
,FALSE);

View File

@ -128,7 +128,8 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
pg_drain_kyc_alert.h pg_drain_kyc_alert.c \
pg_reserves_in_insert.h pg_reserves_in_insert.c \
pg_get_withdraw_info.h pg_get_withdraw_info.c \
pg_get_age_withdraw_info.c pg_get_age_withdraw_info.h \
pg_get_age_withdraw.c pg_get_age_withdraw.h \
pg_do_age_withdraw.h pg_do_age_withdraw.c \
pg_batch_ensure_coin_known.h pg_batch_ensure_coin_known.c \
pg_do_batch_withdraw.h pg_do_batch_withdraw.c \
pg_get_policy_details.h pg_get_policy_details.c \

View File

@ -25,8 +25,7 @@ SET search_path TO exchange;
#include "0003-aml_status.sql"
#include "0003-aml_staff.sql"
#include "0003-aml_history.sql"
#include "0003-age_withdraw_commitments.sql"
#include "0003-age_withdraw_reveals.sql"
#include "0003-age_withdraw.sql"
COMMIT;

View File

@ -0,0 +1,181 @@
--
-- This file is part of TALER
-- Copyright (C) 2023 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/>
--
-- @author Özgür Kesim
CREATE OR REPLACE FUNCTION exchange_do_age_withdraw(
IN amount_val INT8,
IN amount_frac INT4,
IN rpub BYTEA,
IN rsig BYTEA,
IN now INT8,
IN min_reserve_gc INT8,
IN h_commitment BYTEA,
IN maximum_age_committed INT2, -- in years ϵ [0,1..)
IN noreveal_index INT2,
IN blinded_evs BYTEA[],
IN denom_serials INT8[],
IN denom_sigs BYTEA[],
OUT reserve_found BOOLEAN,
OUT balance_ok BOOLEAN,
OUT age_ok BOOLEAN,
OUT required_age INT2, -- in years ϵ [0,1..)
OUT conflict BOOLEAN,
OUT ruuid INT8)
LANGUAGE plpgsql
AS $$
DECLARE
reserve_gc INT8;
reserve_val INT8;
reserve_frac INT4;
reserve_birthday INT4;
not_before date;
earliest_date date;
BEGIN
-- Shards: reserves by reserve_pub (SELECT)
-- reserves_out (INSERT, with CONFLICT detection) by wih
-- reserves by reserve_pub (UPDATE)
-- reserves_in by reserve_pub (SELECT)
-- wire_targets by wire_target_h_payto
SELECT
current_balance_val
,current_balance_frac
,gc_date
,birthday
,reserve_uuid
INTO
reserve_val
,reserve_frac
,reserve_gc
,reserve_birthday
,ruuid
FROM exchange.reserves
WHERE reserves.reserve_pub=rpub;
IF NOT FOUND
THEN
-- reserve unknown
reserve_found=FALSE;
balance_ok=FALSE;
age_ok=FALSE;
required_age=0;
conflict=FALSE;
ruuid=2;
RETURN;
END IF;
-- Check age requirements
IF ((maximum_age_committed = 0) OR (reserve_birthday = 0))
THEN
-- No commitment to a non-zero age was provided or the reserve is marked as
-- having no age restriction. We can simply pass.
age_ok = OK;
ELSE
not_before=date '1970-01-01' + reserve_birthday;
earliest_date = current_date - make_interval(maximum_age_committed);
--
-- 1970-01-01 + birthday == not_before now
-- | | |
-- <.......not allowed......>[<.....allowed range......>]
-- | | |
-- ____*_____________________*_________*________________* timeline
-- |
-- earliest_date ==
-- now - maximum_age_committed*year
--
IF (earliest_date < not_before)
THEN
reserve_found = TRUE;
balance_ok = FALSE;
age_ok = FALSE;
required_age = extract(year from age(not_before, current_date)) + 1;
RETURN;
END IF;
END IF;
-- Check reserve balance is sufficient.
IF (reserve_val > amount_val)
THEN
IF (reserve_frac >= amount_frac)
THEN
reserve_val=reserve_val - amount_val;
reserve_frac=reserve_frac - amount_frac;
ELSE
reserve_val=reserve_val - amount_val - 1;
reserve_frac=reserve_frac + 100000000 - amount_frac;
END IF;
ELSE
IF (reserve_val = amount_val) AND (reserve_frac >= amount_frac)
THEN
reserve_val=0;
reserve_frac=reserve_frac - amount_frac;
ELSE
balance_ok=FALSE;
RETURN;
END IF;
END IF;
-- Calculate new expiration dates.
min_reserve_gc=GREATEST(min_reserve_gc,reserve_gc);
-- Update reserve balance.
UPDATE reserves SET
gc_date=min_reserve_gc
,current_balance_val=reserve_val
,current_balance_frac=reserve_frac
WHERE
reserves.reserve_pub=rpub;
reserve_found=TRUE;
balance_ok=TRUE;
-- Write the commitment into the age-withdraw table
INSERT INTO exchange.age_withdraw
(h_commitment
,max_age
,reserve_pub
,reserve_sig
,noreveal_index
,denomination_serials
,h_blind_evs
,denom_sigs)
VALUES
(h_commitment
,maximum_age_committed
,rpub
,rsig
,noreveal_index
,denom_serials
,blinded_evs
,denom_sigs)
ON CONFLICT DO NOTHING;
IF NOT FOUND
THEN
-- Signal a conflict so that the caller
-- can fetch the actual data from the DB.
conflict=TRUE;
RETURN;
ELSE
conflict=FALSE;
END IF;
END $$;
COMMENT ON FUNCTION exchange_do_age_withdraw(INT8, INT4, BYTEA, BYTEA, INT8, INT8, BYTEA, INT2, INT2, BYTEA[], INT8[], BYTEA[])
IS 'Checks whether the reserve has sufficient balance for an age-withdraw operation (or the request is repeated and was previously approved) and that age requirements are met. If so updates the database with the result. Includes storing the blinded planchets and denomination signatures, or signaling conflict';

View File

@ -1,6 +1,6 @@
--
-- This file is part of TALER
-- Copyright (C) 2014--2022 Taler Systems SA
-- Copyright (C) 2014--2023 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
@ -13,6 +13,8 @@
-- 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/>
--
-- @author Christian Grothoff
-- @author Özgür Kesim
CREATE OR REPLACE FUNCTION exchange_do_batch_withdraw(
IN amount_val INT8,
@ -20,18 +22,20 @@ CREATE OR REPLACE FUNCTION exchange_do_batch_withdraw(
IN rpub BYTEA,
IN now INT8,
IN min_reserve_gc INT8,
-- TODO[oec]: add [IN] parameter for maximum age and [OUT] parameter for required age
IN do_age_check BOOLEAN,
OUT reserve_found BOOLEAN,
OUT balance_ok BOOLEAN,
OUT ruuid INT8)
OUT age_ok BOOLEAN,
OUT allowed_maximum_age INT4, -- in years
OUT ruuid INT8
LANGUAGE plpgsql
AS $$
DECLARE
reserve_gc INT8;
DECLARE
reserve_val INT8;
DECLARE
reserve_frac INT4;
reserve_birthday INT4;
not_before date;
BEGIN
-- Shards: reserves by reserve_pub (SELECT)
-- reserves_out (INSERT, with CONFLICT detection) by wih
@ -44,12 +48,13 @@ SELECT
current_balance_val
,current_balance_frac
,gc_date
,birthday
,reserve_uuid
-- TODO[oec]: get age requirements
INTO
reserve_val
,reserve_frac
,reserve_gc
,reserve_birthday
,ruuid
FROM exchange.reserves
WHERE reserves.reserve_pub=rpub;
@ -59,11 +64,32 @@ THEN
-- reserve unknown
reserve_found=FALSE;
balance_ok=FALSE;
age_ok=FALSE;
allowed_maximum_age=0;
ruuid=2;
RETURN;
END IF;
-- TODO[oec]: check age requirements
-- Check if age requirements are present
IF ((NOT do_age_check) OR (reserve_birthday = 0))
THEN
age_ok = OK;
required_age = 0;
ELSE
-- Age requirements are formally not met: The exchange is setup to support
-- age restrictions (do_age_check == TRUE) and the reserve has a
-- birthday set (reserve_birthday != 0), but the client called the
-- batch-withdraw endpoint instead of the age-withdraw endpoint, which it
-- should have.
not_before=date '1970-01-01' + reserve_birthday;
allowed_maximum_age = extract(year from age(current_date, not_before));
reserve_found=TRUE;
balance_ok=FALSE;
age_ok = FALSE;
RETURN;
END IF;
-- Check reserve balance is sufficient.
IF (reserve_val > amount_val)
@ -82,7 +108,6 @@ ELSE
reserve_val=0;
reserve_frac=reserve_frac - amount_frac;
ELSE
reserve_found=TRUE;
balance_ok=FALSE;
RETURN;
END IF;
@ -104,9 +129,6 @@ balance_ok=TRUE;
END $$;
-- TODO[oec]: Update comment re: age requirements are implemented
COMMENT ON FUNCTION exchange_do_batch_withdraw(INT8, INT4, BYTEA, INT8, INT8)
IS 'Checks whether the reserve has sufficient balance for a withdraw operation (or the request is repeated and was previously approved) and if so updates the database with the result. Excludes storing the planchets.';
COMMENT ON FUNCTION exchange_do_batch_withdraw(INT8, INT4, BYTEA, INT8, INT8, BOOLEAN)
IS 'Checks whether the reserve has sufficient balance for a withdraw operation (or the request is repeated and was previously approved) and that age requirements are formally met. If so updates the database with the result. Excludes storing the planchets.';

View File

@ -14,14 +14,11 @@
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
-- TODO[oec]: add min. age requirements handling
CREATE OR REPLACE FUNCTION exchange_do_batch_withdraw_insert(
IN cs_nonce BYTEA,
IN amount_val INT8,
IN amount_frac INT4,
IN h_denom_pub BYTEA,
IN h_denom_pub BYTEA, -- FIXME: denom_serials should really be a parameter to this FUNCTION.
IN ruuid INT8,
IN reserve_sig BYTEA,
IN h_coin_envelope BYTEA,
@ -45,6 +42,8 @@ out_denom_unknown=TRUE;
out_conflict=TRUE;
out_nonce_reuse=TRUE;
-- FIXME: denom_serials should really be a parameter to this FUNCTION.
SELECT denominations_serial
INTO denom_serial
FROM exchange.denominations

View File

@ -61,7 +61,7 @@ UPDATE exchange.legitimization_processes
out_ok = FOUND;
-- FIXME-Oec: update exchange reserve table to store in_birthday here!
-- UPDATE exchange.reserves SET max_age=in_birthday WHERE reserve_pub=X;
-- UPDATE exchange.reserves SET birthday=in_birthday WHERE reserve_pub=X;
IF in_require_aml
THEN

View File

@ -0,0 +1,104 @@
/*
This file is part of TALER
Copyright (C) 2023 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/pg_do_batch_withdraw.c
* @brief Implementation of the do_batch_withdraw function for Postgres
* @author Özgür Kesim
*/
#include "platform.h"
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_exchangedb_plugin.h"
#include "taler_pq_lib.h"
#include "taler_pq_lib.h"
#include "pg_do_batch_withdraw.h"
#include "pg_helper.h"
#include <gnunet/gnunet_time_lib.h>
enum GNUNET_DB_QueryStatus
TEH_PG_do_age_withdraw (
void *cls,
const struct TALER_EXCHANGEDB_AgeWithdraw *commitment,
struct GNUNET_TIME_Timestamp now,
bool *found,
bool *balance_ok,
bool *age_ok,
uint16_t *required_age,
bool *conflict,
uint64_t *ruuid)
{
struct PostgresClosure *pg = cls;
struct GNUNET_TIME_Timestamp gc;
struct GNUNET_PQ_QueryParam params[] = {
TALER_PQ_query_param_amount (&commitment->amount_with_fee),
GNUNET_PQ_query_param_auto_from_type (&commitment->reserve_pub),
GNUNET_PQ_query_param_auto_from_type (&commitment->reserve_sig),
GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_timestamp (&gc),
GNUNET_PQ_query_param_auto_from_type (&commitment->h_commitment),
GNUNET_PQ_query_param_uint16 (&commitment->max_age),
GNUNET_PQ_query_param_uint16 (&commitment->noreveal_index),
GNUNET_PQ_query_param_array_auto_from_type (commitment->num_coins,
commitment->h_coin_evs,
pg->conn),
GNUNET_PQ_query_param_array_uint64 (commitment->num_coins,
commitment->denom_serials,
pg->conn),
GNUNET_PQ_query_param_array_auto_from_type (commitment->num_coins,
commitment->denom_sigs,
pg->conn),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_bool ("reserve_found",
found),
GNUNET_PQ_result_spec_bool ("balance_ok",
balance_ok),
GNUNET_PQ_result_spec_bool ("age_ok",
age_ok),
GNUNET_PQ_result_spec_uint16 ("required_age",
required_age),
GNUNET_PQ_result_spec_bool ("conflict",
conflict),
GNUNET_PQ_result_spec_uint64 ("ruuid",
ruuid),
GNUNET_PQ_result_spec_end
};
gc = GNUNET_TIME_absolute_to_timestamp (
GNUNET_TIME_absolute_add (now.abs_time,
pg->legal_reserve_expiration_time));
/* Used in #postgres_do_age_withdraw() to
update the reserve balance and check its status */
PREPARE (pg,
"call_age_withdraw",
"SELECT "
" reserve_found"
",balance_ok"
",age_ok"
",required_age"
",conflict"
",ruuid"
" FROM exchange_do_batch_withdraw"
" ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12);");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"call_age_withdraw",
params,
rs);
}

View File

@ -0,0 +1,55 @@
/*
This file is part of TALER
Copyright (C) 2023 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/pg_do_age_withdraw.h
* @brief implementation of the do_age_withdraw function for Postgres
* @author Özgür Kesim
*/
#ifndef PG_DO_AGE_WITHDRAW_H
#define PG_DO_AGE_WITHDRAW_H
#include "taler_util.h"
#include "taler_json_lib.h"
#include "taler_exchangedb_plugin.h"
/**
* Perform reserve update as part of an age-withdraw operation, checking for
* sufficient balance and fulfillment of age requirements. Finally persisting
* the withdrawal details.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param commitment the commitment with all parameters
* @param now current time (rounded)
* @param[out] found set to true if the reserve was found
* @param[out] balance_ok set to true if the balance was sufficient
* @param[out] age_ok set to true if no age requirements are present on the reserve
* @param[out] required_age if @e age_ok is false, set to the maximum allowed age when withdrawing from this reserve
* @param[out] conflict set to true if there already is an entry in the database for the given pair (h_commitment, reserve_pub)
* @param[out] ruuid set to the reserve's UUID (reserves table row)
* @return query execution status
*/
enum GNUNET_DB_QueryStatus
TEH_PG_do_age_withdraw (
void *cls,
const struct TALER_EXCHANGEDB_AgeWithdraw *commitment,
const struct GNUNET_TIME_Timestamp now,
bool *found,
bool *balance_ok,
bool *age_ok,
uint16_t *required_age,
bool *conflict,
uint64_t *ruuid);
#endif

View File

@ -17,6 +17,7 @@
* @file exchangedb/pg_do_batch_withdraw.c
* @brief Implementation of the do_batch_withdraw function for Postgres
* @author Christian Grothoff
* @author Özgür Kesim
*/
#include "platform.h"
#include "taler_error_codes.h"
@ -31,10 +32,12 @@ TEH_PG_do_batch_withdraw (
void *cls,
struct GNUNET_TIME_Timestamp now,
const struct TALER_ReservePublicKeyP *reserve_pub,
/* TODO[oec]: add parameter for maximum age and [out]parameter for required age */
const struct TALER_Amount *amount,
bool do_age_check,
bool *found,
bool *balance_ok,
bool *age_ok,
uint16_t *allowed_maximum_age,
uint64_t *ruuid)
{
struct PostgresClosure *pg = cls;
@ -42,6 +45,7 @@ TEH_PG_do_batch_withdraw (
struct GNUNET_PQ_QueryParam params[] = {
TALER_PQ_query_param_amount (amount),
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
GNUNET_PQ_query_param_bool (do_age_check),
GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_timestamp (&gc),
GNUNET_PQ_query_param_end
@ -51,6 +55,10 @@ TEH_PG_do_batch_withdraw (
found),
GNUNET_PQ_result_spec_bool ("balance_ok",
balance_ok),
GNUNET_PQ_result_spec_bool ("age_ok",
age_ok),
GNUNET_PQ_result_spec_uint16 ("allowed_maximum_age",
allowed_maximum_age),
GNUNET_PQ_result_spec_uint64 ("ruuid",
ruuid),
GNUNET_PQ_result_spec_end
@ -68,8 +76,9 @@ TEH_PG_do_batch_withdraw (
"SELECT "
" reserve_found"
",balance_ok"
",age_ok"
",required_age"
",ruuid"
/* TODO[oec]: add parameter for maximum age and [out] parameter for required age */
" FROM exchange_do_batch_withdraw"
" ($1,$2,$3,$4,$5);");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,

View File

@ -33,8 +33,11 @@
* @param now current time (rounded)
* @param reserve_pub public key of the reserve to debit
* @param amount total amount to withdraw
* @param age_check_required if true, fail if age requirements are set on the reserve
* @param[out] found set to true if the reserve was found
* @param[out] balance_ok set to true if the balance was sufficient
* @param[out] age_ok set to true if no age requirements are present on the reserve
* @param[out] allowed_maximum_age if @e age_ok is false, set to the maximum allowed age when withdrawing from this reserve (client needs to call age-withdraw)
* @param[out] ruuid set to the reserve's UUID (reserves table row)
* @return query execution status
*/
@ -44,8 +47,11 @@ TEH_PG_do_batch_withdraw (
struct GNUNET_TIME_Timestamp now,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
bool age_check_required,
bool *found,
bool *balance_ok,
bool *age_ok,
uint16_t *allowed_maximum_age,
uint64_t *ruuid);
#endif

View File

@ -14,24 +14,24 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file exchangedb/pg_get_age_withdraw_info.c
* @brief Implementation of the get_age_withdraw_info function for Postgres
* @file exchangedb/pg_get_age_withdraw.c
* @brief Implementation of the get_age_withdraw function for Postgres
* @author Özgür Kesim
*/
#include "platform.h"
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
#include "pg_get_age_withdraw_info.h"
#include "pg_get_age_withdraw.h"
#include "pg_helper.h"
enum GNUNET_DB_QueryStatus
TEH_PG_get_age_withdraw_info (
TEH_PG_get_age_withdraw (
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_AgeWithdrawCommitmentHashP *ach,
struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc)
struct TALER_EXCHANGEDB_AgeWithdraw *aw)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@ -41,26 +41,44 @@ TEH_PG_get_age_withdraw_info (
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_commitment",
&awc->h_commitment),
&aw->h_commitment),
GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
&awc->reserve_sig),
&aw->reserve_sig),
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&awc->reserve_pub),
&aw->reserve_pub),
GNUNET_PQ_result_spec_uint16 ("max_age",
&awc->max_age),
&aw->max_age),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
&awc->amount_with_fee),
GNUNET_PQ_result_spec_uint32 ("noreveal_index",
&awc->noreveal_index),
&aw->amount_with_fee),
GNUNET_PQ_result_spec_uint16 ("noreveal_index",
&aw->noreveal_index),
GNUNET_PQ_result_spec_array_fixed_size (
pg->conn,
"h_coin_evs",
sizeof(struct TALER_BlindedPlanchet),
&aw->num_coins,
(void **) &aw->h_coin_evs),
GNUNET_PQ_result_spec_array_fixed_size (
pg->conn,
"denom_sigs",
sizeof(struct TALER_DenominationSignature),
NULL,
(void **) &aw->denom_sigs),
GNUNET_PQ_result_spec_array_fixed_size (
pg->conn,
"denom_pub_hashes",
sizeof(struct TALER_DenominationHashP),
NULL,
(void **) &aw->denom_pub_hashes),
GNUNET_PQ_result_spec_end
};
/* Used in #postgres_get_age_withdraw_info() to
locate the response for a /reserve/$RESERVE_PUB/age-withdraw request using
the hash of the blinded message. Used to make sure
/reserve/$RESERVE_PUB/age-withdraw requests are idempotent. */
/* Used in #postgres_get_age_withdraw() to
locate the response for a /reserve/$RESERVE_PUB/age-withdraw request
using the hash of the blinded message. Also needed to ensure
idempotency of /reserve/$RESERVE_PUB/age-withdraw requests. */
PREPARE (pg,
"get_age_withdraw_info",
"get_age_withdraw",
"SELECT"
" h_commitment"
",reserve_sig"
@ -69,10 +87,20 @@ TEH_PG_get_age_withdraw_info (
",amount_with_fee_val"
",amount_with_fee_frac"
",noreveal_index"
" FROM age_withdraw_commitments"
",h_coin_evs"
",denom_sigs"
",ARRAY("
" SELECT denominations.denom_pub_hash FROM ("
" SELECT UNNEST(denomination_serials) AS id,"
" generate_subscripts(denominations_serials, 1) AS nr" /* for order */
" ) AS denoms"
" LEFT JOIN denominations ON denominations.denominations_serial=denoms.id"
") AS denom_pub_hashes"
" FROM age_withdraw"
" WHERE reserve_pub=$1 and h_commitment=$2;");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"get_age_withdraw_info",
"get_age_withdraw",
params,
rs);
}

View File

@ -14,12 +14,12 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file exchangedb/pg_get_age_withdraw_info.h
* @brief implementation of the get_age_withdraw_info function for Postgres
* @file exchangedb/pg_get_age_withdraw.h
* @brief implementation of the get_age_withdraw function for Postgres
* @author Özgür KESIM
*/
#ifndef PG_GET_AGE_WITHDRAW_INFO_H
#define PG_GET_AGE_WITHDRAW_INFO_H
#ifndef PG_GET_AGE_WITHDRAW_H
#define PG_GET_AGE_WITHDRAW_H
#include "taler_util.h"
#include "taler_json_lib.h"
@ -33,13 +33,13 @@
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve for which the age-withdraw request is made
* @param ach hash that uniquely identifies the age-withdraw operation
* @param[out] awc corresponding details of the previous age-withdraw request if an entry was found
* @param[out] aw corresponding details of the previous age-withdraw request if an entry was found
* @return statement execution status
*/
enum GNUNET_DB_QueryStatus
TEH_PG_get_age_withdraw_info (
TEH_PG_get_age_withdraw (
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_AgeWithdrawCommitmentHashP *ach,
struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc);
struct TALER_EXCHANGEDB_AgeWithdraw *aw);
#endif

View File

@ -27,7 +27,7 @@
enum GNUNET_DB_QueryStatus
TEH_PG_get_withdraw_info (
TEH_PG_get_withdraw (
void *cls,
const struct TALER_BlindedCoinHashP *bch,
struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable)

View File

@ -1,106 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2023 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/pg_insert_age_withdraw_reveal.c
* @brief Implementation of the insert_age_withdraw_reveal function for Postgres
* @author Özgür Kesim
*/
#include "platform.h"
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
#include "pg_insert_refresh_reveal.h"
#include "pg_helper.h"
enum GNUNET_DB_QueryStatus
TEH_PG_insert_age_withdraw_reveal (
void *cls,
/*TODO:oec*/
)
{
struct PostgresClosure *pg = cls;
if (TALER_CNC_KAPPA != num_tprivs + 1)
{
GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
}
/* TODO */
#if 0
PREPARE (pg,
"insert_age_withdraw_revealed_coin",
"INSERT INTO age_withdraw_reveals "
"(h_commitment "
",freshcoin_index "
",denominations_serial "
",h_coin_ev "
",ev_sig"
") SELECT $1, $2, $3, "
" denominations_serial, $5, $6, $7, $8"
" FROM denominations"
" WHERE denom_pub_hash=$4"
" ON CONFLICT DO NOTHING;");
for (uint32_t i = 0; i<num_rrcs; i++)
{
const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&melt_serial_id),
GNUNET_PQ_query_param_uint32 (&i),
GNUNET_PQ_query_param_auto_from_type (&rrc->orig_coin_link_sig),
GNUNET_PQ_query_param_auto_from_type (&rrc->h_denom_pub),
TALER_PQ_query_param_blinded_planchet (&rrc->blinded_planchet),
TALER_PQ_query_param_exchange_withdraw_values (&rrc->exchange_vals),
GNUNET_PQ_query_param_auto_from_type (&rrc->coin_envelope_hash),
TALER_PQ_query_param_blinded_denom_sig (&rrc->coin_sig),
GNUNET_PQ_query_param_end
};
enum GNUNET_DB_QueryStatus qs;
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_refresh_revealed_coin",
params);
if (0 > qs)
return qs;
}
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&melt_serial_id),
GNUNET_PQ_query_param_auto_from_type (tp),
GNUNET_PQ_query_param_fixed_size (
tprivs,
num_tprivs * sizeof (struct TALER_TransferPrivateKeyP)),
GNUNET_PQ_query_param_end
};
/* Used in #postgres_insert_refresh_reveal() to store the transfer
keys we learned */
PREPARE (pg,
"insert_refresh_transfer_keys",
"INSERT INTO refresh_transfer_keys "
"(melt_serial_id"
",transfer_pub"
",transfer_privs"
") VALUES ($1, $2, $3)"
" ON CONFLICT DO NOTHING;");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_refresh_transfer_keys",
params);
}
#endif
}

View File

@ -1,43 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2023 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/pg_insert_age_withdraw_reveal.h
* @brief implementation of the insert_age_withdraw_reveal function for Postgres
* @author Özgür Kesim
*/
#ifndef PG_INSERT_AGE_WITHDRAW_REVEAL_H
#define PG_INSERT_AGE_WITHDRAW_REVEAL_H
#include "taler_util.h"
#include "taler_json_lib.h"
#include "taler_exchangedb_plugin.h"
/**
* @brief Store in the database which coin(s) the wallet wanted to create in a
* given age-withdraw operation and all of the other information we learned or
* created in the /age-withdraw/reveal step.
*
* @param cls the @e cls of this struct with the plugin-specific state
* TODO:oec
* @return query status for the transaction
*/
enum GNUNET_DB_QueryStatus
TEH_PG_insert_refresh_reveal (
void *cls,
/* TODO: oec */
);
#endif

View File

@ -2057,38 +2057,37 @@ irbt_cb_table_purse_deletion (struct PostgresClosure *pg,
/**
* Function called with age_withdraw_commitments records to insert into table.
* Function called with age_withdraw records to insert into table.
*
* @param pg plugin context
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_age_withdraw_commitments (struct PostgresClosure *pg,
irbt_cb_table_age_withdraw (struct PostgresClosure *pg,
const struct
TALER_EXCHANGEDB_TableData *td)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (
&td->details.age_withdraw_commitments.h_commitment),
&td->details.age_withdraw.h_commitment),
TALER_PQ_query_param_amount (
&td->details.age_withdraw_commitments.amount_with_fee),
&td->details.age_withdraw.amount_with_fee),
GNUNET_PQ_query_param_uint16 (
&td->details.age_withdraw_commitments.max_age),
&td->details.age_withdraw.max_age),
GNUNET_PQ_query_param_auto_from_type (
&td->details.age_withdraw_commitments.reserve_pub),
&td->details.age_withdraw.reserve_pub),
GNUNET_PQ_query_param_auto_from_type (
&td->details.age_withdraw_commitments.reserve_sig),
&td->details.age_withdraw.reserve_sig),
GNUNET_PQ_query_param_uint32 (
&td->details.age_withdraw_commitments.noreveal_index),
GNUNET_PQ_query_param_absolute_time (
&td->details.age_withdraw_commitments.timestamp),
&td->details.age_withdraw.noreveal_index),
/* TODO: other fields, too! */
GNUNET_PQ_query_param_end
};
PREPARE (pg,
"insert_into_table_age_withdraw_commitments",
"INSERT INTO age_withdraw_commitments"
"insert_into_table_age_withdraw",
"INSERT INTO age_withdraw"
"(age_withdraw_commitment_id"
",h_commitment"
",amount_with_fee_val"
@ -2097,64 +2096,10 @@ irbt_cb_table_age_withdraw_commitments (struct PostgresClosure *pg,
",reserve_pub"
",reserve_sig"
",noreveal_index"
",timestamp"
") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8, $9);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_into_table_age_withdraw_commitments",
params);
}
/**
* Function called with age_withdraw_revealed_coins records to insert into table.
*
* @param pg plugin context
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_age_withdraw_revealed_coins (struct PostgresClosure *pg,
const struct
TALER_EXCHANGEDB_TableData *td)
{
struct GNUNET_HashCode h_coin_ev;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (
&td->details.age_withdraw_revealed_coins.h_commitment),
GNUNET_PQ_query_param_uint32 (
&td->details.age_withdraw_revealed_coins.freshcoin_index),
GNUNET_PQ_query_param_uint64 (
&td->details.age_withdraw_revealed_coins.denominations_serial),
GNUNET_PQ_query_param_fixed_size (
td->details.age_withdraw_revealed_coins.coin_ev,
td->details.age_withdraw_revealed_coins.coin_ev_size),
GNUNET_PQ_query_param_auto_from_type (&h_coin_ev),
TALER_PQ_query_param_blinded_denom_sig (
&td->details.age_withdraw_revealed_coins.ev_sig),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
"insert_into_table_age_withdraw_revealed_coins",
"INSERT INTO age_withdraw_revealed_coins"
"(age_withdraw_revealed_coins_id"
",h_commitment"
",freshcoin_index"
",denominations_serial"
",coin_ev"
",h_coin_ev"
",ev_sig"
",ewv"
") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8);");
GNUNET_CRYPTO_hash (td->details.age_withdraw_revealed_coins.coin_ev,
td->details.age_withdraw_revealed_coins.coin_ev_size,
&h_coin_ev);
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_into_table_age_withdraw_revealed_coins",
"insert_into_table_age_withdraw",
params);
}
@ -2306,11 +2251,8 @@ TEH_PG_insert_records_by_table (void *cls,
case TALER_EXCHANGEDB_RT_PURSE_DELETION:
rh = &irbt_cb_table_purse_deletion;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
rh = &irbt_cb_table_age_withdraw_commitments;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS:
rh = &irbt_cb_table_age_withdraw_revealed_coins;
case TALER_EXCHANGEDB_RT_AGE_WITHDRAW:
rh = &irbt_cb_table_age_withdraw;
break;
}
if (NULL == rh)

View File

@ -72,6 +72,8 @@ dominations_cb_helper (void *cls,
struct TALER_DenominationHashP h_denom_pub = {0};
bool revoked;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("denominations_serial",
&meta.serial),
GNUNET_PQ_result_spec_auto_from_type ("master_sig",
&master_sig),
GNUNET_PQ_result_spec_bool ("revoked",
@ -145,7 +147,8 @@ TEH_PG_iterate_denominations (void *cls,
PREPARE (pg,
"select_denominations",
"SELECT"
" denominations.master_sig"
" denominations_serial"
",denominations.master_sig"
",denom_revocations_serial_id IS NOT NULL AS revoked"
",valid_from"
",expire_withdraw"

View File

@ -2762,109 +2762,48 @@ lrbt_cb_table_purse_deletion (void *cls,
/**
* Function called with age_withdraw_commitments table entries.
* Function called with age_withdraw table entries.
*
* @param cls closure
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
lrbt_cb_table_age_withdraw_commitments (void *cls,
lrbt_cb_table_age_withdraw (void *cls,
PGresult *result,
unsigned int num_results)
{
struct LookupRecordsByTableContext *ctx = cls;
struct PostgresClosure *pg = ctx->pg;
struct TALER_EXCHANGEDB_TableData td = {
.table = TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS
.table = TALER_EXCHANGEDB_RT_AGE_WITHDRAW
};
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 (
"age_withdraw_commitment_id",
"age_withdraw_id",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"h_commitment",
&td.details.age_withdraw_commitments.h_commitment),
&td.details.age_withdraw.h_commitment),
GNUNET_PQ_result_spec_uint16 (
"max_age",
&td.details.age_withdraw_commitments.max_age),
&td.details.age_withdraw.max_age),
TALER_PQ_RESULT_SPEC_AMOUNT (
"amount_with_fee",
&td.details.age_withdraw_commitments.amount_with_fee),
&td.details.age_withdraw.amount_with_fee),
GNUNET_PQ_result_spec_auto_from_type (
"reserve_pub",
&td.details.age_withdraw_commitments.reserve_pub),
&td.details.age_withdraw.reserve_pub),
GNUNET_PQ_result_spec_auto_from_type (
"reserve_sig",
&td.details.age_withdraw_commitments.reserve_sig),
&td.details.age_withdraw.reserve_sig),
GNUNET_PQ_result_spec_uint32 (
"noreveal_index",
&td.details.age_withdraw_commitments.noreveal_index),
GNUNET_PQ_result_spec_end
};
if (GNUNET_OK !=
GNUNET_PQ_extract_result (result,
rs,
i))
{
GNUNET_break (0);
ctx->error = true;
return;
}
ctx->cb (ctx->cb_cls,
&td);
GNUNET_PQ_cleanup_result (rs);
}
}
/**
* Function called with age_withdraw_revealed_coins table entries.
*
* @param cls closure
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
lrbt_cb_table_age_withdraw_revealed_coins (void *cls,
PGresult *result,
unsigned int num_results)
{
struct LookupRecordsByTableContext *ctx = cls;
struct TALER_EXCHANGEDB_TableData td = {
.table = TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS
};
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 (
"age_withdraw_revealed_coins_id",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"h_commitment",
&td.details.age_withdraw_revealed_coins.h_commitment),
GNUNET_PQ_result_spec_uint32 (
"freshcoin_index",
&td.details.age_withdraw_revealed_coins.freshcoin_index),
GNUNET_PQ_result_spec_uint64 (
"denominations_serial",
&td.details.age_withdraw_revealed_coins.denominations_serial),
/* Note: h_coin_ev is recalculated */
GNUNET_PQ_result_spec_variable_size (
"coin_ev",
(void **) &td.details.age_withdraw_revealed_coins.coin_ev,
&td.details.age_withdraw_revealed_coins.coin_ev_size),
TALER_PQ_result_spec_blinded_denom_sig (
"ev_sig",
&td.details.refresh_revealed_coins.ev_sig),
TALER_PQ_result_spec_exchange_withdraw_values (
"ewv",
&td.details.refresh_revealed_coins.ewv),
&td.details.age_withdraw.noreveal_index),
/* TODO[oec]: more fields! */
GNUNET_PQ_result_spec_end
};
@ -3591,10 +3530,10 @@ TEH_PG_lookup_records_by_table (void *cls,
" ORDER BY purse_deletion_serial_id ASC;");
rh = &lrbt_cb_table_purse_deletion;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
XPREPARE ("select_above_serial_by_table_age_withdraw_commitments",
case TALER_EXCHANGEDB_RT_AGE_WITHDRAW:
XPREPARE ("select_above_serial_by_table_age_withdraw",
"SELECT"
" age_withdraw_commitment_id"
" age_withdraw_id"
",h_commitment"
",amount_with_fee_val"
",amount_with_fee_frac"
@ -3602,26 +3541,11 @@ TEH_PG_lookup_records_by_table (void *cls,
",reserve_pub"
",reserve_sig"
",noreveal_index"
" FROM age_withdraw_commitments"
" WHERE age_withdraw_commitment_id > $1"
" ORDER BY age_withdraw_commitment_id ASC;");
rh = &lrbt_cb_table_age_withdraw_commitments;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS:
XPREPARE ("select_above_serial_by_table_age_withdraw_revealed_coins",
"SELECT"
" age_withdraw_revealed_coins_serial_id"
",h_commitment"
",freshcoin_index"
",denominations_serial"
",coin_ev"
",h_coin_ev"
",ev_sig"
",ewv"
" FROM age_withdraw_revealed_coins"
" WHERE age_withdraw_revealed_coins_serial_id > $1"
" ORDER BY age_withdraw_revealed_coins_serial_id ASC;");
rh = &lrbt_cb_table_age_withdraw_revealed_coins;
" FROM age_withdraw"
" WHERE age_withdraw_id > $1"
" ORDER BY age_withdraw_id ASC;");
/* TODO[oec]: MORE FIELDS! */
rh = &lrbt_cb_table_age_withdraw;
break;
}
if (NULL == rh)

View File

@ -426,23 +426,14 @@ TEH_PG_lookup_serial_by_table (void *cls,
" LIMIT 1;");
statement = "select_serial_by_table_purse_deletion";
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
XPREPARE ("select_serial_by_table_age_withdraw_commitments",
case TALER_EXCHANGEDB_RT_AGE_WITHDRAW:
XPREPARE ("select_serial_by_table_age_withdraw",
"SELECT"
" age_withdraw_commitment_id AS serial"
" FROM age_withdraw_commitments"
" ORDER BY age_withdraw_commitment_id DESC"
" age_withdraw_id AS serial"
" FROM age_withdraw"
" ORDER BY age_withdraw_id DESC"
" LIMIT 1;");
statement = "select_serial_by_table_age_withdraw_commitments";
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS:
XPREPARE ("select_serial_by_table_age_withdraw_revealed_coins",
"SELECT"
" age_withdraw_revealed_coins_id AS serial"
" FROM age_withdraw_revealed_coins"
" ORDER BY age_withdraw_revealed_coins_id DESC"
" LIMIT 1;");
statement = "select_serial_by_table_age_withdraw_revealed_coins";
statement = "select_serial_by_table_age_withdraw";
break;
}
if (NULL == statement)

View File

@ -117,8 +117,9 @@
#include "pg_drain_kyc_alert.h"
#include "pg_reserves_in_insert.h"
#include "pg_get_withdraw_info.h"
#include "pg_get_age_withdraw_info.h"
#include "pg_get_age_withdraw.h"
#include "pg_do_batch_withdraw.h"
#include "pg_do_age_withdraw.h"
#include "pg_get_policy_details.h"
#include "pg_persist_policy_details.h"
#include "pg_do_deposit.h"
@ -581,8 +582,10 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &TEH_PG_get_withdraw_info;
plugin->do_batch_withdraw
= &TEH_PG_do_batch_withdraw;
plugin->get_age_withdraw_info
= &TEH_PG_get_age_withdraw_info;
plugin->do_age_withdraw
= &TEH_PG_do_age_withdraw;
plugin->get_age_withdraw
= &TEH_PG_get_age_withdraw;
plugin->get_policy_details
= &TEH_PG_get_policy_details;
plugin->persist_policy_details

View File

@ -160,7 +160,7 @@ BEGIN
',current_balance_frac INT4 NOT NULL DEFAULT(0)'
',purses_active INT8 NOT NULL DEFAULT(0)'
',purses_allowed INT8 NOT NULL DEFAULT(0)'
',max_age INT4 NOT NULL DEFAULT(120)'
',birthdate INT4 NOT NULL DEFAULT(0)' -- 0 means: no age restriction.
',expiration_date INT8 NOT NULL'
',gc_date INT8 NOT NULL'
') %s ;'

View File

@ -154,6 +154,7 @@ struct TALER_AUDITOR_HttpResponse
* @param vi basic information about the auditor
* @param compat protocol compatibility information
*/
// FIXME: bad API!
typedef void
(*TALER_AUDITOR_VersionCallback) (
void *cls,

View File

@ -3728,7 +3728,8 @@ TALER_wallet_withdraw_verify (
*
* @param h_commitment hash all n*kappa blinded coins in the commitment for the age-withdraw
* @param amount_with_fee amount to debit the reserve for
* @param max_age_group maximum age group that the withdrawn coins must be restricted to
* @param mask the mask that defines the age groups
* @param max_age maximum age from which the age group is derived, that the withdrawn coins must be restricted to.
* @param reserve_priv private key to sign with
* @param[out] reserve_sig resulting signature
*/
@ -3736,7 +3737,8 @@ void
TALER_wallet_age_withdraw_sign (
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
const struct TALER_Amount *amount_with_fee,
uint32_t max_age_group,
const struct TALER_AgeMask *mask,
uint8_t max_age,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
@ -3745,7 +3747,8 @@ TALER_wallet_age_withdraw_sign (
*
* @param h_commitment hash all n*kappa blinded coins in the commitment for the age-withdraw
* @param amount_with_fee amount to debit the reserve for
* @param max_age_group maximum age group that the withdrawn coins must be restricted to
* @param mask the mask that defines the age groups
* @param max_age maximum age from which the age group is derived, that the withdrawn coins must be restricted to.
* @param reserve_pub public key of the reserve
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
@ -3754,7 +3757,8 @@ enum GNUNET_GenericReturnValue
TALER_wallet_age_withdraw_verify (
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
const struct TALER_Amount *amount_with_fee,
uint32_t max_age_group,
const struct TALER_AgeMask *mask,
uint8_t max_age,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
@ -5873,7 +5877,7 @@ TALER_age_commitment_hash (
enum GNUNET_GenericReturnValue
TALER_age_restriction_commit (
const struct TALER_AgeMask *mask,
const uint8_t age,
uint8_t age,
const struct GNUNET_HashCode *seed,
struct TALER_AgeCommitmentProof *comm_proof);

View File

@ -623,15 +623,20 @@ enum TALER_EXCHANGE_CheckKeysFlags
/**
* Check if our current response for /keys is valid, and if
* not, trigger /keys download.
* not, trigger /keys download. If @a cb is given, changes
* the @a exchange callback for the /keys response.
*
* @param exchange exchange to check keys for
* @param flags options controlling when to download what
* @param cb function to call with the /keys response, can be NULL
* @param cb_cls closure for @a cb
* @return until when the existing response is current, 0 if we are re-downloading now
*/
struct GNUNET_TIME_Timestamp
TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
enum TALER_EXCHANGE_CheckKeysFlags flags);
enum TALER_EXCHANGE_CheckKeysFlags flags,
TALER_EXCHANGE_CertificationCallback cb,
void *cb_cls);
/**

View File

@ -301,8 +301,7 @@ enum TALER_EXCHANGEDB_ReplicatedTable
TALER_EXCHANGEDB_RT_AML_HISTORY,
TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES,
TALER_EXCHANGEDB_RT_PURSE_DELETION,
TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS,
TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS,
TALER_EXCHANGEDB_RT_AGE_WITHDRAW,
};
@ -773,22 +772,14 @@ struct TALER_EXCHANGEDB_TableData
struct TALER_AgeWithdrawCommitmentHashP h_commitment;
struct TALER_Amount amount_with_fee;
uint16_t max_age;
uint32_t noreveal_index;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_ReserveSignatureP reserve_sig;
uint32_t noreveal_index;
struct GNUNET_TIME_Absolute timestamp;
} age_withdraw_commitments;
struct
{
struct TALER_AgeWithdrawCommitmentHashP h_commitment;
uint32_t freshcoin_index;
uint64_t denominations_serial;
void *coin_ev;
size_t coin_ev_size;
// h_coin_ev omitted, to be recomputed!
struct TALER_BlindedDenominationSignature ev_sig;
} age_withdraw_revealed_coins;
uint64_t num_coins;
uint64_t *denominations_serials;
void *h_blind_evs;
struct TALER_BlindedDenominationSignature denom_sigs;
} age_withdraw;
} details;
@ -948,6 +939,13 @@ struct TALER_EXCHANGEDB_Reserve
*/
struct TALER_EXCHANGEDB_DenominationKeyMetaData
{
/**
* Serial of the denomination key as in the DB.
* Can be used in calls to stored procedures in order to spare
* additional lookups.
*/
uint64_t serial;
/**
* Start time of the validity period for this key.
*/
@ -1182,11 +1180,11 @@ struct TALER_EXCHANGEDB_CollectableBlindcoin
/**
* @brief Information we keep for an age-withdraw commitment
* @brief Information we keep for an age-withdraw request
* to reproduce the /age-withdraw operation if needed, and to have proof
* that a reserve was drained by this amount.
*/
struct TALER_EXCHANGEDB_AgeWithdrawCommitment
struct TALER_EXCHANGEDB_AgeWithdraw
{
/**
* Total amount (with fee) committed to withdraw
@ -1194,7 +1192,7 @@ struct TALER_EXCHANGEDB_AgeWithdrawCommitment
struct TALER_Amount amount_with_fee;
/**
* Maximum age that the coins are restricted to.
* Maximum age (in years) that the coins are restricted to.
*/
uint16_t max_age;
@ -1208,7 +1206,7 @@ struct TALER_EXCHANGEDB_AgeWithdrawCommitment
* revealed during cut and choose. This value applies to all n coins in the
* commitment.
*/
uint32_t noreveal_index;
uint16_t noreveal_index;
/**
* Public key of the reserve that was drained.
@ -1223,9 +1221,35 @@ struct TALER_EXCHANGEDB_AgeWithdrawCommitment
struct TALER_ReserveSignatureP reserve_sig;
/**
* The exchange's signature of the response.
* Number of coins to be withdrawn.
*/
struct TALER_ExchangeSignatureP sig;
size_t num_coins;
/**
* Array of @a num_coins blinded coins. These are the chosen coins
* (according to @a noreveal_index) from the request, which contained
* kappa*num_coins blinded coins.
*/
struct TALER_BlindedCoinHashP *h_coin_evs;
/**
* Array of @a num_coins denomination signatures of the blinded coins @a
* h_coin_evs.
*/
struct TALER_BlindedDenominationSignature *denom_sigs;
/**
* Array of @a num_coins serial id's of the denominations, corresponding to
* the coins in @a h_coin_evs.
*/
uint64_t *denom_serials;
/**
* Array of @a num_coins hashes of the public keys of the denominations
* identified by @e denom_serials. This field is set when calling
* get_age_withdraw
*/
struct TALER_DenominationHashP *denom_pub_hashes;
};
@ -2751,28 +2775,6 @@ struct TALER_EXCHANGEDB_CsRevealFreshCoinData
uint32_t coin_off;
};
/**
* Information about a coin that was revealed to the exchange
* during reveal.
*/
struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin
{
/**
* Hash of the public denomination key of the coin.
*/
struct TALER_DenominationHashP h_denom_pub;
/**
* Signature generated by the exchange over the coin (in blinded format).
*/
struct TALER_BlindedDenominationSignature coin_sig;
/**
* Blinded hash of the new coin
*/
struct TALER_BlindedCoinHashP h_coin_ev;
};
/**
* Generic KYC status for some operation.
@ -3760,6 +3762,15 @@ struct TALER_EXCHANGEDB_Plugin
uint64_t *ruuid);
/**
* FIXME: merge do_batch_withdraw and do_batch_withdraw_insert into one API,
* which takes as input (among others)
* - denom_serial[]
* - blinded_coin_evs[]
* - denom_sigs[]
* The implementation should persist the data as _arrays_ in the DB.
*/
/**
* Perform reserve update as part of a batch withdraw operation, checking
* for sufficient balance. Persisting the withdrawal details is done
@ -3769,8 +3780,11 @@ struct TALER_EXCHANGEDB_Plugin
* @param now current time (rounded)
* @param reserve_pub public key of the reserve to debit
* @param amount total amount to withdraw
* @param do_age_check if set, the batch-withdrawal can only succeed when the reserve has no age restriction (birthday) set.
* @param[out] found set to true if the reserve was found
* @param[out] balance_ok set to true if the balance was sufficient
* @param[out] age_ok set to true if no age requirements were defined on the reserve or @e do_age_check was false
* @param[out] allowed_maximum_age when @e age_ok is false, set to the allowed maximum age for withdrawal from the reserve. The client MUST then use the age-withdraw endpoint
* @param[out] ruuid set to the reserve's UUID (reserves table row)
* @return query execution status
*/
@ -3780,8 +3794,11 @@ struct TALER_EXCHANGEDB_Plugin
struct GNUNET_TIME_Timestamp now,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
bool do_age_check,
bool *found,
bool *balance_ok,
bool *age_ok,
uint16_t *allowed_maximum_age,
uint64_t *ruuid);
@ -3811,73 +3828,49 @@ struct TALER_EXCHANGEDB_Plugin
bool *nonce_reuse);
/**
* Locate the response for a age-withdraw request under a hash that uniquely
* identifies the age-withdraw operation. Used to ensure idempotency of the
* request.
* Locate the response for a age-withdraw request under a hash of the
* commitment and reserve_pub that uniquely identifies the age-withdraw
* operation. Used to ensure idempotency of the request.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve for which the age-withdraw request is made
* @param ach hash that uniquely identifies the age-withdraw operation
* @param[out] awc corresponding details of the previous age-withdraw request if an entry was found
* @param[out] aw corresponding details of the previous age-withdraw request if an entry was found
* @return statement execution status
*/
enum GNUNET_DB_QueryStatus
(*get_age_withdraw_info)(
(*get_age_withdraw)(
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_AgeWithdrawCommitmentHashP *ach,
struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc);
struct TALER_EXCHANGEDB_AgeWithdraw *aw);
/**
* Perform an age-withdraw operation, checking for sufficient balance
* and possibly persisting the withdrawal details.
* Perform an age-withdraw operation, checking for sufficient balance and
* fulfillment of age requirements and possibly persisting the withdrawal
* details.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param commitment corresponding commitment for the age-withdraw
* @param[out] found set to true if the reserve was found
* @param[out] balance_ok set to true if the balance was sufficient
* @param[out] age_ok set to true if age requirements were met
* @param[out] allowed_maximum_age if @e age_ok is FALSE, this is set to the allowed maximum age
* @param[out] ruuid set to the reserve's UUID (reserves table row)
* @return query execution status
*/
enum GNUNET_DB_QueryStatus
(*do_age_withdraw)(
void *cls,
const struct TALER_EXCHANGEDB_AgeWithdrawCommitment *commitment,
const struct TALER_EXCHANGEDB_AgeWithdraw *commitment,
struct GNUNET_TIME_Timestamp now,
bool *found,
bool *balance_ok,
bool *age_ok,
uint16_t *allowed_maximum_age,
bool *conflict,
uint64_t *ruuid);
/**
* Store in the database which coin(s) the wallet wanted to withdraw with
* age restriction enabled in a given age-withdraw operation and the relevant
* information we learned or created in the reveal steop
*
* @param cls The `struct PostgresClosure` with the plugin-specific state
* @param h_commitment The hash of the original age-withdraw commitment, which is a key into the age_withdraw_commitments table
* @param num_awrcs Number of coins to generate, size of the @a coin_evs array
* @param awrcs Array of @a num_awrcs information about coins to be created
* @return query execution status
*/
enum GNUNET_DB_QueryStatus
(*insert_age_withdraw_reveal)(
void *cls,
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
uint32_t num_awrcs,
const struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin *awrcs);
/**
* Lookup in the database for the fresh coins with age-restriction that
* we created in the given age-withdraw operation.
*
* TODO: oec
*/
enum GNUNET_DB_QueryStatus
(*get_age_withdraw_reveal)(
void *cls,
uint64_t h_commitment
/* TODO: oec */
);
/**
* Retrieve the details to a policy given by its hash_code
*

View File

@ -219,12 +219,12 @@ struct TALER_Extensions
* Generic functions for extensions
*/
/*
/**
* @brief Loads the extensions as shared libraries, as specified in the given
* TALER configuration.
*
* @param cfg Handle to the TALER configuration
* @return GNUNET_OK on success, GNUNET_SYSERR if unknown extensions were found
* @return #GNUNET_OK on success, #GNUNET_SYSERR if unknown extensions were found
* or any particular configuration couldn't be parsed.
*/
enum GNUNET_GenericReturnValue

File diff suppressed because it is too large Load Diff

View File

@ -558,6 +558,18 @@ char *
TALER_age_mask_to_string (
const struct TALER_AgeMask *mask);
/*
* @brief returns the age group of a given age for a given age mask
*
* @param mask Age mask
* @param age The given age
* @return age group
*/
uint8_t
TALER_get_age_group (
const struct TALER_AgeMask *mask,
uint8_t age);
/**
* @brief Parses a JSON object { "age_groups": "a:b:...y:z" }.
*
@ -570,6 +582,18 @@ TALER_JSON_parse_age_groups (const json_t *root,
struct TALER_AgeMask *mask);
/* @brief Return the lowest age in the corresponding group for a given age
* according the given age mask.
*
* @param[IN] mask age mask
* @param[IN] age age to check
* @return lowest age in corresponding age group
*/
uint8_t
TALER_get_lowest_age (
const struct TALER_AgeMask *mask,
uint8_t age);
/**
* Handle to an external process that will assist
* with some JSON-to-JSON conversion.

View File

@ -102,7 +102,7 @@ struct TALER_AUDITOR_Handle
void *version_cb_cls;
/**
* Data for the request to get the /version of a auditor,
* Data for the request to get the /config of a auditor,
* NULL once we are past stage #MHS_INIT.
*/
struct GNUNET_CURL_Job *vr;
@ -113,12 +113,12 @@ struct TALER_AUDITOR_Handle
char *vr_url;
/**
* Task for retrying /version request.
* Task for retrying /config request.
*/
struct GNUNET_SCHEDULER_Task *retry_task;
/**
* /version data of the auditor, only valid if
* /config data of the auditor, only valid if
* @e handshake_complete is past stage #MHS_VERSION.
*/
char *version;
@ -129,7 +129,7 @@ struct TALER_AUDITOR_Handle
struct TALER_AUDITOR_VersionInformation vi;
/**
* Retry /version frequency.
* Retry /config frequency.
*/
struct GNUNET_TIME_Relative retry_delay;
@ -141,10 +141,10 @@ struct TALER_AUDITOR_Handle
};
/* ***************** Internal /version fetching ************* */
/* ***************** Internal /config fetching ************* */
/**
* Decode the JSON in @a resp_obj from the /version response and store the data
* Decode the JSON in @a resp_obj from the /config response and store the data
* in the @a key_data.
*
* @param[in] resp_obj JSON object to parse
@ -216,16 +216,16 @@ decode_version_json (const json_t *resp_obj,
/**
* Initiate download of /version from the auditor.
* Initiate download of /config from the auditor.
*
* @param cls auditor where to download /version from
* @param cls auditor where to download /config from
*/
static void
request_version (void *cls);
/**
* Callback used when downloading the reply to a /version request
* Callback used when downloading the reply to a /config request
* is complete.
*
* @param cls the `struct TALER_AUDITOR_Handle`
@ -267,7 +267,7 @@ version_completed_cb (void *cls,
if (NULL == resp_obj)
{
GNUNET_break_op (0);
TALER_LOG_WARNING ("NULL body for a 200-OK /version\n");
TALER_LOG_WARNING ("NULL body for a 200-OK /config\n");
hr.http_status = 0;
hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
@ -295,7 +295,7 @@ version_completed_cb (void *cls,
if (MHD_HTTP_OK != response_code)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"/version failed for auditor %s: %u!\n",
"/config failed for auditor %s: %u!\n",
auditor->url,
(unsigned int) response_code);
auditor->state = MHS_FAILED;
@ -309,7 +309,7 @@ version_completed_cb (void *cls,
TALER_LOG_DEBUG ("Switching auditor state to 'version'\n");
auditor->state = MHS_VERSION;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Auditor %s is now READY!\n",
"Auditor %s is ready!\n",
auditor->url);
/* notify application about the key information */
auditor->version_cb (auditor->version_cb_cls,
@ -320,9 +320,9 @@ version_completed_cb (void *cls,
/**
* Initiate download of /version from the auditor.
* Initiate download of /config from the auditor.
*
* @param cls auditor where to download /version from
* @param cls auditor where to download /config from
*/
static void
request_version (void *cls)
@ -406,7 +406,7 @@ TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
auditor->ctx = ctx;
auditor->url = GNUNET_strdup (url);
auditor->vr_url = TALER_AUDITOR_path_to_url_ (auditor,
"/version");
"/config");
if (NULL == auditor->vr_url)
{
GNUNET_break (0);

View File

@ -1268,14 +1268,24 @@ TALER_EXCHANGE_set_last_denom (struct TALER_EXCHANGE_Handle *exchange,
struct GNUNET_TIME_Timestamp
TALER_EXCHANGE_check_keys_current (struct TALER_EXCHANGE_Handle *exchange,
enum TALER_EXCHANGE_CheckKeysFlags flags)
enum TALER_EXCHANGE_CheckKeysFlags flags,
TALER_EXCHANGE_CertificationCallback cb,
void *cb_cls)
{
bool force_download = 0 != (flags & TALER_EXCHANGE_CKF_FORCE_DOWNLOAD);
bool pull_all_keys = 0 != (flags & TALER_EXCHANGE_CKF_PULL_ALL_KEYS);
if ( (NULL != cb) &&
( (exchange->cert_cb != cb) ||
(exchange->cert_cb_cls != cb_cls) ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Changing target of exchange certification callback\n");
exchange->cert_cb = cb;
exchange->cert_cb_cls = cb_cls;
}
if (NULL != exchange->kr)
return GNUNET_TIME_UNIT_ZERO_TS;
if (pull_all_keys)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@ -2269,7 +2279,9 @@ const struct TALER_EXCHANGE_Keys *
TALER_EXCHANGE_get_keys (struct TALER_EXCHANGE_Handle *exchange)
{
(void) TALER_EXCHANGE_check_keys_current (exchange,
TALER_EXCHANGE_CKF_NONE);
TALER_EXCHANGE_CKF_NONE,
NULL,
NULL);
return &exchange->key_data;
}
@ -2278,7 +2290,9 @@ json_t *
TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange)
{
(void) TALER_EXCHANGE_check_keys_current (exchange,
TALER_EXCHANGE_CKF_NONE);
TALER_EXCHANGE_CKF_NONE,
NULL,
NULL);
return json_deep_copy (exchange->key_data_raw);
}

View File

@ -46,3 +46,12 @@ test_exchange_api_twisted_cs
test_exchange_api_twisted_rsa
test_exchange_p2p_cs
test_exchange_p2p_rsa
*.edited
tmp-last-response.*
test_exchange_api_home/taler/auditor/
test_exchange_api_home/taler/exchange-offline/secm_tofus.pub
test_exchange_api_home/taler/exchange-secmod-cs/
test_exchange_api_home/taler/exchange-secmod-eddsa/
test_exchange_api_home/taler/exchange-secmod-rsa/
test_exchange_api_keys_cherry_picking_home/taler/
test_taler_exchange_httpd_home/taler/

View File

@ -13,6 +13,9 @@ endif
clean-local:
rm -rf report*
bin_SCRIPTS = \
taler-unified-setup.sh
# Libraries
lib_LTLIBRARIES = \
@ -54,11 +57,11 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_batch.c \
testing_api_cmd_batch_deposit.c \
testing_api_cmd_batch_withdraw.c \
testing_api_cmd_change_auth.c \
testing_api_cmd_check_aml_decision.c \
testing_api_cmd_check_aml_decisions.c \
testing_api_cmd_check_keys.c \
testing_api_cmd_common.c \
testing_api_cmd_connect_with_state.c \
testing_api_cmd_contract_get.c \
testing_api_cmd_deposit.c \
testing_api_cmd_deposits_get.c \
@ -70,6 +73,8 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_exec_transfer.c \
testing_api_cmd_exec_wget.c \
testing_api_cmd_exec_wirewatch.c \
testing_api_cmd_get_auditor.c \
testing_api_cmd_get_exchange.c \
testing_api_cmd_insert_deposit.c \
testing_api_cmd_kyc_check_get.c \
testing_api_cmd_kyc_proof.c \
@ -85,7 +90,6 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_purse_deposit.c \
testing_api_cmd_purse_get.c \
testing_api_cmd_purse_merge.c \
testing_api_cmd_set_wire_fee.c \
testing_api_cmd_recoup.c \
testing_api_cmd_recoup_refresh.c \
testing_api_cmd_refund.c \
@ -101,12 +105,14 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_revoke.c \
testing_api_cmd_revoke_denom_key.c \
testing_api_cmd_revoke_sign_key.c \
testing_api_cmd_rewind.c \
testing_api_cmd_run_fakebank.c \
testing_api_cmd_serialize_keys.c \
testing_api_cmd_set_officer.c \
testing_api_cmd_set_wire_fee.c \
testing_api_cmd_signal.c \
testing_api_cmd_sleep.c \
testing_api_cmd_stat.c \
testing_api_cmd_system_start.c \
testing_api_cmd_take_aml_decision.c \
testing_api_cmd_transfer_get.c \
testing_api_cmd_wait.c \
@ -114,14 +120,15 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_wire_add.c \
testing_api_cmd_wire_del.c \
testing_api_cmd_withdraw.c \
testing_api_helpers_auditor.c \
testing_api_helpers_bank.c \
testing_api_helpers_exchange.c \
testing_api_loop.c \
testing_api_misc.c \
testing_api_traits.c
libtalertesting_la_LIBADD = \
$(top_builddir)/src/lib/libtalerauditor.la \
$(top_builddir)/src/lib/libtalerexchange.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/mhd/libtalermhd.la \
$(top_builddir)/src/util/libtalerutil.la \
@ -140,15 +147,16 @@ libtalertesting_la_LIBADD = \
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
# removed for now, due to bug(s) in libeufin!
noinst_PROGRAMS = \
test_bank_api_with_nexus
.NOTPARALLEL:
check_PROGRAMS = \
test_auditor_api_cs \
test_auditor_api_rsa \
test_auditor_api_version_rsa \
test_auditor_api_version_cs \
test_auditor_api_version \
test_bank_api_with_fakebank \
test_bank_api_with_nexus \
test_exchange_api_cs \
test_exchange_api_rsa \
test_exchange_api_keys_cherry_picking_cs \
@ -211,22 +219,9 @@ test_auditor_api_rsa_LDADD = \
$(XLIB)
test_auditor_api_version_cs_SOURCES = \
test_auditor_api_version_SOURCES = \
test_auditor_api_version.c
test_auditor_api_version_cs_LDADD = \
libtalertesting.la \
$(top_builddir)/src/lib/libtalerauditor.la \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunettesting \
-lgnunetcurl \
-lgnunetutil \
-ljansson \
$(XLIB)
test_auditor_api_version_rsa_SOURCES = \
test_auditor_api_version.c
test_auditor_api_version_rsa_LDADD = \
test_auditor_api_version_LDADD = \
libtalertesting.la \
$(top_builddir)/src/lib/libtalerauditor.la \
$(LIBGCRYPT_LIBS) \
@ -241,7 +236,7 @@ test_bank_api_with_nexus_SOURCES = \
test_bank_api.c
test_bank_api_with_nexus_LDADD = \
libtalertesting.la \
-ltalerexchange \
$(top_builddir)/src/lib/libtalerexchange.la \
-lgnunetutil \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(XLIB)
@ -250,7 +245,7 @@ test_bank_api_with_fakebank_SOURCES = \
test_bank_api.c
test_bank_api_with_fakebank_LDADD = \
libtalertesting.la \
-ltalerexchange \
$(top_builddir)/src/lib/libtalerexchange.la \
-lgnunetutil \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(XLIB)
@ -542,10 +537,14 @@ test_kyc_api_LDADD = \
# Distribution
EXTRA_DIST = \
$(bin_SCRIPTS) \
coins-cs.conf \
coins-rsa.conf \
test_auditor_api-cs.conf \
test_auditor_api-rsa.conf \
test_auditor_api_expire_reserve_now-cs.conf \
test_auditor_api_expire_reserve_now-rsa.conf \
test_bank_api.conf \
test_bank_api_fakebank.conf \
test_bank_api_fakebank_twisted.conf \
test_bank_api_nexus.conf \

118
src/testing/coins-cs.conf Normal file
View File

@ -0,0 +1,118 @@
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_1_age_restricted]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_ct_10_age_restricted]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_1_age_restricted]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_5_age_restricted]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_10_age_restricted]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS

128
src/testing/coins-rsa.conf Normal file
View File

@ -0,0 +1,128 @@
# This file is in the public domain.
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_ct_1_age_restricted]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_ct_10_age_restricted]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_1_age_restricted]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_5_age_restricted]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_10_age_restricted]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA

View File

@ -57,16 +57,21 @@ START_AUDITOR=0
START_BACKUP=0
START_EXCHANGE=0
START_FAKEBANK=0
START_AGGREGATOR=0
START_MERCHANT=0
START_NEXUS=0
START_SANDBOX=0
START_TRANSFER=0
START_WIREWATCH=0
USE_ACCOUNT="exchange-account-1"
USE_VALGRIND=""
WIRE_DOMAIN="x-taler-bank"
CONF_ORIG="~/.config/taler.conf"
LOGLEVEL="DEBUG"
DEFAULT_SLEEP="0.2"
# Parse command-line options
while getopts ':abc:efhl:mnsv' OPTION; do
while getopts ':abc:d:efghl:mnr:stu:vw' OPTION; do
case "$OPTION" in
a)
START_AUDITOR="1"
@ -77,6 +82,9 @@ while getopts ':abc:efhl:mnsv' OPTION; do
c)
CONF_ORIG="$OPTARG"
;;
c)
WIRE_DOMAIN="$OPTARG"
;;
e)
START_EXCHANGE="1"
;;
@ -88,16 +96,24 @@ while getopts ':abc:efhl:mnsv' OPTION; do
echo ' -a -- start auditor'
echo ' -b -- start backup/sync'
echo ' -c $CONF -- set configuration'
echo ' -d $METHOD -- use wire method (default: x-taler-bank)'
echo ' -e -- start exchange'
echo ' -f -- start fakebank'
echo ' -h -- print this help'
echo ' -l $LOGLEVEL -- set log level'
echo ' -m -- start merchant'
echo ' -n -- start nexus'
echo ' -r $MEX -- which exchange to use at the merchant (optional)'
echo ' -s -- start sandbox'
echo ' -t -- start transfer'
echo ' -u $SECTION -- exchange account to use'
echo ' -v -- use valgrind'
echo ' -w -- start wirewatch'
exit 0
;;
g)
START_AGGREGATOR="1"
;;
l)
LOGLEVEL="$OPTARG"
;;
@ -107,13 +123,25 @@ while getopts ':abc:efhl:mnsv' OPTION; do
n)
START_NEXUS="1"
;;
r)
USE_MERCHANT_EXCHANGE="$OPTARG"
;;
s)
START_SANDBOX="1"
;;
t)
START_TRANSFER="1"
;;
u)
USE_ACCOUNT="$OPTARG"
;;
v)
USE_VALGRIND="valgrind --leak-check=yes"
DEFAULT_SLEEP="2"
;;
w)
START_WIREWATCH="1"
;;
?)
exit_fail "Unrecognized command line option"
;;
@ -156,6 +184,12 @@ then
echo " FOUND"
fi
# FIXME-MS: when run twice using
# taler-unified-setup.sh -c test_bank_api_nexus.conf -ns
# libeufin fails with a 502 failure (sandbox happy, nexus dies) below.
# Work-around is to delete the database every time. Very unclean. => needs a fix!
rm -f *.sqlite3
EXCHANGE_URL=$(taler-config -c "$CONF" -s "EXCHANGE" -o "BASE_URL")
CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY")
@ -235,7 +269,7 @@ then
export LIBEUFIN_SANDBOX_USERNAME="exchange"
export LIBEUFIN_SANDBOX_PASSWORD="x"
EXCHANGE_PAYTO=$(libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri')
taler-config -c "$CONF" -s exchange-account-1 -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
echo " OK"
echo -n "Setting this exchange as the bank's default ..."
@ -305,6 +339,7 @@ then
export LIBEUFIN_NEXUS_USERNAME=exchange
export LIBEUFIN_NEXUS_PASSWORD=x
echo -n "Creating a EBICS connection at Nexus ..."
# FIXME-MS: '||true' should be removed after we make 'new-ebics-connection' idempotent!
libeufin-cli connections new-ebics-connection \
--ebics-url "http://localhost:$SANDBOX_PORT/ebicsweb" \
--host-id talerebics \
@ -314,7 +349,7 @@ then
echo "OK"
echo -n "Setup EBICS keying ..."
libeufin-cli connections connect talerconn > /dev/null
libeufin-cli connections connect talerconn
echo "OK"
echo -n "Download bank account name from Sandbox ..."
libeufin-cli connections download-bank-accounts talerconn
@ -364,13 +399,16 @@ fi
if [ "1" = "$START_EXCHANGE" ]
then
echo -n "Starting exchange ..."
EXCHANGE_PORT=$(taler-config -c "$CONF" -s EXCHANGE -o PORT)
EXCHANGE_URL="http://localhost:${EXCHANGE_PORT}/"
MASTER_PRIV_FILE=$(taler-config -f -c "${CONF}" -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE")
MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE")
mkdir -p "${MASTER_PRIV_DIR}"
if [ ! -e "$MASTER_PRIV_FILE" ]
then
gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null 2> /dev/null
echo -n "."
fi
MASTER_PUB=$(gnunet-ecc -p "${MASTER_PRIV_FILE}")
MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)
if [ "$MPUB" != "$MASTER_PUB" ]
@ -378,16 +416,34 @@ then
echo -n " patching master_pub ($MASTER_PUB)..."
taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB"
fi
taler-exchange-dbinit -c "$CONF"
taler-exchange-dbinit -c "$CONF" --reset
$USE_VALGRIND taler-exchange-secmod-eddsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-eddsa.log &
$USE_VALGRIND taler-exchange-secmod-rsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-rsa.log &
$USE_VALGRIND taler-exchange-secmod-cs -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-cs.log &
$USE_VALGRIND taler-exchange-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-httpd.log &
EXCHANGE_HTTPD_PID=$!
echo " DONE"
fi
if [ "1" = "$START_WIREWATCH" ]
then
echo -n "Starting wirewatch ..."
$USE_VALGRIND taler-exchange-wirewatch -c "$CONF" 2> taler-exchange-wirewatch.log &
WIREWATCH_PID=$!
echo " DONE"
fi
if [ "1" = "$START_AGGREGATOR" ]
then
echo -n "Starting aggregator ..."
$USE_VALGRIND taler-exchange-aggregator -c "$CONF" 2> taler-exchange-aggregator.log &
AGGREGATOR_PID=$!
echo " DONE"
fi
if [ "1" = "$START_TRANSFER" ]
then
echo -n "Starting transfer ..."
$USE_VALGRIND taler-exchange-transfer -c "$CONF" 2> taler-exchange-transfer.log &
TRANSFER_PID=$!
echo " DONE"
@ -396,16 +452,19 @@ fi
if [ "1" = "$START_MERCHANT" ]
then
echo -n "Starting merchant ..."
MEPUB=$(taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY)
if [ ! -z "${USE_MERCHANT_EXCHANGE+x}" ]
then
MEPUB=$(taler-config -c "$CONF" -s "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY)
MXPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
if [ "$MEPUB" != "$MXPUB" ]
then
echo -n " patching master_pub ($MXPUB)..."
taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY -V "$MXPUB"
taler-config -c "$CONF" -s "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY -V "$MXPUB"
fi
fi
MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
MERCHANT_URL="http://localhost:${MERCHANT_PORT}/"
taler-merchant-dbinit -c "$CONF"
taler-merchant-dbinit -c "$CONF" -L "$LOGLEVEL" --reset &> taler-merchant-dbinit.log
$USE_VALGRIND taler-merchant-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-httpd.log &
MERCHANT_HTTPD_PID=$!
$USE_VALGRIND taler-merchant-webhook -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-webhook.log &
@ -418,7 +477,7 @@ then
echo -n "Starting sync ..."
SYNC_PORT=$(taler-config -c "$CONF" -s SYNC -o PORT)
SYNC_URL="http://localhost:${SYNC_PORT}/"
sync-dbinit -c "$CONF"
sync-dbinit -c "$CONF" --reset
$USE_VALGRIND sync-httpd -c "$CONF" -L "$LOGLEVEL" 2> sync-httpd.log &
echo " DONE"
fi
@ -427,14 +486,18 @@ fi
if [ "1" = "$START_AUDITOR" ]
then
echo -n "Starting auditor ..."
AUDITOR_URL="http://localhost:8083/"
AUDITOR_URL=$(taler-config -c "$CONF" -s AUDITOR -o BASE_URL)
AUDITOR_PRIV_FILE=$(taler-config -f -c "$CONF" -s AUDITOR -o AUDITOR_PRIV_FILE)
AUDITOR_PRIV_DIR=$(dirname "$AUDITOR_PRIV_FILE")
mkdir -p "$AUDITOR_PRIV_DIR"
if [ ! -e "$AUDITOR_PRIV_FILE" ]
then
gnunet-ecc -g1 "$AUDITOR_PRIV_FILE" > /dev/null 2> /dev/null
echo -n "."
fi
AUDITOR_PUB=$(gnunet-ecc -p "${AUDITOR_PRIV_FILE}")
MAPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
taler-auditor-dbinit -c "$CONF"
taler-auditor-dbinit -c "$CONF" --reset
taler-auditor-exchange -c "$CONF" -m "$MAPUB" -u "$EXCHANGE_URL"
$USE_VALGRIND taler-auditor-httpd -L "$LOGLEVEL" -c "$CONF" 2> taler-auditor-httpd.log &
echo " DONE"
@ -472,20 +535,21 @@ echo -n "Waiting for Taler services ..."
# Wait for all other taler services to be available
for n in $(seq 1 20)
do
echo -n "."
sleep "$DEFAULT_SLEEP"
OK="0"
if [ "1" = "$START_EXCHANGE" ]
then
echo -n "E"
wget \
--tries=1 \
--timeout=1 \
"http://localhost:8081/config" \
"${EXCHANGE_URL}config" \
-o /dev/null \
-O /dev/null >/dev/null || continue
fi
if [ "1" = "$START_MERCHANT" ]
then
echo -n "M"
wget \
--tries=1 \
--timeout=1 \
@ -495,6 +559,7 @@ do
fi
if [ "1" = "$START_BACKUP" ]
then
echo -n "S"
wget \
--tries=1 \
--timeout=1 \
@ -504,6 +569,7 @@ do
fi
if [ "1" = "$START_AUDITOR" ]
then
echo -n "A"
wget \
--tries=1 \
--timeout=1 \
@ -553,23 +619,20 @@ then
taler-exchange-offline -c "$CONF" \
download \
sign \
wire-fee now iban "$CURRENCY:0.01" "$CURRENCY:0.01" \
wire-fee now "$WIRE_DOMAIN" "$CURRENCY:0.01" "$CURRENCY:0.01" \
global-fee now "$CURRENCY:0.01" "$CURRENCY:0.01" "$CURRENCY:0.01" 1h 1year 5 \
upload &> taler-exchange-offline.log
echo "OK"
for ASEC in $(taler-config -c "$CONF" -S | grep -i "exchange-account-")
do
ENABLED=$(taler-config -c "$CONF" -s "$ASEC" -o "ENABLE_CREDIT")
ENABLED=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "ENABLE_CREDIT")
if [ "YES" = "$ENABLED" ]
then
echo -n "Configuring bank account $ASEC ..."
EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$ASEC" -o "PAYTO_URI")
echo -n "Configuring bank account $USE_ACCOUNT ..."
EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "PAYTO_URI")
taler-exchange-offline -c "$CONF" \
enable-account "$EXCHANGE_PAYTO_URI" \
upload &> "taler-exchange-offline-account-$ASEC.log"
upload &> "taler-exchange-offline-account.log"
echo " OK"
fi
done
if [ "1" = "$START_AUDITOR" ]
then
echo -n "Enabling auditor ..."

View File

@ -1,75 +1,43 @@
# This file is in the public domain.
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_taler_exchange_httpd_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-rsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[exchange]
AML_THRESHOLD = EUR:1000000
# The DB plugin to use
DB = postgres
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# Expected base URL of the exchange. Used in wire transfers for
# the tracking API.
BASE_URL = "http://localhost:8081/"
[auditor]
BASE_URL = "http://auditor.example.com/"
PORT = 8083
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
[exchangedb]
# After how long do we close idle reserves? The exchange
# and the auditor must agree on this value. We currently
# expect it to be globally defined for the whole system,
# as there is no way for wallets to query this value. Thus,
# it is only configurable for testing, and should be treated
# as constant in production.
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
[exchangedb-postgres]
#The connection string the plugin has to use for connecting to the database
CONFIG = postgres:///talercheck
[exchangedb]
# After how long do we close idle reserves? The exchange
# and the auditor must agree on this value. We currently
# expect it to be globally defined for the whole system,
# as there is no way for wallets to query this value. Thus,
# it is only configurable for testing, and should be treated
# as constant in production.
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
# After how long do we forget about reserves? Should be above
# the legal expiration timeframe of withdrawn coins.
LEGAL_RESERVE_EXPIRATION_TIME = 7 years
[exchange-account-1]
[exchangedb-postgres]
CONFIG = postgres:///talercheck
[exchange-account-1]
# What is the account URL?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
@ -81,7 +49,6 @@ WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x
[bank]
HTTP_PORT = 8082

View File

@ -1,62 +1,41 @@
# This file is in the public domain.
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_taler_exchange_httpd_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-rsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[exchange]
AML_THRESHOLD = EUR:1000000
# The DB plugin to use
DB = postgres
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# Expected base URL of the exchange.
BASE_URL = "http://localhost:8081/"
[exchangedb]
# After how long do we close idle reserves? The exchange
# and the auditor must agree on this value. We currently
# expect it to be globally defined for the whole system,
# as there is no way for wallets to query this value. Thus,
# it is only configurable for testing, and should be treated
# as constant in production.
#
# This is THE test that requires a short reserve expiration time!
IDLE_RESERVE_EXPIRATION_TIME = 4 s
[exchangedb-postgres]
#The connection string the plugin has to use for connecting to the database
CONFIG = "postgres:///talercheck"
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
[auditor]
BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
[exchange-account-1]
# What is the account URL?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"

View File

@ -1,141 +1,4 @@
# This file is in the public domain.
#
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_exchange_api_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-cs]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[auditor]
BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083
PUBLIC_KEY = XNYZPJJ6YPSQ4C6QPW120ACG9B5E5GBTTSYWXDMDB6G4X74TDBPG
TINY_AMOUNT = EUR:0.01
[exchange]
AML_THRESHOLD = EUR:1000000
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
BASE_URL = "http://localhost:8081/"
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
# Sections starting with "exchange-account-" configure the bank accounts
# of the exchange. The "URL" specifies the account in
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
[bank]
HTTP_PORT = 8082
# ENABLE_CREDIT = YES
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
# Authentication information for basic authentication
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = user
PASSWORD = pass
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
@INLINE@ coins-cs.conf
@INLINE@ test_exchange_api.conf

View File

@ -1,147 +1,4 @@
# This file is in the public domain.
#
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_exchange_api_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-rsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[auditor]
BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083
PUBLIC_KEY = XNYZPJJ6YPSQ4C6QPW120ACG9B5E5GBTTSYWXDMDB6G4X74TDBPG
TINY_AMOUNT = EUR:0.01
[exchange]
AML_THRESHOLD = EUR:1000000
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
BASE_URL = "http://localhost:8081/"
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
# Sections starting with "exchange-account-" configure the bank accounts
# of the exchange. The "URL" specifies the account in
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
[bank]
HTTP_PORT = 8082
# ENABLE_CREDIT = YES
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
# Authentication information for basic authentication
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = user
PASSWORD = pass
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
@INLINE@ coins-rsa.conf
@INLINE@ test_exchange_api.conf

View File

@ -45,14 +45,9 @@ static char *config_file;
static char *config_file_expire_reserve_now;
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
static struct TALER_TESTING_Credentials cred;
/**
* Execute the taler-exchange-wirewatch command with
@ -83,8 +78,8 @@ static struct TALER_TESTING_BankConfiguration bc;
*/
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \
bc.user42_payto)
&cred.ba, \
cred.user42_payto)
/**
* Run the taler-auditor.
@ -116,7 +111,7 @@ run (void *cls,
"EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer
("check-create-reserve-1",
"EUR:5.01", bc.user42_payto, bc.exchange_payto,
"EUR:5.01", cred.user42_payto, cred.exchange_payto,
"create-reserve-1"),
/**
* Make a reserve exist, according to the previous transfer.
@ -140,7 +135,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-simple",
"withdraw-coin-1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -157,7 +152,7 @@ run (void *cls,
"EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer
("check-refresh-create-reserve-1",
"EUR:5.01", bc.user42_payto, bc.exchange_payto,
"EUR:5.01", cred.user42_payto, cred.exchange_payto,
"refresh-create-reserve-1"),
/**
* Make previous command effective.
@ -178,7 +173,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
"refresh-withdraw-coin-1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -203,7 +198,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
"refresh-reveal-1",
3,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:0.1",
@ -225,75 +220,75 @@ run (void *cls,
*/
TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-499c",
ec.exchange_url,
cred.exchange_url,
"EUR:4.98",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-99c1",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-99c",
ec.exchange_url,
cred.exchange_url,
"EUR:0.08",
bc.exchange_payto,
bc.user43_payto),
cred.exchange_payto,
cred.user43_payto),
/* The following transactions got originated within
* the "massive deposit confirms" batch. */
TALER_TESTING_cmd_check_bank_transfer (
"check-massive-transfer-1",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-2",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-3",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-4",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-5",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-6",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-7",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-8",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-9",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer
("check-massive-transfer-10",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto, bc.user43_payto),
cred.exchange_payto, cred.user43_payto),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
TALER_TESTING_cmd_end ()
};
@ -311,8 +306,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"check_bank_transfer-unaggregated",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-unaggregated"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
"create-reserve-unaggregated",
@ -322,7 +317,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
"withdraw-coin-unaggregated",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_YEARS,
@ -359,7 +354,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-1",
"withdraw-coin-r1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_MINUTES,
"EUR:5",
@ -376,7 +371,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-2",
"withdraw-coin-r1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:4.99",
@ -466,7 +461,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
"recoup-withdraw-coin-2a",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:0.5",
@ -493,7 +488,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"check-massive-transfer",
"EUR:10.10",
bc.user42_payto, bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"massive-reserve"),
CMD_EXEC_WIREWATCH ("massive-wirewatch"),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-1",
@ -550,7 +546,7 @@ run (void *cls,
"massive-deposit-1",
"massive-withdraw-1",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -559,7 +555,7 @@ run (void *cls,
("massive-deposit-2",
"massive-withdraw-2",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -568,7 +564,7 @@ run (void *cls,
("massive-deposit-3",
"massive-withdraw-3",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -577,7 +573,7 @@ run (void *cls,
("massive-deposit-4",
"massive-withdraw-4",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -586,7 +582,7 @@ run (void *cls,
("massive-deposit-5",
"massive-withdraw-5",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -595,7 +591,7 @@ run (void *cls,
("massive-deposit-6",
"massive-withdraw-6",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -604,7 +600,7 @@ run (void *cls,
("massive-deposit-7",
"massive-withdraw-7",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -613,7 +609,7 @@ run (void *cls,
("massive-deposit-8",
"massive-withdraw-8",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -622,7 +618,7 @@ run (void *cls,
("massive-deposit-9",
"massive-withdraw-9",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -631,13 +627,12 @@ run (void *cls,
"massive-deposit-10",
"massive-withdraw-10",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
MHD_HTTP_OK),
TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation",
is->auditor,
"massive-deposit-10",
0,
"EUR:0.99",
@ -648,21 +643,22 @@ run (void *cls,
};
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-2"),
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"EUR:0.01",
"EUR:0.01"),
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
2),
"-u", "exchange-account-2",
"-ae",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_get_auditor ("get-auditor",
cred.cfg,
true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_exec_auditor_offline ("auditor-offline",
config_file),
CMD_RUN_AUDITOR ("virgin-auditor"),
@ -690,9 +686,8 @@ run (void *cls,
};
(void) cls;
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
commands);
}
@ -700,15 +695,9 @@ int
main (int argc,
char *const *argv)
{
char *cipher;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
{
char *cipher;
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
@ -719,41 +708,15 @@ main (int argc,
"test_auditor_api_expire_reserve_now-%s.conf",
cipher);
GNUNET_free (cipher);
/* Check fakebank port is available and get configuration data. */
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_file,
"exchange-account-2",
&bc))
return 77;
TALER_TESTING_cleanup_files (config_file);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 78;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_auditor_setup (&run,
NULL,
config_file))
return 2;
break;
default:
GNUNET_break (0);
return 3;
}
return 0;
return TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2014-2018 Taler Systems SA
Copyright (C) 2014-2023 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
@ -39,7 +39,7 @@
* Configuration file we use. One (big) configuration is used
* for the various components for this test.
*/
#define CONFIG_FILE "test_auditor_api.conf"
#define CONFIG_FILE "test_auditor_api-rsa.conf"
static struct TALER_AUDITOR_Handle *ah;
@ -51,6 +51,7 @@ static int global_ret;
static struct GNUNET_SCHEDULER_Task *tt;
static void
do_shutdown (void *cls)
{
@ -148,15 +149,16 @@ main (int argc,
"taler-auditor-httpd",
"taler-auditor-httpd",
"-c", CONFIG_FILE,
"-L", "INFO",
NULL);
if (NULL == proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to run `taler-auditor-httpd`,"
" is your PATH correct?\n");
"Failed to run `taler-auditor-httpd`, is your PATH correct?\n");
return 77;
}
if (0 != TALER_TESTING_wait_auditor_ready ("http://localhost:8083/"))
global_ret = TALER_TESTING_wait_httpd_ready ("http://localhost:8083/");
if (0 != global_ret)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to launch `taler-auditor-httpd`\n");
@ -166,7 +168,8 @@ main (int argc,
GNUNET_SCHEDULER_run (&run,
NULL);
}
GNUNET_OS_process_kill (proc, SIGTERM);
GNUNET_OS_process_kill (proc,
SIGTERM);
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc);
return global_ret;

View File

@ -34,6 +34,7 @@
#include "taler_testing_lib.h"
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank.conf"
#define CONFIG_FILE_NEXUS "test_bank_api_nexus.conf"
@ -41,28 +42,19 @@
* Configuration file. It changes based on
* whether Nexus or Fakebank are used.
*/
const char *cfgfile;
static const char *cfgfile;
/**
* Bank configuration data.
* Our credentials.
*/
static struct TALER_TESTING_BankConfiguration bc;
static struct TALER_TESTING_Credentials cred;
/**
* Flag indicating whether the test is running against the
* Fakebank. Set up at runtime.
* Which bank is the test running against?
* Set up at runtime.
*/
static int with_fakebank;
static enum TALER_TESTING_BankSystem bs;
/**
* Handles to the libeufin services.
*/
static struct TALER_TESTING_LibeufinServices libeufin_services;
/**
* Needed to shutdown differently.
*/
static int with_libeufin;
/**
* Main function that will tell the interpreter what commands to
@ -75,20 +67,36 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_WireTransferIdentifierRawP wtid;
const char *ssoptions;
(void) cls;
memset (&wtid, 42, sizeof (wtid));
switch (bs)
{
case TALER_TESTING_BS_FAKEBANK:
ssoptions = "-f";
break;
case TALER_TESTING_BS_IBAN:
ssoptions = "-ns";
break;
}
memset (&wtid,
42,
sizeof (wtid));
{
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_system_start ("start-taler",
cfgfile,
ssoptions,
NULL),
TALER_TESTING_cmd_bank_credits ("history-0",
&bc.exchange_auth,
&cred.ba,
NULL,
1),
TALER_TESTING_cmd_admin_add_incoming ("credit-1",
"KUDOS:5.01",
&bc.exchange_auth,
bc.user42_payto),
"EUR:5.01",
&cred.ba,
cred.user42_payto),
/**
* This CMD doesn't care about the HTTP response code; that's
* because Fakebank and euFin behaves differently when a reserve
@ -96,9 +104,9 @@ run (void *cls,
* with 200 but it bounces the payment back to the customer.
*/
TALER_TESTING_cmd_admin_add_incoming_with_ref ("credit-1-fail",
"KUDOS:2.01",
&bc.exchange_auth,
bc.user42_payto,
"EUR:2.01",
&cred.ba,
cred.user42_payto,
"credit-1",
-1),
TALER_TESTING_cmd_sleep ("Waiting 4s for 'credit-1' to settle",
@ -108,28 +116,28 @@ run (void *cls,
* reserve public key didn't make it to the exchange.
*/
TALER_TESTING_cmd_bank_credits ("history-1c",
&bc.exchange_auth,
&cred.ba,
NULL,
5),
TALER_TESTING_cmd_bank_debits ("history-1d",
&bc.exchange_auth,
&cred.ba,
NULL,
5),
TALER_TESTING_cmd_admin_add_incoming ("credit-2",
"KUDOS:3.21",
&bc.exchange_auth,
bc.user42_payto),
"EUR:3.21",
&cred.ba,
cred.user42_payto),
TALER_TESTING_cmd_transfer ("debit-1",
"KUDOS:3.22",
&bc.exchange_auth,
bc.exchange_payto,
bc.user42_payto,
"EUR:3.22",
&cred.ba,
cred.exchange_payto,
cred.user42_payto,
&wtid,
"http://exchange.example.com/"),
TALER_TESTING_cmd_sleep ("Waiting 5s for 'debit-1' to settle",
5),
with_libeufin
(bs == TALER_TESTING_BS_IBAN)
? TALER_TESTING_cmd_nexus_fetch_transactions (
"fetch-transactions-at-nexus",
"exchange", /* from taler-nexus-prepare */
@ -139,7 +147,7 @@ run (void *cls,
: TALER_TESTING_cmd_sleep ("nop",
0),
TALER_TESTING_cmd_bank_debits ("history-2b",
&bc.exchange_auth,
&cred.ba,
NULL,
5),
TALER_TESTING_cmd_end ()
@ -147,116 +155,44 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Bank serves at `%s'\n",
bc.exchange_auth.wire_gateway_url);
if (GNUNET_YES == with_fakebank)
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
else
cred.ba.wire_gateway_url);
TALER_TESTING_run (is,
commands);
}
}
/**
* Runs #TALER_TESTING_setup() using the configuration.
*
* @param cls unused
* @param cfg configuration to use
* @return status code
*/
static int
setup_with_cfg (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
(void) cls;
return TALER_TESTING_setup (&run,
NULL,
cfg,
NULL,
GNUNET_NO);
}
int
main (int argc,
char *const *argv)
{
int rv;
(void) argc;
(void) argv;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test-bank-api",
"INFO",
NULL);
with_fakebank = TALER_TESTING_has_in_name (argv[0],
"_with_fakebank");
if (GNUNET_YES == with_fakebank)
if (TALER_TESTING_has_in_name (argv[0],
"_with_fakebank"))
{
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
bs = TALER_TESTING_BS_FAKEBANK;
cfgfile = CONFIG_FILE_FAKEBANK;
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (CONFIG_FILE_FAKEBANK,
"exchange-account-2",
&bc))
{
GNUNET_break (0);
return 77;
}
}
else if (GNUNET_YES == TALER_TESTING_has_in_name (argv[0],
else if (TALER_TESTING_has_in_name (argv[0],
"_with_nexus"))
{
TALER_LOG_DEBUG ("Running with Nexus.\n");
with_libeufin = GNUNET_YES;
bs = TALER_TESTING_BS_IBAN;
cfgfile = CONFIG_FILE_NEXUS;
if (GNUNET_OK !=
TALER_TESTING_prepare_libeufin (CONFIG_FILE_NEXUS,
GNUNET_YES,
"exchange-account-2",
&bc))
}
else
{
/* no bank service was specified. */
GNUNET_break (0);
return 77;
}
libeufin_services = TALER_TESTING_run_libeufin (&bc);
if ( (NULL == libeufin_services.nexus) ||
(NULL == libeufin_services.sandbox) )
return 77;
}
else
{
/* no bank service was ever invoked. */
return 77;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_parse_and_run (cfgfile,
&setup_with_cfg,
NULL))
rv = 1;
else
rv = 0;
if (with_libeufin)
{
GNUNET_OS_process_kill (libeufin_services.nexus,
SIGKILL);
GNUNET_OS_process_wait (libeufin_services.nexus);
GNUNET_OS_process_destroy (libeufin_services.nexus);
GNUNET_OS_process_kill (libeufin_services.sandbox,
SIGKILL);
GNUNET_OS_process_wait (libeufin_services.sandbox);
GNUNET_OS_process_destroy (libeufin_services.sandbox);
}
return rv;
return TALER_TESTING_main (argv,
"INFO",
cfgfile,
"exchange-account-2",
bs,
&cred,
&run,
NULL);
}

View File

@ -0,0 +1,13 @@
# This file is in the public domain
[PATHS]
TALER_TEST_HOME = test_exchange_api_home/
[taler]
currency = EUR
[bank]
# not (!) used by the nexus, only by the helper
# check to make sure the port is free for Nexus.
SERVE = http
HTTP_PORT = 8082

View File

@ -1,21 +1,14 @@
# This file is in the public domain.
@INLINE@ test_bank_api.conf
[taler]
currency = KUDOS
[exchange-account-1]
PAYTO_URI = "payto://x-taler-bank/localhost:8082/1?receiver-name=1"
[exchange-account-2]
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
PAYTO_URI = "payto://x-taler-bank/localhost:8082/2?receiver-name=2"
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8081/2/"
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x
[bank]
SERVE = http
HTTP_PORT = 8081
DATABASE = postgres:///talercheck
[auditor]
BASE_URL = "http://localhost:8083/"

View File

@ -1,12 +1,15 @@
# This file is in the public domain.
@INLINE@ test_bank_api_fakebank.conf
[twister]
# HTTP listen port for twister
HTTP_PORT = 8888
SERVE = tcp
# HTTP Destination for twister. The test-Webserver needs
# to listen on the port used here. Note: no trailing '/'!
DESTINATION_BASE_URL = "http://localhost:8081"
DESTINATION_BASE_URL = "http://localhost:8082"
# Control port for TCP
# PORT = 8889
@ -18,20 +21,3 @@ ACCEPT_FROM6 = ::1;
UNIXPATH = /tmp/taler-service-twister.sock
UNIX_MATCH_UID = NO
UNIX_MATCH_GID = YES
[taler]
currency = KUDOS
[bank]
serve = http
http_port = 8081
database = postgres:///talercheck
[exchange-account-1]
PAYTO_URI = "payto://x-taler-bank/localhost:8081/1?receiver-name=1"
[exchange-account-2]
PAYTO_URI = "payto://x-taler-bank/localhost:8081/2?receiver-name=2"
[auditor]
BASE_URL = "http://localhost:8083/"

View File

@ -1,21 +1,19 @@
# This file is in the public domain.
[taler]
currency = TESTKUDOS
@INLINE@ test_bank_api.conf
[exchange-account-2]
PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = http://localhost:5001/facades/my-facade/taler-wire-gateway/
WIRE_GATEWAY_URL = http://localhost:8082/facades/test-facade/taler-wire-gateway/
WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = exchange
PASSWORD = x
[bank]
# not (!) used by the nexus, only by the helper
# check to make sure the port is free for Nexus.
HTTP_PORT = 5001
[libeufin-nexus]
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
[auditor]
BASE_URL = "http://localhost:8083/"
[libeufin-sandbox]
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2014-2018 Taler Systems SA
Copyright (C) 2014-2023 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
@ -17,7 +17,7 @@
<http://www.gnu.org/licenses/>
*/
/**
* @file testing/test_bank_api_with_fakebank_twisted.c
* @file testing/test_bank_api_twisted.c
* @author Marcello Stanisci
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Christian Grothoff
@ -42,14 +42,20 @@
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank_twisted.conf"
/**
* True when the test runs against Fakebank.
* Configuration file we use.
*/
static int with_fakebank;
static const char *cfgfile;
/**
* Bank configuration data.
* Our credentials.
*/
static struct TALER_TESTING_BankConfiguration bc;
static struct TALER_TESTING_Credentials cred;
/**
* Which bank is the test running against?
* Set up at runtime.
*/
static enum TALER_TESTING_BankSystem bs;
/**
* (real) Twister URL. Used at startup time to check if it runs.
@ -61,11 +67,6 @@ static char *twister_url;
*/
static struct GNUNET_OS_Process *twisterd;
/**
* Python bank process handle.
*/
static struct GNUNET_OS_Process *bankd;
/**
* Main function that will tell
@ -78,156 +79,118 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_WireTransferIdentifierRawP wtid;
/* Route our commands through twister. */
/* Authentication data to route our commands through twister. */
struct TALER_BANK_AuthenticationData exchange_auth_twisted;
const char *systype = NULL;
(void) cls;
memset (&wtid,
0x5a,
sizeof (wtid));
GNUNET_memcpy (&exchange_auth_twisted,
&bc.exchange_auth,
&cred.ba,
sizeof (struct TALER_BANK_AuthenticationData));
if (with_fakebank)
exchange_auth_twisted.wire_gateway_url =
"http://localhost:8888/2/";
else
exchange_auth_twisted.wire_gateway_url =
"http://localhost:8888/taler-wire-gateway/Exchange/";
switch (bs)
{
case TALER_TESTING_BS_FAKEBANK:
exchange_auth_twisted.wire_gateway_url
= "http://localhost:8888/2/";
systype = "-f";
break;
case TALER_TESTING_BS_IBAN:
exchange_auth_twisted.wire_gateway_url
= "http://localhost:8888/taler-wire-gateway/Exchange/";
systype = "-ns";
break;
}
GNUNET_assert (NULL != systype);
{
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_system_start ("start-taler",
cfgfile,
systype,
NULL),
/* Test retrying transfer after failure. */
TALER_TESTING_cmd_malform_response ("malform-transfer",
CONFIG_FILE_FAKEBANK),
cfgfile),
TALER_TESTING_cmd_transfer_retry (
TALER_TESTING_cmd_transfer ("debit-1",
"KUDOS:3.22",
"EUR:3.22",
&exchange_auth_twisted,
bc.exchange_payto,
bc.user42_payto,
cred.exchange_payto,
cred.user42_payto,
&wtid,
"http://exchange.example.com/")),
TALER_TESTING_cmd_end ()
};
if (GNUNET_YES == with_fakebank)
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
else
TALER_TESTING_run (is,
commands);
}
}
/**
* Kill, wait, and destroy convenience function.
*
* @param process process to purge.
* @param[in] process process to purge.
*/
static void
purge_process (struct GNUNET_OS_Process *process)
{
GNUNET_OS_process_kill (process, SIGINT);
GNUNET_OS_process_kill (process,
SIGINT);
GNUNET_OS_process_wait (process);
GNUNET_OS_process_destroy (process);
}
/**
* Runs #TALER_TESTING_setup() using the configuration.
*
* @param cls unused
* @param cfg configuration to use
* @return status code
*/
static int
setup_with_cfg (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
(void) cls;
return TALER_TESTING_setup (&run,
NULL,
cfg,
NULL,
GNUNET_NO);
}
int
main (int argc,
char *const *argv)
{
int ret;
const char *cfgfilename;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test-bank-api-with-(fake)bank-twisted",
if (TALER_TESTING_has_in_name (argv[0],
"_with_fakebank"))
{
bs = TALER_TESTING_BS_FAKEBANK;
cfgfile = CONFIG_FILE_FAKEBANK;
}
else if (TALER_TESTING_has_in_name (argv[0],
"_with_nexus"))
{
GNUNET_assert (0); /* FIXME: test with nexus not yet implemented */
bs = TALER_TESTING_BS_IBAN;
/* cfgfile = CONFIG_FILE_NEXUS; */
}
else
{
/* no bank service was specified. */
GNUNET_break (0);
return 77;
}
/* FIXME: introduce commands for twister! */
twister_url = TALER_TWISTER_prepare_twister (cfgfile);
if (NULL == twister_url)
return 77;
twisterd = TALER_TWISTER_run_twister (cfgfile);
if (NULL == twisterd)
return 77;
ret = TALER_TESTING_main (argv,
"INFO",
NULL);
with_fakebank = TALER_TESTING_has_in_name (argv[0],
"_with_fakebank");
if (with_fakebank)
cfgfilename = CONFIG_FILE_FAKEBANK;
else
GNUNET_assert (0);
if (NULL == (twister_url = TALER_TWISTER_prepare_twister (
cfgfilename)))
{
GNUNET_break (0);
return 77;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"twister_url is %s\n",
twister_url);
if (NULL == (twisterd = TALER_TWISTER_run_twister (cfgfilename)))
{
GNUNET_break (0);
GNUNET_free (twister_url);
return 77;
}
if (GNUNET_YES == with_fakebank)
{
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (cfgfilename,
cfgfile,
"exchange-account-2",
&bc))
{
GNUNET_break (0);
GNUNET_free (twister_url);
return 77;
}
}
else
{
GNUNET_assert (0);
}
sleep (5);
ret = GNUNET_CONFIGURATION_parse_and_run (cfgfilename,
&setup_with_cfg,
bs,
&cred,
&run,
NULL);
purge_process (twisterd);
if (GNUNET_NO == with_fakebank)
{
GNUNET_OS_process_kill (bankd,
SIGKILL);
GNUNET_OS_process_wait (bankd);
GNUNET_OS_process_destroy (bankd);
}
GNUNET_free (twister_url);
if (GNUNET_OK == ret)
return 0;
return 1;
return ret;
}

View File

@ -1,120 +1,4 @@
# This file is in the public domain.
#
@INLINE@ coins-cs.conf
@INLINE@ test_exchange_api.conf
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_1_age_restricted]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_ct_10_age_restricted]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_1_age_restricted]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_5_age_restricted]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS
[coin_eur_10_age_restricted]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
age_restricted = YES
CIPHER = CS

View File

@ -1,130 +1,4 @@
# This file is in the public domain.
#
@INLINE@ test_exchange_api.conf
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_ct_1_age_restricted]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_ct_10_age_restricted]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_1_age_restricted]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_5_age_restricted]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
[coin_eur_10_age_restricted]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
age_restricted = YES
CIPHER = RSA
@INLINE@ coins-rsa.conf

View File

@ -49,14 +49,9 @@ static char *config_file;
static char *config_file_expire_reserve_now;
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
static struct TALER_TESTING_Credentials cred;
/**
* Some tests behave differently when using CS as we cannot
@ -97,8 +92,8 @@ static bool uses_cs;
*/
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \
bc.user42_payto)
&cred.ba, \
cred.user42_payto)
/**
* Main function that will tell the interpreter what commands to
@ -142,8 +137,8 @@ run (void *cls,
MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
"EUR:6.02",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-1"),
/**
* Make a reserve exist, according to the previous
@ -201,7 +196,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-simple",
"withdraw-coin-1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -219,7 +214,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure",
"withdraw-coin-1x",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -232,7 +227,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-double-1",
"withdraw-coin-1",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -246,7 +241,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-double-1",
"withdraw-coin-1",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -257,7 +252,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-double-2",
"withdraw-coin-1",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -282,8 +277,8 @@ run (void *cls,
"EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"refresh-create-reserve-1"),
/**
* Make previous command effective.
@ -304,7 +299,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
"refresh-withdraw-coin-1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -341,7 +336,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a",
"refresh-reveal-1-idempotency",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -352,7 +347,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
"refresh-reveal-1",
3,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:0.1",
@ -390,8 +385,8 @@ run (void *cls,
"EUR:6.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age",
"EUR:6.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-age"),
/**
* Make a reserve exist, according to the previous
@ -417,7 +412,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-simple-age",
"withdraw-coin-age-1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:4.99",
@ -464,53 +459,53 @@ run (void *cls,
* Check all the transfers took place.
*/
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c",
ec.exchange_url,
cred.exchange_url,
"EUR:4.98",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2",
ec.exchange_url,
cred.exchange_url,
"EUR:4.97",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c",
ec.exchange_url,
cred.exchange_url,
"EUR:0.08",
bc.exchange_payto,
bc.user43_payto),
cred.exchange_payto,
cred.user43_payto),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2",
ec.exchange_url,
cred.exchange_url,
"EUR:0.08",
bc.exchange_payto,
bc.user43_payto),
cred.exchange_payto,
cred.user43_payto),
/* In case of CS, one transaction above succeeded that
failed for RSA, hence we need to check for an extra transfer here */
uses_cs
? TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-98c",
ec.exchange_url,
cred.exchange_url,
"EUR:0.98",
bc.exchange_payto,
bc.user42_payto)
cred.exchange_payto,
cred.user42_payto)
: TALER_TESTING_cmd_sleep ("dummy",
0),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
@ -544,8 +539,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-unaggregated",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-unaggregated"),
CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
@ -556,7 +551,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
"withdraw-coin-unaggregated",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_YEARS,
@ -578,8 +573,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"ck-refresh-create-reserve-age-1",
"EUR:6.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"refresh-create-reserve-age-1"),
/**
* Make previous command effective.
@ -600,7 +595,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age",
"refresh-withdraw-coin-age-1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -637,7 +632,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a",
"refresh-reveal-age-1-idempotency",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -648,7 +643,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b",
"refresh-reveal-age-1",
3,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:0.1",
@ -680,8 +675,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-aggtest",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-aggtest"),
CMD_EXEC_WIREWATCH ("wirewatch-aggtest"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest",
@ -692,7 +687,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-aggtest-1",
"withdraw-coin-aggtest",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:2",
@ -700,7 +695,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2",
"withdraw-coin-aggtest",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:2",
@ -708,10 +703,10 @@ run (void *cls,
"deposit-aggtest-1"),
CMD_EXEC_AGGREGATOR ("aggregation-aggtest"),
TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest",
ec.exchange_url,
cred.exchange_url,
"EUR:3.97",
bc.exchange_payto,
bc.user43_payto),
cred.exchange_payto,
cred.user43_payto),
TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"),
TALER_TESTING_cmd_end ()
};
@ -725,8 +720,8 @@ run (void *cls,
"EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-r1"),
/**
* Run wire-watch to trigger the reserve creation.
@ -745,7 +740,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-1",
"withdraw-coin-r1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_MINUTES,
"EUR:5",
@ -779,7 +774,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund",
"withdraw-coin-r1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}",
GNUNET_TIME_UNIT_MINUTES,
"EUR:4",
@ -796,7 +791,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-2",
"withdraw-coin-r1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:4.99",
@ -810,10 +805,10 @@ run (void *cls,
* Check that deposit did run.
*/
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund",
ec.exchange_url,
cred.exchange_url,
"EUR:4.97",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
/**
* Run failing refund, as past deadline & aggregation.
*/
@ -830,8 +825,8 @@ run (void *cls,
"EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-rb"),
CMD_EXEC_WIREWATCH ("wirewatch-rb"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb",
@ -842,7 +837,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-refund-1b",
"withdraw-coin-rb",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -876,8 +871,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"recoup-create-reserve-1-check",
"EUR:15.02",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"recoup-create-reserve-1"),
/**
* Run wire-watch to trigger the reserve creation.
@ -1006,8 +1001,8 @@ run (void *cls,
"EUR:5.01"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"short-lived-reserve"),
TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation",
config_file_expire_reserve_now),
@ -1029,10 +1024,10 @@ run (void *cls,
0, /* age restriction off */
MHD_HTTP_CONFLICT),
TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse",
ec.exchange_url,
cred.exchange_url,
"EUR:5",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
/* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
* config, then withdraw two coin, partially spend one, and
* then have the rest paid back. Check deposit of other coin
@ -1042,8 +1037,8 @@ run (void *cls,
"EUR:2.02"),
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2",
"EUR:2.02",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"recoup-create-reserve-2"),
/* Make previous command effective. */
CMD_EXEC_WIREWATCH ("wirewatch-5"),
@ -1062,7 +1057,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
"recoup-withdraw-coin-2a",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:0.5",
@ -1090,7 +1085,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-revoked",
"recoup-withdraw-coin-2b",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -1102,7 +1097,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup",
"recoup-withdraw-coin-2a",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:0.5",
@ -1113,8 +1108,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"check-recoup-create-reserve-3",
"EUR:1.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"recoup-create-reserve-3"),
CMD_EXEC_WIREWATCH ("wirewatch-6"),
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked",
@ -1144,8 +1139,8 @@ run (void *cls,
MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1",
"EUR:6.03",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-batch-reserve-1"),
/*
* Make a reserve exist, according to the previous
@ -1184,7 +1179,7 @@ run (void *cls,
* Spend the coins.
*/
TALER_TESTING_cmd_batch_deposit ("batch-deposit-1",
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}",
GNUNET_TIME_UNIT_ZERO,
MHD_HTTP_OK,
@ -1232,33 +1227,18 @@ run (void *cls,
{
struct TALER_TESTING_Command commands[] = {
/* setup exchange */
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions",
config_file),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_global_fees (
"offline-sign-global-fees",
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-2"),
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"EUR:0.01",
"EUR:0.01",
"EUR:0.01",
GNUNET_TIME_UNIT_MINUTES,
GNUNET_TIME_UNIT_DAYS,
1),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_file),
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
config_file,
"EUR:0.01",
"EUR:0.01"),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
"-e",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_batch ("wire",
wire),
TALER_TESTING_cmd_batch ("withdraw",
@ -1291,9 +1271,8 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
commands);
}
}
@ -1302,19 +1281,14 @@ int
main (int argc,
char *const *argv)
{
char *cipher;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
{
char *cipher;
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
uses_cs = (0 == strcmp (cipher, "cs"));
uses_cs = (0 == strcmp (cipher,
"cs"));
GNUNET_asprintf (&config_file,
"test_exchange_api-%s.conf",
cipher);
@ -1322,42 +1296,15 @@ main (int argc,
"test_exchange_api_expire_reserve_now-%s.conf",
cipher);
GNUNET_free (cipher);
/* Check fakebank port is available and get config */
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_file,
"exchange-account-2",
&bc))
return 77;
TALER_TESTING_cleanup_files (config_file);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 78;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_file))
return 2;
break;
default:
GNUNET_break (0);
return 3;
}
return 0;
return TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -2,30 +2,64 @@
#
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_exchange_api_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-rsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[auditor]
BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083
PUBLIC_KEY = SA7JVMCW3MMN7SYAWJ9AB0BGJDX6MP3PNN2JWQ3T8233MDSQC7Z0
TINY_AMOUNT = EUR:0.01
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
[bank]
HTTP_PORT = 8082
[exchange]
TERMS_ETAG = 0
PRIVACY_ETAG = 0
AML_THRESHOLD = EUR:1000000
PORT = 8081
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
DB = postgres
BASE_URL = "http://localhost:8081/"
EXPIRE_SHARD_SIZE = 300 ms
EXPIRE_IDLE_SLEEP_INTERVAL = 1 s
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[taler-exchange-secmod-rsa]
LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa]
LOOKAHEAD_SIGN = 24 days
DURATION = 14 days
[exchange-account-1]
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
[exchange-account-2]
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-2]
WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
[kyc-provider-test-oauth2]
@ -48,68 +82,6 @@ REQUIRED_CHECKS = DUMMY
THRESHOLD = EUR:0
TIMEFRAME = 1d
[exchange]
TERMS_ETAG = 0
PRIVACY_ETAG = 0
AML_THRESHOLD = EUR:1000000
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
BASE_URL = "http://localhost:8081/"
# How big is an individual shard to be processed
# by taler-exchange-expire (in time). It may take
# this much time for an expired purse to be really
# cleaned up and the coins refunded.
EXPIRE_SHARD_SIZE = 300 ms
EXPIRE_IDLE_SLEEP_INTERVAL = 1 s
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
# Sections starting with "exchange-account-" configure the bank accounts
# of the exchange. The "URL" specifies the account in
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
# ENABLE_CREDIT = YES
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:9081/42/"
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-2]
WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x
WIRE_GATEWAY_URL = "http://localhost:9081/2/"
[bank]
HTTP_PORT = 9081
# Enabled extensions
[exchange-extension-age_restriction]
ENABLED = YES
# default age groups:
#AGE_GROUPS = "8:10:12:14:16:18:21"

View File

@ -0,0 +1 @@
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>

View File

@ -43,9 +43,9 @@ lished
static char *config_file;
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
static struct TALER_TESTING_Credentials cred;
/**
@ -59,27 +59,19 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"EUR:0.01",
"EUR:0.01"),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("initial-/keys",
1),
"-e",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("initial-/keys"),
TALER_TESTING_cmd_sleep ("sleep",
6 /* seconds */),
TALER_TESTING_cmd_check_keys ("check-keys-1",
2 /* generation */),
TALER_TESTING_cmd_check_keys ("check-keys-1"),
TALER_TESTING_cmd_check_keys_with_last_denom ("check-keys-2",
3 /* generation */,
"check-keys-1"),
TALER_TESTING_cmd_serialize_keys ("serialize-keys"),
TALER_TESTING_cmd_connect_with_state ("reconnect-with-state",
@ -88,8 +80,7 @@ run (void *cls,
* Make sure we have the same keys situation as
* it was before the serialization.
*/
TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization",
4),
TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization"),
/**
* Use one of the deserialized keys.
*/
@ -110,50 +101,25 @@ int
main (int argc,
char *const *argv)
{
(void) argc;
{
char *cipher;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
GNUNET_asprintf (&config_file,
"test_exchange_api_keys_cherry_picking-%s.conf",
cipher);
GNUNET_free (cipher);
TALER_TESTING_cleanup_files (config_file);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 77;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_file))
return 1;
break;
default:
GNUNET_break (0);
return 1;
}
return 0;
return TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -3,48 +3,21 @@
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_exchange_api_keys_cherry_picking_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
# Persistent data storage
TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
# Configuration files
TALER_CONFIG_HOME = $TALER_HOME/.config/taler/
# Cached data, no big deal if lost
TALER_CACHE_HOME = $TALER_HOME/.cache/taler/
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[taler-exchange-secmod-eddsa]
OVERLAP_DURATION = 1 s
DURATION = 30 s
LOOKAHEAD_SIGN = 20 s
[auditor]
BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083
[exchange]
AML_THRESHOLD = EUR:1000000
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
BASE_URL = "http://localhost:8081/"
[exchangedb-postgres]
@ -55,6 +28,8 @@ CONFIG = "postgres:///talercheck"
[exchange-account-1]
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:9082/42/"
@ -66,11 +41,9 @@ ENABLE_CREDIT = YES
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:9082/2/"
# Authentication information for basic authentication
TALER_BANK_AUTH_METHOD = "basic"
USERNAME = user
PASSWORD = pass
WIRE_GATEWAY_AUTH_METHOD = basic
USERNAME = Exchange
PASSWORD = x
[bank]
HTTP_PORT=8082

View File

@ -44,9 +44,9 @@
static char *config_file;
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
static struct TALER_TESTING_Credentials cred;
/**
@ -60,22 +60,21 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
TALER_TESTING_cmd_check_keys ("first-download",
1),
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-2"),
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"-e",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_check_keys ("first-download"),
/* Causes GET /keys?last_denom_issue=0 */
TALER_TESTING_cmd_check_keys_with_last_denom ("second-download",
1,
"zero"),
TALER_TESTING_cmd_end ()
};
@ -90,50 +89,25 @@ int
main (int argc,
char *const *argv)
{
(void) argc;
{
char *cipher;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
GNUNET_asprintf (&config_file,
"test_exchange_api_keys_cherry_picking-%s.conf",
cipher);
GNUNET_free (cipher);
TALER_TESTING_cleanup_files (config_file);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 77;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_file))
return 1;
break;
default:
GNUNET_break (0);
return 1;
}
return 0;
return TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2014--2020 Taler Systems SA
Copyright (C) 2014--2023 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
@ -42,14 +42,9 @@
static char *config_file;
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
static struct TALER_TESTING_Credentials cred;
/**
@ -63,6 +58,18 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command revocation[] = {
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-2"),
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"-e",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
#if 0
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
@ -72,20 +79,20 @@ run (void *cls,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
#endif
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
/**
* Fill reserve with EUR:10.02, as withdraw fee is 1 ct per
* config.
*/
TALER_TESTING_cmd_admin_add_incoming ("create-reserve-1",
"EUR:10.02",
&bc.exchange_auth,
bc.user42_payto),
&cred.ba,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
"EUR:10.02",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-1"),
/**
* Run wire-watch to trigger the reserve creation.
@ -109,7 +116,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-partial",
"withdraw-revocation-coin-1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -118,7 +125,7 @@ run (void *cls,
TALER_TESTING_cmd_deposit ("deposit-full",
"withdraw-revocation-coin-2",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -241,9 +248,8 @@ run (void *cls,
};
(void) cls;
TALER_TESTING_run_with_fakebank (is,
revocation,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
revocation);
}
@ -251,56 +257,25 @@ int
main (int argc,
char *const *argv)
{
(void) argc;
{
char *cipher;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
GNUNET_asprintf (&config_file,
"test_exchange_api-%s.conf",
cipher);
GNUNET_free (cipher);
/* Check fakebank port is available and get config */
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_file,
"exchange-account-2",
&bc))
return 77;
TALER_TESTING_cleanup_files (config_file);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 77;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_file))
return 1;
break;
default:
GNUNET_break (0);
return 1;
}
return 0;
return TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -43,21 +43,16 @@
*/
static char *config_file;
/**
* Our credentials.
*/
static struct TALER_TESTING_Credentials cred;
/**
* (real) Twister URL. Used at startup time to check if it runs.
*/
static char *twister_url;
/**
* Exchange configuration data.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Twister process.
*/
@ -92,8 +87,8 @@ CMD_TRANSFER_TO_EXCHANGE (const char *label,
{
return TALER_TESTING_cmd_admin_add_incoming (label,
amount,
&bc.exchange_auth,
bc.user42_payto);
&cred.ba,
cred.user42_payto);
}
@ -132,7 +127,7 @@ run (void *cls,
"refresh-deposit-partial",
"refresh-withdraw-coin",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:1",
@ -178,7 +173,7 @@ run (void *cls,
"deposit-refund-1",
"withdraw-coin-r1",
0,
bc.user42_payto,
cred.user42_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
GNUNET_TIME_UNIT_MINUTES,
"EUR:5",
@ -201,7 +196,7 @@ run (void *cls,
"deposit-refund-to-fail",
"withdraw-coin-r1",
0, /* coin index. */
bc.user42_payto,
cred.user42_payto,
/* This parameter will make any comparison about
h_contract_terms fail, when /refund will be handled.
So in other words, this is h_contract mismatch. */
@ -251,17 +246,17 @@ run (void *cls,
#endif
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_wire_add (
"add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys (
"offline-sign-future-keys",
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys (
"refetch /keys",
1),
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-2"),
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"-e",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_batch (
"refresh-reveal-409-conflict",
refresh_409_conflict),
@ -276,16 +271,15 @@ run (void *cls,
};
(void) cls;
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
commands);
}
/**
* Kill, wait, and destroy convenience function.
*
* @param process process to purge.
* @param[in] process process to purge.
*/
static void
purge_process (struct GNUNET_OS_Process *process)
@ -301,57 +295,37 @@ int
main (int argc,
char *const *argv)
{
char *cipher;
int ret;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
{
char *cipher;
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
GNUNET_asprintf (&config_file,
"test_exchange_api_twisted-%s.conf",
cipher);
GNUNET_free (cipher);
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_file,
}
/* FIXME: introduce commands for twister! */
twister_url = TALER_TWISTER_prepare_twister (config_file);
if (NULL == twister_url)
return 77;
twisterd = TALER_TWISTER_run_twister (config_file);
if (NULL == twisterd)
return 77;
ret = TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
&bc))
return 77;
if (NULL == (twister_url = TALER_TWISTER_prepare_twister
(config_file)))
return 77;
TALER_TESTING_cleanup_files (config_file);
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 77;
case GNUNET_OK:
if (NULL == (twisterd = TALER_TWISTER_run_twister (config_file)))
return 77;
ret = TALER_TESTING_setup_with_exchange (&run,
NULL,
config_file);
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
purge_process (twisterd);
GNUNET_free (twister_url);
if (GNUNET_OK != ret)
return 1;
break;
default:
GNUNET_break (0);
return 1;
}
return 0;
return ret;
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2020-2022 Taler Systems SA
Copyright (C) 2020-2023 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
@ -35,16 +35,10 @@
*/
static char *config_file;
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
static struct TALER_TESTING_Credentials cred;
/**
@ -58,10 +52,20 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command commands[] = {
/* this currently fails, because the
auditor is already added by the test setup logic */
TALER_TESTING_cmd_auditor_del ("del-auditor-NOT-FOUND",
MHD_HTTP_NOT_FOUND,
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"-u", "exchange-account-2",
"-ae",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_get_auditor ("get-auditor",
cred.cfg,
true),
TALER_TESTING_cmd_auditor_del ("del-auditor-FROM-SETUP",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG",
MHD_HTTP_FORBIDDEN,
@ -141,15 +145,13 @@ run (void *cls,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("download-future-keys",
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_end ()
};
(void) cls;
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
commands);
}
@ -157,56 +159,25 @@ int
main (int argc,
char *const *argv)
{
(void) argc;
{
char *cipher;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
/* Check fakebank port is available and get config */
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
GNUNET_asprintf (&config_file,
"test_exchange_api-%s.conf",
cipher);
GNUNET_free (cipher);
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_file,
"exchange-account-2",
&bc))
return 77;
TALER_TESTING_cleanup_files (config_file);
/* @helpers. Create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES, /* reset DB? */
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 77;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_file))
return 1;
break;
default:
GNUNET_break (0);
return 1;
}
return 0;
return TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -42,14 +42,9 @@
static char *config_file;
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
struct TALER_TESTING_Credentials cred;
/**
* Some tests behave differently when using CS as we cannot
@ -90,8 +85,8 @@ static bool uses_cs;
*/
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \
bc.user42_payto)
&cred.ba, \
cred.user42_payto)
/**
* Main function that will tell the interpreter what commands to
@ -122,13 +117,13 @@ run (void *cls,
MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
"EUR:5.04",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-1"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-2",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-2"),
/**
* Make a reserve exist, according to the previous
@ -380,15 +375,15 @@ run (void *cls,
"EUR:1.04"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-100",
"EUR:1.04",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-100"),
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-101",
"EUR:1.04"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-101",
"EUR:1.04",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-101"),
CMD_EXEC_WIREWATCH ("wirewatch-100"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-100",
@ -500,32 +495,18 @@ run (void *cls,
};
struct TALER_TESTING_Command commands[] = {
/* setup exchange */
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_extensions ("offline-sign-extensions",
config_file),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-wire-fees",
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-2"),
TALER_TESTING_cmd_system_start ("start-taler",
config_file,
"EUR:0.01",
"EUR:0.01"),
TALER_TESTING_cmd_exec_offline_sign_global_fees ("offline-sign-global-fees",
config_file,
"EUR:0.01",
"EUR:0.01",
"EUR:0.01",
GNUNET_TIME_UNIT_MINUTES,
GNUNET_TIME_UNIT_DAYS,
1),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
"-e",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_batch ("withdraw",
withdraw),
TALER_TESTING_cmd_batch ("push",
@ -541,9 +522,8 @@ run (void *cls,
};
(void) cls;
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
commands);
}
@ -551,15 +531,9 @@ int
main (int argc,
char *const *argv)
{
char *cipher;
(void) argc;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup (argv[0],
"INFO",
NULL);
{
char *cipher;
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_assert (NULL != cipher);
@ -568,42 +542,15 @@ main (int argc,
"test_exchange_api-%s.conf",
cipher);
GNUNET_free (cipher);
/* Check fakebank port is available and get config */
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_file,
"exchange-account-2",
&bc))
return 77;
TALER_TESTING_cleanup_files (config_file);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (config_file,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 78;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_file))
return 2;
break;
default:
GNUNET_break (0);
return 3;
}
return 0;
return TALER_TESTING_main (argv,
"INFO",
config_file,
"exchange-account-2",
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -41,14 +41,10 @@
#define CONFIG_FILE "test_kyc_api.conf"
/**
* Exchange configuration data.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
struct TALER_TESTING_Credentials cred;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Execute the taler-exchange-wirewatch command with
@ -79,8 +75,8 @@ static struct TALER_TESTING_BankConfiguration bc;
*/
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
&bc.exchange_auth, \
bc.user42_payto)
&cred.ba, \
cred.user42_payto)
/**
* Main function that will tell the interpreter what commands to
@ -98,8 +94,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"check-create-reserve-1",
"EUR:15.02",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"create-reserve-1"),
CMD_EXEC_WIREWATCH ("wirewatch-1"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-no-kyc",
@ -150,7 +146,7 @@ run (void *cls,
"deposit-simple",
"withdraw-coin-1",
0,
bc.user43_payto,
cred.user43_payto,
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
@ -196,10 +192,10 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-after-kyc"),
TALER_TESTING_cmd_check_bank_transfer (
"check_bank_transfer-499c",
ec.exchange_url,
cred.exchange_url,
"EUR:4.98",
bc.exchange_payto,
bc.user43_payto),
cred.exchange_payto,
cred.user43_payto),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
TALER_TESTING_cmd_end ()
};
@ -255,13 +251,13 @@ run (void *cls,
MHD_HTTP_OK),
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-1",
"EUR:5.04",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"p2p_create-reserve-1"),
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-2",
"EUR:5.01",
bc.user42_payto,
bc.exchange_payto,
cred.user42_payto,
cred.exchange_payto,
"p2p_create-reserve-2"),
/**
* Make a reserve exist, according to the previous
@ -518,29 +514,18 @@ run (void *cls,
};
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-2"),
TALER_TESTING_cmd_system_start ("start-taler",
CONFIG_FILE,
"EUR:0.01",
"EUR:0.01"),
TALER_TESTING_cmd_exec_offline_sign_global_fees ("offline-sign-global-fees",
CONFIG_FILE,
"EUR:0.01",
"EUR:0.01",
"EUR:0.01",
GNUNET_TIME_UNIT_MINUTES,
GNUNET_TIME_UNIT_DAYS,
1),
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
CONFIG_FILE),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
2),
"-e",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_batch ("withdraw",
withdraw),
TALER_TESTING_cmd_batch ("spend",
@ -563,9 +548,8 @@ run (void *cls,
};
(void) cls;
TALER_TESTING_run_with_fakebank (is,
commands,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
commands);
}
@ -574,48 +558,14 @@ main (int argc,
char *const *argv)
{
(void) argc;
(void) argv;
/* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test-kyc-api",
return TALER_TESTING_main (argv,
"INFO",
NULL);
/* Check fakebank port is available and get configuration data. */
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
CONFIG_FILE,
"exchange-account-2",
&bc))
return 77;
TALER_TESTING_cleanup_files (CONFIG_FILE);
/* @helpers. Run keyup, create tables, ... Note: it
* fetches the port number from config in order to see
* if it's available. */
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
GNUNET_YES,
&ec))
{
case GNUNET_SYSERR:
GNUNET_break (0);
return 1;
case GNUNET_NO:
return 77;
case GNUNET_OK:
if (GNUNET_OK !=
/* Set up event loop and reschedule context, plus
* start/stop the exchange. It calls TALER_TESTING_setup
* which creates the 'is' object.
*/
TALER_TESTING_setup_with_exchange (&run,
NULL,
CONFIG_FILE))
return 1;
break;
default:
GNUNET_break (0);
return 1;
}
return 0;
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -1,51 +1,7 @@
# This file is in the public domain.
#
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_exchange_api_home/
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
[taler-exchange-secmod-rsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
[taler-exchange-secmod-eddsa]
# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 24 days
# Reduce from 12 weeks to ensure we have multiple
DURATION = 14 days
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[auditor]
BASE_URL = "http://localhost:8083/"
# HTTP port the auditor listens to
PORT = 8083
TINY_AMOUNT = EUR:0.01
[exchange]
AML_THRESHOLD = EUR:1000000
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
BASE_URL = "http://localhost:8081/"
@INLINE@ coins-rsa.conf
@INLINE@ test_exchange_api.conf
[kyc-provider-test-oauth2]
COST = 0
@ -83,157 +39,3 @@ OPERATION_TYPE = MERGE
REQUIRED_CHECKS = DUMMY
THRESHOLD = EUR:0
TIMEFRAME = 1d
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[auditordb-postgres]
CONFIG = "postgres:///talercheck"
# Sections starting with "exchange-account-" configure the bank accounts
# of the exchange. The "URL" specifies the account in
# payto://-format.
[exchange-account-1]
# What is the URL of our account?
PAYTO_URI = "payto://x-taler-bank/localhost/42?receiver-name=42"
[exchange-accountcredentials-1]
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
[bank]
HTTP_PORT = 8082
# ENABLE_CREDIT = YES
[exchange-account-2]
# What is the bank account (with the "Taler Bank" demo system)?
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
# Authentication information for basic authentication
[exchange-accountcredentials-2]
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = user
PASSWORD = pass
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_ct_2]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_ct_11]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_2]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_6]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 1024
[coin_eur_11]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS

View File

@ -31,24 +31,9 @@
/**
* Helper structure to keep exchange configuration values.
* Our credentials.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
/**
* Bank configuration data.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Contains plugin.
*/
static struct TALER_TESTING_DatabaseConnection dbc;
/**
* Return value from main().
*/
static int result;
struct TALER_TESTING_Credentials cred;
/**
* Name of the configuration file to use.
@ -70,24 +55,6 @@ static char *config_filename;
TALER_TESTING_cmd_exec_transfer (label "-transfer", cfg_fn)
/**
* 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;
}
}
/**
* Collects all the tests.
*/
@ -96,11 +63,13 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command all[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-1"),
TALER_TESTING_cmd_system_start ("start-taler",
config_filename,
"EUR:0.01",
"EUR:0.01"),
// check no aggregation happens on a empty database
"-e",
NULL),
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty-db",
config_filename),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
@ -108,7 +77,7 @@ run (void *cls,
/* check aggregation happens on the simplest case:
one deposit into the database. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-1",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -119,15 +88,15 @@ run (void *cls,
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
ec.exchange_url,
cred.exchange_url,
"EUR:0.89",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-1"),
/* check aggregation accumulates well. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-2a",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -136,7 +105,7 @@ run (void *cls,
"EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-2b",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -148,15 +117,15 @@ run (void *cls,
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2",
ec.exchange_url,
cred.exchange_url,
"EUR:1.79",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-2"),
/* check that different merchants stem different aggregations. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-3a",
&dbc,
cred.cfg,
"bob",
"4",
GNUNET_TIME_timestamp_get (),
@ -164,7 +133,7 @@ run (void *cls,
"EUR:1",
"EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-3b",
&dbc,
cred.cfg,
"bob",
"5",
GNUNET_TIME_timestamp_get (),
@ -172,7 +141,7 @@ run (void *cls,
"EUR:1",
"EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-3c",
&dbc,
cred.cfg,
"alice",
"4",
GNUNET_TIME_timestamp_get (),
@ -183,25 +152,25 @@ run (void *cls,
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a",
ec.exchange_url,
cred.exchange_url,
"EUR:0.89",
bc.exchange_payto,
cred.exchange_payto,
"payto://x-taler-bank/localhost/4?receiver-name=4"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
ec.exchange_url,
cred.exchange_url,
"EUR:0.89",
bc.exchange_payto,
cred.exchange_payto,
"payto://x-taler-bank/localhost/4?receiver-name=4"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
ec.exchange_url,
cred.exchange_url,
"EUR:0.89",
bc.exchange_payto,
cred.exchange_payto,
"payto://x-taler-bank/localhost/5?receiver-name=5"),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-after-3"),
/* checking that aggregator waits for the deadline. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-4a",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -211,7 +180,7 @@ run (void *cls,
"EUR:0.2",
"EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-4b",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -230,14 +199,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-4-delayed",
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4",
ec.exchange_url,
cred.exchange_url,
"EUR:0.19",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
// test picking all deposits at earliest deadline
TALER_TESTING_cmd_insert_deposit ("do-deposit-5a",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -248,7 +217,7 @@ run (void *cls,
"EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-5b",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -267,13 +236,13 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-5-delayed",
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5",
ec.exchange_url,
cred.exchange_url,
"EUR:0.19",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
/* Test NEVER running 'tiny' unless they make up minimum unit */
TALER_TESTING_cmd_insert_deposit ("do-deposit-6a",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -285,7 +254,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-6a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6b",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -293,7 +262,7 @@ run (void *cls,
"EUR:0.102",
"EUR:0.1"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6c",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -305,7 +274,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-6c-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6d",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -317,7 +286,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-6d-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-6e",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -327,14 +296,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6e",
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6",
ec.exchange_url,
cred.exchange_url,
"EUR:0.01",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
/* Test profiteering if wire deadline is short */
TALER_TESTING_cmd_insert_deposit ("do-deposit-7a",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -346,7 +315,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-7a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-7b",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -356,14 +325,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-profit",
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
ec.exchange_url,
cred.exchange_url,
"EUR:0.01",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
/* Now check profit was actually taken */
TALER_TESTING_cmd_insert_deposit ("do-deposit-7c",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -373,14 +342,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-loss",
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
ec.exchange_url,
cred.exchange_url,
"EUR:0.01",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
/* Test that aggregation would happen fully if wire deadline is long */
TALER_TESTING_cmd_insert_deposit ("do-deposit-8a",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -394,7 +363,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-8a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-8b",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -410,7 +379,7 @@ run (void *cls,
/* now trigger aggregate with large transaction and short deadline */
TALER_TESTING_cmd_insert_deposit ("do-deposit-8c",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -420,14 +389,14 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8",
config_filename),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8",
ec.exchange_url,
cred.exchange_url,
"EUR:0.03",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
/* Test aggregation with fees and rounding profits. */
TALER_TESTING_cmd_insert_deposit ("do-deposit-9a",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -441,7 +410,7 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_empty (
"expect-empty-transactions-after-9a-tiny"),
TALER_TESTING_cmd_insert_deposit ("do-deposit-9b",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -457,7 +426,7 @@ run (void *cls,
/* now trigger aggregate with large transaction and short deadline */
TALER_TESTING_cmd_insert_deposit ("do-deposit-9c",
&dbc,
cred.cfg,
"bob",
USER42_ACCOUNT,
GNUNET_TIME_timestamp_get (),
@ -468,49 +437,15 @@ run (void *cls,
config_filename),
/* 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",
ec.exchange_url,
cred.exchange_url,
"EUR:0.01",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_end ()
};
TALER_TESTING_run_with_fakebank (is,
all,
bc.exchange_auth.wire_gateway_url);
}
/**
* Prepare database and launch the test.
*
* @param cls unused
* @param is interpreter to use
*/
static void
prepare_database (void *cls,
struct TALER_TESTING_Interpreter *is)
{
dbc.plugin = TALER_EXCHANGEDB_plugin_load (is->cfg);
if (NULL == dbc.plugin)
{
GNUNET_break (0);
result = 77;
TALER_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_OK !=
dbc.plugin->preflight (dbc.plugin->cls))
{
GNUNET_break (0);
result = 77;
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_SCHEDULER_add_shutdown (&unload_db,
NULL);
run (NULL,
is);
TALER_TESTING_run (is,
all);
}
@ -519,7 +454,6 @@ main (int argc,
char *const argv[])
{
const char *plugin_name;
char *testname;
if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
{
@ -527,52 +461,17 @@ main (int argc,
return -1;
}
plugin_name++;
(void) GNUNET_asprintf (&testname,
"test-taler-exchange-aggregator-%s",
plugin_name);
(void) GNUNET_asprintf (&config_filename,
"%s.conf",
testname);
GNUNET_log_setup ("test_taler_exchange_aggregator",
"test-taler-exchange-aggregator-%s.conf",
plugin_name);
return TALER_TESTING_main (argv,
"INFO",
NULL);
/* these might get in the way */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
TALER_TESTING_cleanup_files (config_filename);
if (GNUNET_OK !=
TALER_TESTING_prepare_exchange (config_filename,
GNUNET_YES,
&ec))
{
TALER_LOG_WARNING ("Could not prepare the exchange.\n");
return 77;
}
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_filename,
config_filename,
"exchange-account-1",
&bc))
{
TALER_LOG_WARNING ("Could not prepare the fakebank\n");
return 77;
}
result = GNUNET_OK;
if (GNUNET_OK !=
TALER_TESTING_setup_with_exchange (&prepare_database,
NULL,
config_filename))
{
TALER_LOG_WARNING ("Could not prepare database for tests.\n");
return result;
}
GNUNET_free (config_filename);
GNUNET_free (testname);
return GNUNET_OK == result ? 0 : 1;
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -34,14 +34,9 @@
/**
* Bank configuration data.
* Our credentials.
*/
static struct TALER_TESTING_BankConfiguration bc;
/**
* Helper structure to keep exchange configuration values.
*/
static struct TALER_TESTING_ExchangeConfiguration ec;
static struct TALER_TESTING_Credentials cred;
/**
* Name of the configuration file to use.
@ -66,8 +61,8 @@ transfer_to_exchange (const char *label,
{
return TALER_TESTING_cmd_admin_add_incoming (label,
amount,
&bc.exchange_auth,
bc.user42_payto);
&cred.ba,
cred.user42_payto);
}
@ -82,21 +77,19 @@ run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_TESTING_Command all[] = {
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
cred.cfg,
"exchange-account-1"),
TALER_TESTING_cmd_system_start ("start-taler",
config_filename,
"EUR:0.01",
"EUR:0.01"),
TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_wire_add ("add-wire-account",
"payto://x-taler-bank/localhost/2?receiver-name=2",
MHD_HTTP_NO_CONTENT,
false),
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
config_filename),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
"-e",
"-u", "exchange-account-1",
NULL),
TALER_TESTING_cmd_get_exchange ("get-exchange",
cred.cfg,
true,
true),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty"),
TALER_TESTING_cmd_exec_wirewatch ("run-wirewatch-on-empty",
@ -111,8 +104,8 @@ run (void *cls,
TALER_TESTING_cmd_check_bank_admin_transfer (
"clear-good-transfer-to-the-exchange",
"EUR:5",
bc.user42_payto, // debit
bc.exchange_payto, // credit
cred.user42_payto, // debit
cred.exchange_payto, // credit
"run-transfer-good-to-exchange"),
TALER_TESTING_cmd_exec_closer ("run-closer-non-expired-reserve",
@ -135,18 +128,17 @@ run (void *cls,
CMD_EXEC_AGGREGATOR ("run-closer-on-expired-reserve"),
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
ec.exchange_url,
cred.exchange_url,
"EUR:4.99",
bc.exchange_payto,
bc.user42_payto),
cred.exchange_payto,
cred.user42_payto),
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-2"),
TALER_TESTING_cmd_end ()
};
(void) cls;
TALER_TESTING_run_with_fakebank (is,
all,
bc.exchange_auth.wire_gateway_url);
TALER_TESTING_run (is,
all);
}
@ -154,69 +146,29 @@ int
main (int argc,
char *const argv[])
{
(void) argc;
{
const char *plugin_name;
(void) argc;
/* these might get in the way */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test_taler_exchange_wirewatch",
"INFO",
NULL);
if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
plugin_name = strrchr (argv[0], (int) '-');
if (NULL == plugin_name)
{
GNUNET_break (0);
return -1;
}
plugin_name++;
{
char *testname;
GNUNET_asprintf (&testname,
"test-taler-exchange-wirewatch-%s",
plugin_name);
GNUNET_asprintf (&config_filename,
"%s.conf",
testname);
GNUNET_free (testname);
"test-taler-exchange-wirewatch-%s.conf",
plugin_name);
}
/* check database is working */
{
struct GNUNET_PQ_Context *conn;
struct GNUNET_PQ_ExecuteStatement es[] = {
GNUNET_PQ_EXECUTE_STATEMENT_END
};
conn = GNUNET_PQ_connect ("postgres:///talercheck",
NULL,
es,
NULL);
if (NULL == conn)
return 77;
GNUNET_PQ_disconnect (conn);
}
TALER_TESTING_cleanup_files (config_filename);
if (GNUNET_OK !=
TALER_TESTING_prepare_exchange (config_filename,
GNUNET_YES,
&ec))
{
TALER_LOG_INFO ("Could not prepare the exchange\n");
return 77;
}
if (GNUNET_OK !=
TALER_TESTING_prepare_fakebank (config_filename,
return TALER_TESTING_main (argv,
"INFO",
config_filename,
"exchange-account-1",
&bc))
return 77;
return (GNUNET_OK ==
TALER_TESTING_setup_with_exchange (&run,
NULL,
config_filename)) ? 0 : 1;
TALER_TESTING_BS_FAKEBANK,
&cred,
&run,
NULL);
}

View File

@ -18,7 +18,7 @@
*/
/**
* @file testing/testing_api_cmd_auditor_add.c
* @brief command for testing /auditor_add.
* @brief command for testing auditor_add
* @author Christian Grothoff
*/
#include "platform.h"
@ -75,16 +75,8 @@ auditor_add_cb (
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
hr->http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (ds->is);
TALER_TESTING_unexpected_status (ds->is,
hr->http_status);
return;
}
TALER_TESTING_interpreter_next (ds->is);
@ -106,10 +98,43 @@ auditor_add_run (void *cls,
struct AuditorAddState *ds = cls;
struct GNUNET_TIME_Timestamp now;
struct TALER_MasterSignatureP master_sig;
const struct TALER_AuditorPublicKeyP *auditor_pub;
const struct TALER_TESTING_Command *auditor_cmd;
const struct TALER_TESTING_Command *exchange_cmd;
const char *exchange_url;
const char *auditor_url;
(void) cmd;
now = GNUNET_TIME_timestamp_get ();
ds->is = is;
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
"auditor");
if (NULL == auditor_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor_pub (auditor_cmd,
&auditor_pub));
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor_url (auditor_cmd,
&auditor_url));
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
"exchange");
if (NULL == exchange_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
&exchange_url));
if (ds->bad_sig)
{
memset (&master_sig,
@ -118,17 +143,22 @@ auditor_add_run (void *cls,
}
else
{
TALER_exchange_offline_auditor_add_sign (&is->auditor_pub,
is->auditor_url,
const struct TALER_MasterPrivateKeyP *master_priv;
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_master_priv (exchange_cmd,
&master_priv));
TALER_exchange_offline_auditor_add_sign (auditor_pub,
auditor_url,
now,
&is->master_priv,
master_priv,
&master_sig);
}
ds->dh = TALER_EXCHANGE_management_enable_auditor (
is->ctx,
is->exchange_url,
&is->auditor_pub,
is->auditor_url,
TALER_TESTING_interpreter_get_context (is),
exchange_url,
auditor_pub,
auditor_url,
"test-case auditor", /* human-readable auditor name */
now,
&master_sig,
@ -158,9 +188,7 @@ auditor_add_cleanup (void *cls,
if (NULL != ds->dh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
ds->is->ip,
TALER_TESTING_command_incomplete (ds->is,
cmd->label);
TALER_EXCHANGE_management_enable_auditor_cancel (ds->dh);
ds->dh = NULL;

View File

@ -80,16 +80,8 @@ denom_sig_add_cb (
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
hr->http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (ds->is);
TALER_TESTING_unexpected_status (ds->is,
hr->http_status);
return;
}
TALER_TESTING_interpreter_next (ds->is);
@ -112,6 +104,11 @@ auditor_add_run (void *cls,
struct TALER_AuditorSignatureP auditor_sig;
struct TALER_DenominationHashP h_denom_pub;
const struct TALER_EXCHANGE_DenomPublicKey *dk;
const struct TALER_AuditorPublicKeyP *auditor_pub;
const struct TALER_TESTING_Command *auditor_cmd;
const struct TALER_TESTING_Command *exchange_cmd;
const char *exchange_url;
const char *auditor_url;
(void) cmd;
/* Get denom pub from trait */
@ -120,7 +117,6 @@ auditor_add_run (void *cls,
denom_cmd = TALER_TESTING_interpreter_lookup_command (is,
ds->denom_ref);
if (NULL == denom_cmd)
{
GNUNET_break (0);
@ -133,6 +129,31 @@ auditor_add_run (void *cls,
&dk));
}
ds->is = is;
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
"auditor");
if (NULL == auditor_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor_pub (auditor_cmd,
&auditor_pub));
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor_url (auditor_cmd,
&auditor_url));
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
"exchange");
if (NULL == exchange_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
&exchange_url));
if (ds->bad_sig)
{
memset (&auditor_sig,
@ -141,28 +162,33 @@ auditor_add_run (void *cls,
}
else
{
struct TALER_MasterPublicKeyP master_pub;
const struct TALER_MasterPublicKeyP *master_pub;
const struct TALER_AuditorPrivateKeyP *auditor_priv;
GNUNET_CRYPTO_eddsa_key_get_public (&is->master_priv.eddsa_priv,
&master_pub.eddsa_pub);
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_master_pub (exchange_cmd,
&master_pub));
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor_priv (auditor_cmd,
&auditor_priv));
TALER_auditor_denom_validity_sign (
is->auditor_url,
auditor_url,
&dk->h_key,
&master_pub,
master_pub,
dk->valid_from,
dk->withdraw_valid_until,
dk->expire_deposit,
dk->expire_legal,
&dk->value,
&dk->fees,
&is->auditor_priv,
auditor_priv,
&auditor_sig);
}
ds->dh = TALER_EXCHANGE_add_auditor_denomination (
is->ctx,
is->exchange_url,
TALER_TESTING_interpreter_get_context (is),
exchange_url,
&h_denom_pub,
&is->auditor_pub,
auditor_pub,
&auditor_sig,
&denom_sig_add_cb,
ds);
@ -190,9 +216,7 @@ auditor_add_cleanup (void *cls,
if (NULL != ds->dh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
ds->is->ip,
TALER_TESTING_command_incomplete (ds->is,
cmd->label);
TALER_EXCHANGE_add_auditor_denomination_cancel (ds->dh);
ds->dh = NULL;

View File

@ -76,16 +76,8 @@ auditor_del_cb (
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
hr->http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (ds->is);
TALER_TESTING_unexpected_status (ds->is,
hr->http_status);
return;
}
TALER_TESTING_interpreter_next (ds->is);
@ -107,10 +99,36 @@ auditor_del_run (void *cls,
struct AuditorDelState *ds = cls;
struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Timestamp now;
const struct TALER_AuditorPublicKeyP *auditor_pub;
const struct TALER_TESTING_Command *auditor_cmd;
const struct TALER_TESTING_Command *exchange_cmd;
const char *exchange_url;
(void) cmd;
now = GNUNET_TIME_timestamp_get ();
ds->is = is;
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
"auditor");
if (NULL == auditor_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor_pub (auditor_cmd,
&auditor_pub));
exchange_cmd = TALER_TESTING_interpreter_get_command (is,
"exchange");
if (NULL == exchange_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_exchange_url (exchange_cmd,
&exchange_url));
if (ds->bad_sig)
{
memset (&master_sig,
@ -119,15 +137,20 @@ auditor_del_run (void *cls,
}
else
{
TALER_exchange_offline_auditor_del_sign (&is->auditor_pub,
const struct TALER_MasterPrivateKeyP *master_priv;
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_master_priv (exchange_cmd,
&master_priv));
TALER_exchange_offline_auditor_del_sign (auditor_pub,
now,
&is->master_priv,
master_priv,
&master_sig);
}
ds->dh = TALER_EXCHANGE_management_disable_auditor (
is->ctx,
is->exchange_url,
&is->auditor_pub,
TALER_TESTING_interpreter_get_context (is),
exchange_url,
auditor_pub,
now,
&master_sig,
&auditor_del_cb,
@ -156,9 +179,7 @@ auditor_del_cleanup (void *cls,
if (NULL != ds->dh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
ds->is->ip,
TALER_TESTING_command_incomplete (ds->is,
cmd->label);
TALER_EXCHANGE_management_disable_auditor_cancel (ds->dh);
ds->dh = NULL;

View File

@ -68,11 +68,6 @@ struct DepositConfirmationState
*/
struct TALER_AUDITOR_DepositConfirmationHandle *dc;
/**
* Auditor connection.
*/
struct TALER_AUDITOR_Handle *auditor;
/**
* Interpreter state.
*/
@ -125,8 +120,7 @@ do_retry (void *cls)
struct DepositConfirmationState *dcs = cls;
dcs->retry_task = NULL;
dcs->is->commands[dcs->is->ip].last_req_time
= GNUNET_TIME_absolute_get ();
TALER_TESTING_touch_cmd (dcs->is);
deposit_confirmation_run (dcs,
NULL,
dcs->is);
@ -166,21 +160,15 @@ deposit_confirmation_cb (void *cls,
else
dcs->backoff = GNUNET_TIME_randomized_backoff (dcs->backoff,
MAX_BACKOFF);
dcs->is->commands[dcs->is->ip].num_tries++;
TALER_TESTING_inc_tries (dcs->is);
dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
&do_retry,
dcs);
return;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
hr->http_status,
dcs->is->commands[dcs->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply, stderr, 0);
TALER_TESTING_interpreter_fail (dcs->is);
TALER_TESTING_unexpected_status (dcs->is,
hr->http_status);
return;
}
TALER_TESTING_interpreter_next (dcs->is);
@ -220,10 +208,31 @@ deposit_confirmation_run (void *cls,
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
const struct TALER_EXCHANGE_Keys *keys;
const struct TALER_EXCHANGE_SigningPublicKey *spk;
struct TALER_AUDITOR_Handle *auditor;
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd;
if (NULL == exchange)
return;
dcs->is = is;
GNUNET_assert (NULL != dcs->deposit_reference);
{
const struct TALER_TESTING_Command *auditor_cmd;
auditor_cmd
= TALER_TESTING_interpreter_get_command (is,
"auditor");
if (NULL == auditor_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor (auditor_cmd,
&auditor));
}
deposit_cmd
= TALER_TESTING_interpreter_lookup_command (is,
dcs->deposit_reference);
@ -251,7 +260,7 @@ deposit_confirmation_run (void *cls,
dcs->coin_index,
&wire_deadline));
GNUNET_assert (NULL != exchange_timestamp);
keys = TALER_EXCHANGE_get_keys (dcs->is->exchange);
keys = TALER_EXCHANGE_get_keys (exchange);
GNUNET_assert (NULL != keys);
spk = TALER_EXCHANGE_get_signing_key_info (keys,
exchange_pub);
@ -308,7 +317,7 @@ deposit_confirmation_run (void *cls,
if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time))
refund_deadline = timestamp;
}
dcs->dc = TALER_AUDITOR_deposit_confirmation (dcs->auditor,
dcs->dc = TALER_AUDITOR_deposit_confirmation (auditor,
&h_wire,
&no_h_policy,
&h_contract_terms,
@ -353,9 +362,7 @@ deposit_confirmation_cleanup (void *cls,
if (NULL != dcs->dc)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
dcs->is->ip,
TALER_TESTING_command_incomplete (dcs->is,
cmd->label);
TALER_AUDITOR_deposit_confirmation_cancel (dcs->dc);
dcs->dc = NULL;
@ -371,7 +378,6 @@ deposit_confirmation_cleanup (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_deposit_confirmation (const char *label,
struct TALER_AUDITOR_Handle *auditor,
const char *deposit_reference,
unsigned int coin_index,
const char *amount_without_fee,
@ -380,7 +386,6 @@ TALER_TESTING_cmd_deposit_confirmation (const char *label,
struct DepositConfirmationState *dcs;
dcs = GNUNET_new (struct DepositConfirmationState);
dcs->auditor = auditor;
dcs->deposit_reference = deposit_reference;
dcs->coin_index = coin_index;
dcs->amount_without_fee = amount_without_fee;

View File

@ -53,11 +53,6 @@ struct ExchangesState
*/
struct TALER_AUDITOR_ListExchangesHandle *leh;
/**
* Auditor connection.
*/
struct TALER_AUDITOR_Handle *auditor;
/**
* Interpreter state.
*/
@ -115,8 +110,7 @@ do_retry (void *cls)
struct ExchangesState *es = cls;
es->retry_task = NULL;
es->is->commands[es->is->ip].last_req_time
= GNUNET_TIME_absolute_get ();
TALER_TESTING_touch_cmd (es->is);
exchanges_run (es,
NULL,
es->is);
@ -159,24 +153,15 @@ exchanges_cb (void *cls,
else
es->backoff = GNUNET_TIME_randomized_backoff (es->backoff,
MAX_BACKOFF);
es->is->commands[es->is->ip].num_tries++;
TALER_TESTING_inc_tries (es->is);
es->retry_task = GNUNET_SCHEDULER_add_delayed (es->backoff,
&do_retry,
es);
return;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d to command %s in %s:%u\n",
hr->http_status,
(int) hr->ec,
es->is->commands[es->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (es->is);
TALER_TESTING_unexpected_status (es->is,
hr->http_status);
return;
}
if (NULL != es->exchange_url)
@ -217,11 +202,24 @@ exchanges_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct ExchangesState *es = cls;
const struct TALER_TESTING_Command *auditor_cmd;
struct TALER_AUDITOR_Handle *auditor;
(void) cmd;
auditor_cmd = TALER_TESTING_interpreter_get_command (is,
"auditor");
if (NULL == auditor_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_auditor (auditor_cmd,
&auditor));
es->is = is;
es->leh = TALER_AUDITOR_list_exchanges
(is->auditor,
es->leh = TALER_AUDITOR_list_exchanges (auditor,
&exchanges_cb,
es);
@ -250,9 +248,7 @@ exchanges_cleanup (void *cls,
if (NULL != es->leh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
es->is->ip,
TALER_TESTING_command_incomplete (es->is,
cmd->label);
TALER_AUDITOR_list_exchanges_cancel (es->leh);
es->leh = NULL;
@ -275,7 +271,7 @@ exchanges_cleanup (void *cls,
* @param index index number of the traits to be returned.
* @return #GNUNET_OK on success
*/
static int
static enum GNUNET_GenericReturnValue
exchanges_traits (void *cls,
const void **ret,
const char *trait,
@ -301,13 +297,11 @@ exchanges_traits (void *cls,
*/
struct TALER_TESTING_Command
TALER_TESTING_cmd_exchanges (const char *label,
struct TALER_AUDITOR_Handle *auditor,
unsigned int expected_response_code)
{
struct ExchangesState *es;
es = GNUNET_new (struct ExchangesState);
es->auditor = auditor;
es->expected_response_code = expected_response_code;
{

View File

@ -180,8 +180,7 @@ do_retry (void *cls)
struct AdminAddIncomingState *fts = cls;
fts->retry_task = NULL;
fts->is->commands[fts->is->ip].last_req_time
= GNUNET_TIME_absolute_get ();
TALER_TESTING_touch_cmd (fts->is);
admin_add_incoming_run (fts,
NULL,
fts->is);
@ -279,7 +278,7 @@ confirmation_cb (void *cls,
else
fts->backoff = GNUNET_TIME_randomized_backoff (fts->backoff,
MAX_BACKOFF);
fts->is->commands[fts->is->ip].num_tries++;
TALER_TESTING_inc_tries (fts->is);
fts->retry_task = GNUNET_SCHEDULER_add_delayed (
fts->backoff,
&do_retry,
@ -314,6 +313,7 @@ admin_add_incoming_run (void *cls,
bool have_public = false;
(void) cmd;
fts->is = is;
/* Use reserve public key as subject */
if (NULL != fts->reserve_reference)
{
@ -364,7 +364,6 @@ admin_add_incoming_run (void *cls,
fts->reserve_history.amount = fts->amount;
fts->reserve_history.details.in_details.sender_url
= (char *) fts->payto_debit_account; /* remember to NOT free this one... */
fts->is = is;
fts->aih
= TALER_BANK_admin_add_incoming (
TALER_TESTING_interpreter_get_context (is),
@ -398,8 +397,7 @@ admin_add_incoming_cleanup (void *cls,
if (NULL != fts->aih)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %s did not complete\n",
TALER_TESTING_command_incomplete (fts->is,
cmd->label);
TALER_BANK_admin_add_incoming_cancel (fts->aih);
fts->aih = NULL;
@ -439,12 +437,12 @@ admin_add_incoming_traits (void *cls,
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account),
TALER_TESTING_make_trait_payto_uri (&fts->payto_debit_account),
TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account),
TALER_TESTING_make_trait_payto_uri (fts->payto_debit_account),
/* Used as a marker, content does not matter */
TALER_TESTING_make_trait_credit_payto_uri (&void_uri),
TALER_TESTING_make_trait_credit_payto_uri (void_uri),
TALER_TESTING_make_trait_exchange_bank_account_url (
&fts->exchange_credit_url),
fts->exchange_credit_url),
TALER_TESTING_make_trait_amount (&fts->amount),
TALER_TESTING_make_trait_timestamp (0,
&fts->timestamp),
@ -464,13 +462,14 @@ admin_add_incoming_traits (void *cls,
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
TALER_TESTING_make_trait_debit_payto_uri (&fts->payto_debit_account),
TALER_TESTING_make_trait_debit_payto_uri (fts->payto_debit_account),
/* Used as a marker, content does not matter */
TALER_TESTING_make_trait_credit_payto_uri (&void_uri),
TALER_TESTING_make_trait_credit_payto_uri (void_uri),
TALER_TESTING_make_trait_exchange_bank_account_url (
&fts->exchange_credit_url),
fts->exchange_credit_url),
TALER_TESTING_make_trait_amount (&fts->amount),
TALER_TESTING_make_trait_timestamp (0, &fts->timestamp),
TALER_TESTING_make_trait_timestamp (0,
&fts->timestamp),
TALER_TESTING_make_trait_reserve_pub (&fts->reserve_pub),
TALER_TESTING_make_trait_reserve_history (0,
&fts->reserve_history),

View File

@ -82,8 +82,30 @@ check_bank_admin_transfer_run (void *cls,
const char *credit_payto;
const struct TALER_ReservePublicKeyP *reserve_pub;
const struct TALER_TESTING_Command *cmd_ref;
struct TALER_FAKEBANK_Handle *fakebank;
(void) cmd;
{
const struct TALER_TESTING_Command *fakebank_cmd;
fakebank_cmd
= TALER_TESTING_interpreter_get_command (is,
"fakebank");
if (NULL == fakebank_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_fakebank (fakebank_cmd,
&fakebank))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
}
cmd_ref
= TALER_TESTING_interpreter_lookup_command (is,
bcs->reserve_pub_ref);
@ -109,9 +131,9 @@ check_bank_admin_transfer_run (void *cls,
&amount))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at %u\n",
"Failed to parse amount `%s' at %s\n",
bcs->amount,
is->ip);
TALER_TESTING_interpreter_get_current_label (is));
TALER_TESTING_interpreter_fail (is);
return;
}
@ -122,7 +144,7 @@ check_bank_admin_transfer_run (void *cls,
debit_payto,
debit_account);
if (GNUNET_OK !=
TALER_FAKEBANK_check_credit (is->fakebank,
TALER_FAKEBANK_check_credit (fakebank,
&amount,
debit_account,
credit_account,

View File

@ -91,26 +91,48 @@ check_bank_transfer_run (void *cls,
struct TALER_Amount amount;
char *debit_account;
char *credit_account;
const char **exchange_base_url;
const char **debit_payto;
const char **credit_payto;
const char *exchange_base_url;
const char *debit_payto;
const char *credit_payto;
struct TALER_FAKEBANK_Handle *fakebank;
(void) cmd;
{
const struct TALER_TESTING_Command *fakebank_cmd;
fakebank_cmd
= TALER_TESTING_interpreter_get_command (is,
"fakebank");
if (NULL == fakebank_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_fakebank (fakebank_cmd,
&fakebank))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
}
if (NULL == bcs->deposit_reference)
{
TALER_LOG_INFO ("Deposit reference NOT given\n");
debit_payto = &bcs->debit_payto;
credit_payto = &bcs->credit_payto;
exchange_base_url = &bcs->exchange_base_url;
debit_payto = bcs->debit_payto;
credit_payto = bcs->credit_payto;
exchange_base_url = bcs->exchange_base_url;
if (GNUNET_OK !=
TALER_string_to_amount (bcs->amount,
&amount))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at %u\n",
"Failed to parse amount `%s' at %s\n",
bcs->amount,
is->ip);
TALER_TESTING_interpreter_get_current_label (is));
TALER_TESTING_interpreter_fail (is);
return;
}
@ -145,27 +167,22 @@ check_bank_transfer_run (void *cls,
TALER_TESTING_FAIL (is);
amount = *amount_ptr;
}
debit_account = TALER_xtalerbank_account_from_payto (*debit_payto);
credit_account = TALER_xtalerbank_account_from_payto (*credit_payto);
debit_account = TALER_xtalerbank_account_from_payto (debit_payto);
credit_account = TALER_xtalerbank_account_from_payto (credit_payto);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"converted debit_payto (%s) to debit_account (%s)\n",
*debit_payto,
debit_payto,
debit_account);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"converted credit_payto (%s) to credit_account (%s)\n",
*credit_payto,
credit_payto,
credit_account);
if (GNUNET_OK !=
TALER_FAKEBANK_check_debit (is->fakebank,
TALER_FAKEBANK_check_debit (fakebank,
&amount,
debit_account,
credit_account,
*exchange_base_url,
exchange_base_url,
&bcs->wtid))
{
GNUNET_break (0);
@ -217,7 +234,7 @@ check_bank_transfer_traits (void *cls,
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_wtid (wtid_ptr),
TALER_TESTING_make_trait_exchange_url (
&bcs->exchange_base_url),
bcs->exchange_base_url),
TALER_TESTING_trait_end ()
};

View File

@ -58,9 +58,33 @@ check_bank_empty_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
{
struct TALER_FAKEBANK_Handle *fakebank;
(void) cls;
(void) cmd;
if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank))
{
const struct TALER_TESTING_Command *fakebank_cmd;
fakebank_cmd
= TALER_TESTING_interpreter_get_command (is,
"fakebank");
if (NULL == fakebank_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_fakebank (fakebank_cmd,
&fakebank))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
}
if (GNUNET_OK !=
TALER_FAKEBANK_check_empty (fakebank))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);

View File

@ -82,6 +82,11 @@ struct HistoryState
*/
struct TALER_BANK_CreditHistoryHandle *hh;
/**
* The interpreter.
*/
struct TALER_TESTING_Interpreter *is;
/**
* Authentication data for the operation.
*/
@ -144,90 +149,64 @@ print_expected (struct History *h,
/**
* This function constructs the list of history elements that
* interest the account number of the caller. It has two main
* loops: the first to figure out how many history elements have
* to be allocated, and the second to actually populate every
* element.
*
* @param is interpreter state (supposedly having the
* current CMD pointing at a "history" CMD).
* @param[out] rh history array to initialize.
* @return number of entries in @a rh.
* Closure for command_cb().
*/
static unsigned int
build_history (struct TALER_TESTING_Interpreter *is,
struct History **rh)
struct IteratorContext
{
struct HistoryState *hs = is->commands[is->ip].cls;
unsigned int total;
unsigned int pos;
struct History *h;
const struct TALER_TESTING_Command *add_incoming_cmd;
int inc;
unsigned int start;
unsigned int end;
int ok;
const uint64_t *row_id_start = NULL;
if (NULL != hs->start_row_reference)
{
TALER_LOG_INFO ("`%s': start row given via reference `%s'\n",
TALER_TESTING_interpreter_get_current_label (is),
hs->start_row_reference);
add_incoming_cmd
= TALER_TESTING_interpreter_lookup_command (is,
hs->start_row_reference);
GNUNET_assert (NULL != add_incoming_cmd);
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_row (add_incoming_cmd,
&row_id_start));
}
GNUNET_assert (0 != hs->num_results);
if (0 == is->ip)
{
TALER_LOG_DEBUG ("Checking history at FIRST transaction (EMPTY)\n");
*rh = NULL;
return 0;
}
if (hs->num_results > 0)
{
inc = 1; /* _inc_rement */
start = 0;
end = is->ip - 1;
}
else
{
inc = -1;
start = is->ip - 1;
end = 0;
}
/**
* ok equals GNUNET_YES whenever a starting row_id
* was provided AND was found among the CMDs, OR no
* starting row was given in the first place.
* Array of history items to return.
*/
ok = GNUNET_NO;
if (NULL == row_id_start)
ok = GNUNET_YES;
h = NULL;
total = 0;
GNUNET_array_grow (h,
total,
4);
pos = 0;
for (unsigned int off = start; off != end + inc; off += inc)
{
const struct TALER_TESTING_Command *cmd = &is->commands[off];
struct History *h;
/**
* Set to the row ID from where on we should actually process history items,
* or NULL if we should process all of them.
*/
const uint64_t *row_id_start;
/**
* History state we are working on.
*/
struct HistoryState *hs;
/**
* Current length of the @e h array.
*/
unsigned int total;
/**
* Current write position in @e h array.
*/
unsigned int pos;
/**
* Ok equals True whenever a starting row_id was provided AND was found
* among the CMDs, OR no starting row was given in the first place.
*/
bool ok;
};
/**
* Helper function of build_history() that expands
* the history for each relevant command encountered.
*
* @param[in,out] cls our `struct IteratorContext`
* @param cmd a command to process
*/
static void
command_cb (void *cls,
const struct TALER_TESTING_Command *cmd)
{
struct IteratorContext *ic = cls;
struct HistoryState *hs = ic->hs;
const uint64_t *row_id;
const char **credit_account;
const char **debit_account;
const char *credit_account;
const char *debit_account;
const struct TALER_Amount *amount;
const struct TALER_ReservePublicKeyP *reserve_pub;
const char **exchange_credit_url;
const char *exchange_credit_url;
/**
* The following command allows us to skip over those CMDs
@ -253,60 +232,111 @@ build_history (struct TALER_TESTING_Interpreter *is,
TALER_TESTING_get_trait_exchange_bank_account_url (
cmd,
&exchange_credit_url)) )
continue; // Not an interesting event
return; // Not an interesting event
/**
* Is the interesting event a match with regard to
* the row_id value? If yes, store this condition
* to the state and analyze the next CMDs.
*/
if ( (NULL != row_id_start) &&
(*row_id_start == *row_id) &&
(GNUNET_NO == ok) )
if ( (NULL != ic->row_id_start) &&
(*(ic->row_id_start) == *row_id) &&
(! ic->ok) )
{
ok = GNUNET_YES;
continue;
ic->ok = true;
return;
}
/**
* The interesting event didn't match the wanted
* row_id value, analyze the next CMDs. Note: this
* branch is relevant only when row_id WAS given.
*/
if (GNUNET_NO == ok)
continue;
if (! ic->ok)
return;
if (0 != strcasecmp (hs->account_url,
*exchange_credit_url))
continue; // Account mismatch
if (total >= GNUNET_MAX (hs->num_results,
exchange_credit_url))
return; // Account mismatch
if (ic->total >= GNUNET_MAX (hs->num_results,
-hs->num_results) )
{
TALER_LOG_DEBUG ("Hit history limit\n");
break;
return;
}
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
*debit_account,
*credit_account,
debit_account,
credit_account,
hs->account_url);
/* found matching record, make sure we have room */
if (pos == total)
GNUNET_array_grow (h,
total,
pos * 2);
h[pos].url = GNUNET_strdup (*debit_account);
h[pos].details.debit_account_uri = h[pos].url;
h[pos].details.amount = *amount;
h[pos].row_id = *row_id;
h[pos].details.reserve_pub = *reserve_pub;
h[pos].details.credit_account_uri = *exchange_credit_url;
pos++;
if (ic->pos == ic->total)
GNUNET_array_grow (ic->h,
ic->total,
ic->pos * 2);
ic->h[ic->pos].url = GNUNET_strdup (debit_account);
ic->h[ic->pos].details.debit_account_uri = ic->h[ic->pos].url;
ic->h[ic->pos].details.amount = *amount;
ic->h[ic->pos].row_id = *row_id;
ic->h[ic->pos].details.reserve_pub = *reserve_pub;
ic->h[ic->pos].details.credit_account_uri = exchange_credit_url;
ic->pos++;
}
/**
* This function constructs the list of history elements that
* interest the account number of the caller. It has two main
* loops: the first to figure out how many history elements have
* to be allocated, and the second to actually populate every
* element.
*
* @param is interpreter state (supposedly having the
* current CMD pointing at a "history" CMD).
* @param[out] rh history array to initialize.
* @return number of entries in @a rh.
*/
static unsigned int
build_history (struct HistoryState *hs,
struct History **rh)
{
struct TALER_TESTING_Interpreter *is = hs->is;
struct IteratorContext ic = {
.hs = hs
};
if (NULL != hs->start_row_reference)
{
const struct TALER_TESTING_Command *add_incoming_cmd;
TALER_LOG_INFO ("`%s': start row given via reference `%s'\n",
TALER_TESTING_interpreter_get_current_label (is),
hs->start_row_reference);
add_incoming_cmd
= TALER_TESTING_interpreter_lookup_command (is,
hs->start_row_reference);
GNUNET_assert (NULL != add_incoming_cmd);
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_row (add_incoming_cmd,
&ic.row_id_start));
}
GNUNET_assert (GNUNET_YES == ok);
GNUNET_array_grow (h,
total,
pos);
if (0 == pos)
ic.ok = false;
if (NULL == ic.row_id_start)
ic.ok = true;
GNUNET_array_grow (ic.h,
ic.total,
4);
GNUNET_assert (0 != hs->num_results);
TALER_TESTING_iterate (is,
hs->num_results > 0,
&command_cb,
&ic);
GNUNET_assert (ic.ok);
GNUNET_array_grow (ic.h,
ic.total,
ic.pos);
if (0 == ic.pos)
TALER_LOG_DEBUG ("Empty credit history computed\n");
*rh = h;
return total;
*rh = ic.h;
return ic.pos;
}
@ -376,8 +406,8 @@ static void
history_cb (void *cls,
const struct TALER_BANK_CreditHistoryResponse *chr)
{
struct TALER_TESTING_Interpreter *is = cls;
struct HistoryState *hs = is->commands[is->ip].cls;
struct HistoryState *hs = cls;
struct TALER_TESTING_Interpreter *is = hs->is;
hs->hh = NULL;
switch (chr->http_status)
@ -470,6 +500,7 @@ history_run (void *cls,
const uint64_t *row_ptr;
(void) cmd;
hs->is = is;
/* Get row_id from trait. */
if (NULL != hs->start_row_reference)
{
@ -490,15 +521,16 @@ history_run (void *cls,
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
(unsigned long long) row_id);
}
hs->total = build_history (is,
hs->total = build_history (hs,
&hs->h);
hs->hh = TALER_BANK_credit_history (is->ctx,
hs->hh = TALER_BANK_credit_history (
TALER_TESTING_interpreter_get_context (is),
&hs->auth,
row_id,
hs->num_results,
GNUNET_TIME_UNIT_ZERO,
&history_cb,
is);
hs);
GNUNET_assert (NULL != hs->hh);
}
@ -519,7 +551,8 @@ history_cleanup (void *cls,
(void) cmd;
if (NULL != hs->hh)
{
TALER_LOG_WARNING ("/history/incoming did not complete\n");
TALER_TESTING_command_incomplete (hs->is,
cmd->label);
TALER_BANK_credit_history_cancel (hs->hh);
}
GNUNET_free (hs->account_url);

View File

@ -91,6 +91,11 @@ struct HistoryState
*/
struct TALER_BANK_DebitHistoryHandle *hh;
/**
* Our interpreter.
*/
struct TALER_TESTING_Interpreter *is;
/**
* Expected number of results (= rows).
*/
@ -147,93 +152,65 @@ print_expected (struct History *h,
/**
* This function constructs the list of history elements that
* interest the account number of the caller. It has two main
* loops: the first to figure out how many history elements have
* to be allocated, and the second to actually populate every
* element.
*
* @param is interpreter state (supposedly having the
* current CMD pointing at a "history" CMD).
* @param[out] rh history array to initialize.
* @return number of entries in @a rh.
* Closure for command_cb().
*/
static unsigned int
build_history (struct TALER_TESTING_Interpreter *is,
struct History **rh)
struct IteratorContext
{
struct HistoryState *hs = is->commands[is->ip].cls;
unsigned int total;
unsigned int pos;
/**
* Array of history items to return.
*/
struct History *h;
const struct TALER_TESTING_Command *add_incoming_cmd;
int inc;
int start;
int end;
/* #GNUNET_YES whenever either no 'start' value was given for the history
* query, or the given value is found in the list of all the CMDs. */
int ok;
const uint64_t *row_id_start = NULL;
if (NULL != hs->start_row_reference)
{
TALER_LOG_INFO
("`%s': start row given via reference `%s'\n",
TALER_TESTING_interpreter_get_current_label (is),
hs->start_row_reference);
add_incoming_cmd = TALER_TESTING_interpreter_lookup_command (
is,
hs->start_row_reference);
GNUNET_assert (NULL != add_incoming_cmd);
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_row (add_incoming_cmd,
&row_id_start));
}
/**
* Set to the row ID from where on we should actually process history items,
* or NULL if we should process all of them.
*/
const uint64_t *row_id_start;
GNUNET_assert (0 != hs->num_results);
if (0 == is->ip)
{
TALER_LOG_DEBUG ("Checking history at first CMD..\n");
*rh = NULL;
return 0;
}
/**
* History state we are working on.
*/
struct HistoryState *hs;
/* AKA 'delta' */
if (hs->num_results > 0)
{
inc = 1; /* _inc_rement: go forwards */
start = 0;
end = is->ip;
}
else
{
inc = -1; /* decrement: we go backwards */
start = is->ip - 1;
end = -1; /* range is exclusive, do look at 0! */
}
/**
* Current length of the @e h array.
*/
unsigned int total;
/**
* Current write position in @e h array.
*/
unsigned int pos;
/**
* Ok equals True whenever a starting row_id was provided AND was found
* among the CMDs, OR no starting row was given in the first place.
*/
bool ok;
};
/**
* Helper function of build_history() that expands
* the history for each relevant command encountered.
*
* @param[in,out] cls our `struct IteratorContext`
* @param cmd a command to process
*/
static void
command_cb (void *cls,
const struct TALER_TESTING_Command *cmd)
{
struct IteratorContext *ic = cls;
struct HistoryState *hs = ic->hs;
ok = GNUNET_NO;
if (NULL == row_id_start)
ok = GNUNET_YES;
h = NULL;
total = 0;
GNUNET_array_grow (h,
total,
4);
pos = 0;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking commands %u to %u for debit history\n",
start,
end);
for (int off = start; off != end; off += inc)
{
const struct TALER_TESTING_Command *cmd = &is->commands[off];
const uint64_t *row_id;
const char **debit_account;
const char **credit_account;
const char *debit_account;
const char *credit_account;
const struct TALER_Amount *amount;
const struct TALER_WireTransferIdentifierRawP *wtid;
const char **exchange_base_url;
const char *exchange_base_url;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking if command %s is relevant for debit history\n",
@ -256,55 +233,105 @@ build_history (struct TALER_TESTING_Interpreter *is,
(GNUNET_OK !=
TALER_TESTING_get_trait_exchange_url (cmd,
&exchange_base_url)) )
continue; /* not an event we care about */
return; /* not an event we care about */
/* Seek "/history/outgoing" starting row. */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Command %s is relevant for debit history!\n",
cmd->label);
if ( (NULL != row_id_start) &&
(*row_id_start == *row_id) &&
(GNUNET_NO == ok) )
if ( (NULL != ic->row_id_start) &&
(*(ic->row_id_start) == *row_id) &&
(! ic->ok) )
{
/* Until here, nothing counted. */
ok = GNUNET_YES;
continue;
ic->ok = true;
return;
}
/* when 'start' was _not_ given, then ok == GNUNET_YES */
if (GNUNET_NO == ok)
continue; /* skip until we find the marker */
if (total >= GNUNET_MAX (hs->num_results,
if (! ic->ok)
return; /* skip until we find the marker */
if (ic->total >= GNUNET_MAX (hs->num_results,
-hs->num_results) )
{
TALER_LOG_DEBUG ("Hit history limit\n");
break;
return;
}
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
*debit_account,
*credit_account,
debit_account,
credit_account,
hs->account_url);
/* found matching record, make sure we have room */
if (pos == total)
GNUNET_array_grow (h,
total,
pos * 2);
h[pos].c_url = GNUNET_strdup (*credit_account);
h[pos].d_url = GNUNET_strdup (*debit_account);
h[pos].details.credit_account_uri = h[pos].c_url;
h[pos].details.debit_account_uri = h[pos].d_url;
h[pos].details.amount = *amount;
h[pos].row_id = *row_id;
h[pos].details.wtid = *wtid;
h[pos].details.exchange_base_url = *exchange_base_url;
pos++;
if (ic->pos == ic->total)
GNUNET_array_grow (ic->h,
ic->total,
ic->pos * 2);
ic->h[ic->pos].c_url = GNUNET_strdup (credit_account);
ic->h[ic->pos].d_url = GNUNET_strdup (debit_account);
ic->h[ic->pos].details.credit_account_uri = ic->h[ic->pos].c_url;
ic->h[ic->pos].details.debit_account_uri = ic->h[ic->pos].d_url;
ic->h[ic->pos].details.amount = *amount;
ic->h[ic->pos].row_id = *row_id;
ic->h[ic->pos].details.wtid = *wtid;
ic->h[ic->pos].details.exchange_base_url = exchange_base_url;
ic->pos++;
}
/**
* This function constructs the list of history elements that
* interest the account number of the caller. It has two main
* loops: the first to figure out how many history elements have
* to be allocated, and the second to actually populate every
* element.
*
* @param hs history state command context
* @param[out] rh history array to initialize.
* @return number of entries in @a rh.
*/
static unsigned int
build_history (struct HistoryState *hs,
struct History **rh)
{
struct TALER_TESTING_Interpreter *is = hs->is;
struct IteratorContext ic = {
.hs = hs
};
if (NULL != hs->start_row_reference)
{
const struct TALER_TESTING_Command *add_incoming_cmd;
TALER_LOG_INFO (
"`%s': start row given via reference `%s'\n",
TALER_TESTING_interpreter_get_current_label (is),
hs->start_row_reference);
add_incoming_cmd = TALER_TESTING_interpreter_lookup_command (
is,
hs->start_row_reference);
GNUNET_assert (NULL != add_incoming_cmd);
GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_row (add_incoming_cmd,
&ic.row_id_start));
}
GNUNET_assert (GNUNET_YES == ok);
GNUNET_array_grow (h,
total,
pos);
if (0 == pos)
TALER_LOG_DEBUG ("Empty debit history computed\n");
*rh = h;
return total;
ic.ok = false;
if (NULL == ic.row_id_start)
ic.ok = true;
GNUNET_array_grow (ic.h,
ic.total,
4);
GNUNET_assert (0 != hs->num_results);
TALER_TESTING_iterate (is,
hs->num_results > 0,
&command_cb,
&ic);
GNUNET_assert (ic.ok);
GNUNET_array_grow (ic.h,
ic.total,
ic.pos);
if (0 == ic.pos)
TALER_LOG_DEBUG ("Empty credit history computed\n");
*rh = ic.h;
return ic.pos;
}
@ -368,8 +395,8 @@ static void
history_cb (void *cls,
const struct TALER_BANK_DebitHistoryResponse *dhr)
{
struct TALER_TESTING_Interpreter *is = cls;
struct HistoryState *hs = is->commands[is->ip].cls;
struct HistoryState *hs = cls;
struct TALER_TESTING_Interpreter *is = hs->is;
hs->hh = NULL;
switch (dhr->http_status)
@ -462,6 +489,7 @@ history_run (void *cls,
const uint64_t *row_ptr;
(void) cmd;
hs->is = is;
/* Get row_id from trait. */
if (NULL != hs->start_row_reference)
{
@ -482,14 +510,16 @@ history_run (void *cls,
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
(unsigned long long) row_id);
}
hs->total = build_history (is, &hs->h);
hs->hh = TALER_BANK_debit_history (is->ctx,
hs->total = build_history (hs,
&hs->h);
hs->hh = TALER_BANK_debit_history (
TALER_TESTING_interpreter_get_context (is),
&hs->auth,
row_id,
hs->num_results,
GNUNET_TIME_UNIT_ZERO,
&history_cb,
is);
hs);
GNUNET_assert (NULL != hs->hh);
}
@ -510,7 +540,8 @@ history_cleanup (void *cls,
(void) cmd;
if (NULL != hs->hh)
{
TALER_LOG_WARNING ("/history/outgoing did not complete\n");
TALER_TESTING_command_incomplete (hs->is,
cmd->label);
TALER_BANK_debit_history_cancel (hs->hh);
}
for (unsigned int off = 0; off<hs->total; off++)

View File

@ -149,8 +149,7 @@ do_retry (void *cls)
struct TransferState *fts = cls;
fts->retry_task = NULL;
fts->is->commands[fts->is->ip].last_req_time
= GNUNET_TIME_absolute_get ();
TALER_TESTING_touch_cmd (fts->is);
transfer_run (fts,
NULL,
fts->is);
@ -191,7 +190,7 @@ confirmation_cb (void *cls,
fts->backoff = GNUNET_TIME_UNIT_ZERO;
else
fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff);
fts->is->commands[fts->is->ip].num_tries++;
TALER_TESTING_inc_tries (fts->is);
fts->retry_task
= GNUNET_SCHEDULER_add_delayed (fts->backoff,
&do_retry,
@ -199,12 +198,8 @@ confirmation_cb (void *cls,
return;
}
}
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Bank returned HTTP status %u/%d\n",
tr->http_status,
(int) tr->ec);
TALER_TESTING_interpreter_fail (is);
TALER_TESTING_unexpected_status (is,
tr->http_status);
return;
}
@ -276,8 +271,7 @@ transfer_cleanup (void *cls,
if (NULL != fts->weh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %s did not complete\n",
TALER_TESTING_command_incomplete (fts->is,
cmd->label);
TALER_BANK_transfer_cancel (fts->weh);
fts->weh = NULL;
@ -311,12 +305,12 @@ transfer_traits (void *cls,
struct TransferState *fts = cls;
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_exchange_url (
(const char **) &fts->exchange_base_url),
fts->exchange_base_url),
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
TALER_TESTING_make_trait_credit_payto_uri (
(const char **) &fts->payto_credit_account),
fts->payto_credit_account),
TALER_TESTING_make_trait_debit_payto_uri (
(const char **) &fts->payto_debit_account),
fts->payto_debit_account),
TALER_TESTING_make_trait_amount (&fts->amount),
TALER_TESTING_make_trait_timestamp (0, &fts->timestamp),
TALER_TESTING_make_trait_wtid (&fts->wtid),

View File

@ -37,6 +37,11 @@ struct BatchState
*/
struct TALER_TESTING_Command *batch;
/**
* My command (the batch command).
*/
const struct TALER_TESTING_Command *cmd;
/**
* Internal command pointer.
*/
@ -58,6 +63,7 @@ batch_run (void *cls,
{
struct BatchState *bs = cls;
bs->cmd = cmd;
if (NULL != bs->batch[bs->batch_ip].label)
TALER_LOG_INFO ("Running batched command: %s\n",
bs->batch[bs->batch_ip].label);
@ -167,19 +173,33 @@ TALER_TESTING_cmd_batch (const char *label,
}
void
TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is)
bool
TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is,
void *cls)
{
struct BatchState *bs = is->commands[is->ip].cls;
struct BatchState *bs = cls;
struct TALER_TESTING_Command *bcmd = &bs->batch[bs->batch_ip];
if (NULL == bs->batch[bs->batch_ip].label)
if (NULL == bcmd->label)
{
is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get ();
is->ip++;
return;
/* This batch is done */
return true;
}
bs->batch[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get ();
if (TALER_TESTING_cmd_is_batch (bcmd))
{
if (TALER_TESTING_cmd_batch_next (is,
bcmd->cls))
{
/* sub-batch is done */
bcmd->finish_time = GNUNET_TIME_absolute_get ();
bs->batch_ip++;
return false;
}
}
/* Simple command is done */
bcmd->finish_time = GNUNET_TIME_absolute_get ();
bs->batch_ip++;
return false;
}

View File

@ -198,16 +198,8 @@ batch_deposit_cb (void *cls,
ds->dh = NULL;
if (ds->expected_response_code != dr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u to command %s in %s:%u\n",
dr->hr.http_status,
ds->is->commands[ds->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (dr->hr.reply,
stderr,
JSON_INDENT (2));
TALER_TESTING_interpreter_fail (ds->is);
TALER_TESTING_unexpected_status (ds->is,
dr->hr.http_status);
return;
}
if (MHD_HTTP_OK == dr->hr.http_status)
@ -259,8 +251,12 @@ batch_deposit_run (void *cls,
&wire_salt),
GNUNET_JSON_spec_end ()
};
struct TALER_EXCHANGE_Handle *exchange
= TALER_TESTING_get_exchange (is);
(void) cmd;
if (NULL == exchange)
return;
memset (cdds,
0,
sizeof (cdds));
@ -387,7 +383,7 @@ batch_deposit_run (void *cls,
.refund_deadline = ds->refund_deadline
};
ds->dh = TALER_EXCHANGE_batch_deposit (is->exchange,
ds->dh = TALER_EXCHANGE_batch_deposit (exchange,
&dcd,
ds->num_coins,
cdds,
@ -422,9 +418,7 @@ batch_deposit_cleanup (void *cls,
if (NULL != ds->dh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
ds->is->ip,
TALER_TESTING_command_incomplete (ds->is,
cmd->label);
TALER_EXCHANGE_batch_deposit_cancel (ds->dh);
ds->dh = NULL;

Some files were not shown because too many files have changed in this diff Show More