Compare commits
No commits in common. "ddedf03a816e5139b235a3ebdf5b600508c5ed5f" and "46188ae07e97d12b73269167459707844b3c2486" have entirely different histories.
ddedf03a81
...
46188ae07e
@ -1 +1 @@
|
||||
Subproject commit 31b74264e62c4a7f4a671033e214c43fa2f304c0
|
||||
Subproject commit f9ea79a6aae074928f44960f69bc3c2d0c9c7e1d
|
@ -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 = http://localhost:8083/
|
||||
# BASE_URL = https://auditor.taler.net/
|
||||
|
||||
|
||||
# Network configuration for the normal API/service HTTP server
|
||||
|
@ -132,7 +132,7 @@ handle_mhd_completion_callback (void *cls,
|
||||
|
||||
|
||||
/**
|
||||
* Handle a "/config" request.
|
||||
* Handle a "/version" request.
|
||||
*
|
||||
* @param rh context of the handler
|
||||
* @param connection the MHD connection to handle
|
||||
@ -142,11 +142,11 @@ handle_mhd_completion_callback (void *cls,
|
||||
* @return MHD result code
|
||||
*/
|
||||
static MHD_RESULT
|
||||
handle_config (struct TAH_RequestHandler *rh,
|
||||
struct MHD_Connection *connection,
|
||||
void **connection_cls,
|
||||
const char *upload_data,
|
||||
size_t *upload_data_size)
|
||||
handle_version (struct TAH_RequestHandler *rh,
|
||||
struct MHD_Connection *connection,
|
||||
void **connection_cls,
|
||||
const char *upload_data,
|
||||
size_t *upload_data_size)
|
||||
{
|
||||
static json_t *ver; /* we build the response only once, keep around for next query! */
|
||||
|
||||
@ -207,9 +207,9 @@ handle_mhd_request (void *cls,
|
||||
{ "/exchanges", MHD_HTTP_METHOD_GET, "application/json",
|
||||
NULL, 0,
|
||||
&TAH_EXCHANGES_handler, MHD_HTTP_OK },
|
||||
{ "/config", MHD_HTTP_METHOD_GET, "application/json",
|
||||
{ "/version", MHD_HTTP_METHOD_GET, "application/json",
|
||||
NULL, 0,
|
||||
&handle_config, MHD_HTTP_OK },
|
||||
&handle_version, 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",
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/bin/bash
|
||||
# This file is in the public domain.
|
||||
|
||||
set -eu
|
||||
|
||||
|
@ -12,9 +12,11 @@ endif
|
||||
|
||||
bin_PROGRAMS = \
|
||||
taler-aggregator-benchmark \
|
||||
taler-bank-benchmark
|
||||
taler-bank-benchmark \
|
||||
taler-exchange-benchmark
|
||||
|
||||
# taler-exchange-benchmark
|
||||
bin_SCRIPTS = \
|
||||
taler-benchmark-setup.sh
|
||||
|
||||
|
||||
taler_aggregator_benchmark_SOURCES = \
|
||||
@ -73,4 +75,5 @@ 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
|
||||
|
@ -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.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"
|
||||
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
|
||||
DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
|
||||
|
||||
[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:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
|
||||
DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
|
||||
|
||||
[auditor]
|
||||
|
@ -322,8 +322,11 @@ launch_clients (void)
|
||||
if (1 == howmany_clients)
|
||||
{
|
||||
/* do everything in this process */
|
||||
result = TALER_TESTING_loop (&run,
|
||||
NULL);
|
||||
result = TALER_TESTING_setup (&run,
|
||||
NULL,
|
||||
cfg,
|
||||
NULL,
|
||||
GNUNET_NO);
|
||||
if (verbose)
|
||||
print_stats ();
|
||||
return result;
|
||||
@ -337,8 +340,11 @@ launch_clients (void)
|
||||
GNUNET_log_setup ("benchmark-worker",
|
||||
NULL == loglev ? "INFO" : loglev,
|
||||
logfile);
|
||||
result = TALER_TESTING_loop (&run,
|
||||
NULL);
|
||||
result = TALER_TESTING_setup (&run,
|
||||
NULL,
|
||||
cfg,
|
||||
NULL,
|
||||
GNUNET_NO);
|
||||
if (verbose)
|
||||
print_stats ();
|
||||
if (GNUNET_OK != result)
|
||||
|
@ -57,21 +57,16 @@ 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:d:efghl:mnr:stu:vw' OPTION; do
|
||||
while getopts ':abc:efhl:mnsv' OPTION; do
|
||||
case "$OPTION" in
|
||||
a)
|
||||
START_AUDITOR="1"
|
||||
@ -82,9 +77,6 @@ while getopts ':abc:d:efghl:mnr:stu:vw' OPTION; do
|
||||
c)
|
||||
CONF_ORIG="$OPTARG"
|
||||
;;
|
||||
c)
|
||||
WIRE_DOMAIN="$OPTARG"
|
||||
;;
|
||||
e)
|
||||
START_EXCHANGE="1"
|
||||
;;
|
||||
@ -96,24 +88,16 @@ while getopts ':abc:d:efghl:mnr:stu:vw' 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"
|
||||
;;
|
||||
@ -123,25 +107,13 @@ while getopts ':abc:d:efghl:mnr:stu:vw' 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"
|
||||
;;
|
||||
@ -184,12 +156,6 @@ 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")
|
||||
|
||||
@ -269,7 +235,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 "$USE_ACCOUNT" -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
|
||||
taler-config -c "$CONF" -s exchange-account-1 -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
|
||||
echo " OK"
|
||||
|
||||
echo -n "Setting this exchange as the bank's default ..."
|
||||
@ -339,7 +305,6 @@ 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 \
|
||||
@ -349,7 +314,7 @@ then
|
||||
echo "OK"
|
||||
|
||||
echo -n "Setup EBICS keying ..."
|
||||
libeufin-cli connections connect talerconn
|
||||
libeufin-cli connections connect talerconn > /dev/null
|
||||
echo "OK"
|
||||
echo -n "Download bank account name from Sandbox ..."
|
||||
libeufin-cli connections download-bank-accounts talerconn
|
||||
@ -399,16 +364,13 @@ 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
|
||||
gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null 2> /dev/null
|
||||
MASTER_PUB=$(gnunet-ecc -p "${MASTER_PRIV_FILE}")
|
||||
MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)
|
||||
if [ "$MPUB" != "$MASTER_PUB" ]
|
||||
@ -416,34 +378,16 @@ 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" --reset
|
||||
taler-exchange-dbinit -c "$CONF"
|
||||
$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"
|
||||
@ -452,19 +396,16 @@ fi
|
||||
if [ "1" = "$START_MERCHANT" ]
|
||||
then
|
||||
echo -n "Starting merchant ..."
|
||||
if [ ! -z "${USE_MERCHANT_EXCHANGE+x}" ]
|
||||
MEPUB=$(taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY)
|
||||
MXPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
|
||||
if [ "$MEPUB" != "$MXPUB" ]
|
||||
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 "${USE_MERCHANT_EXCHANGE}" -o MASTER_KEY -V "$MXPUB"
|
||||
fi
|
||||
echo -n " patching master_pub ($MXPUB)..."
|
||||
taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY -V "$MXPUB"
|
||||
fi
|
||||
MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
|
||||
MERCHANT_URL="http://localhost:${MERCHANT_PORT}/"
|
||||
taler-merchant-dbinit -c "$CONF" -L "$LOGLEVEL" --reset &> taler-merchant-dbinit.log
|
||||
taler-merchant-dbinit -c "$CONF"
|
||||
$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 &
|
||||
@ -477,7 +418,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" --reset
|
||||
sync-dbinit -c "$CONF"
|
||||
$USE_VALGRIND sync-httpd -c "$CONF" -L "$LOGLEVEL" 2> sync-httpd.log &
|
||||
echo " DONE"
|
||||
fi
|
||||
@ -486,18 +427,14 @@ fi
|
||||
if [ "1" = "$START_AUDITOR" ]
|
||||
then
|
||||
echo -n "Starting auditor ..."
|
||||
AUDITOR_URL=$(taler-config -c "$CONF" -s AUDITOR -o BASE_URL)
|
||||
AUDITOR_URL="http://localhost:8083/"
|
||||
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
|
||||
gnunet-ecc -g1 "$AUDITOR_PRIV_FILE" > /dev/null 2> /dev/null
|
||||
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" --reset
|
||||
taler-auditor-dbinit -c "$CONF"
|
||||
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"
|
||||
@ -535,21 +472,20 @@ 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 \
|
||||
"${EXCHANGE_URL}config" \
|
||||
"http://localhost:8081/config" \
|
||||
-o /dev/null \
|
||||
-O /dev/null >/dev/null || continue
|
||||
fi
|
||||
if [ "1" = "$START_MERCHANT" ]
|
||||
then
|
||||
echo -n "M"
|
||||
wget \
|
||||
--tries=1 \
|
||||
--timeout=1 \
|
||||
@ -559,7 +495,6 @@ do
|
||||
fi
|
||||
if [ "1" = "$START_BACKUP" ]
|
||||
then
|
||||
echo -n "S"
|
||||
wget \
|
||||
--tries=1 \
|
||||
--timeout=1 \
|
||||
@ -569,7 +504,6 @@ do
|
||||
fi
|
||||
if [ "1" = "$START_AUDITOR" ]
|
||||
then
|
||||
echo -n "A"
|
||||
wget \
|
||||
--tries=1 \
|
||||
--timeout=1 \
|
||||
@ -619,20 +553,23 @@ then
|
||||
taler-exchange-offline -c "$CONF" \
|
||||
download \
|
||||
sign \
|
||||
wire-fee now "$WIRE_DOMAIN" "$CURRENCY:0.01" "$CURRENCY:0.01" \
|
||||
wire-fee now iban "$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"
|
||||
ENABLED=$(taler-config -c "$CONF" -s "$USE_ACCOUNT" -o "ENABLE_CREDIT")
|
||||
if [ "YES" = "$ENABLED" ]
|
||||
then
|
||||
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.log"
|
||||
echo " OK"
|
||||
fi
|
||||
for ASEC in $(taler-config -c "$CONF" -S | grep -i "exchange-account-")
|
||||
do
|
||||
ENABLED=$(taler-config -c "$CONF" -s "$ASEC" -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")
|
||||
taler-exchange-offline -c "$CONF" \
|
||||
enable-account "$EXCHANGE_PAYTO_URI" \
|
||||
upload &> "taler-exchange-offline-account-$ASEC.log"
|
||||
echo " OK"
|
||||
fi
|
||||
done
|
||||
if [ "1" = "$START_AUDITOR" ]
|
||||
then
|
||||
echo -n "Enabling auditor ..."
|
@ -85,6 +85,11 @@ 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.
|
||||
*/
|
||||
@ -141,6 +146,11 @@ 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.
|
||||
*/
|
||||
@ -464,6 +474,45 @@ 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.
|
||||
@ -482,6 +531,148 @@ 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)
|
||||
{
|
||||
@ -519,16 +710,58 @@ 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_run (main_cb,
|
||||
main_cb_cls);
|
||||
result = TALER_TESTING_setup (main_cb,
|
||||
main_cb_cls,
|
||||
cfg,
|
||||
exchanged,
|
||||
GNUNET_YES);
|
||||
print_stats ();
|
||||
}
|
||||
else
|
||||
@ -542,8 +775,11 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
|
||||
NULL == loglev ? "INFO" : loglev,
|
||||
logfile);
|
||||
|
||||
result = TALER_TESTING_run (main_cb,
|
||||
main_cb_cls);
|
||||
result = TALER_TESTING_setup (main_cb,
|
||||
main_cb_cls,
|
||||
cfg,
|
||||
exchanged,
|
||||
GNUNET_YES);
|
||||
print_stats ();
|
||||
if (GNUNET_OK != result)
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
@ -609,6 +845,58 @@ 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;
|
||||
}
|
||||
|
||||
@ -778,8 +1066,39 @@ 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",
|
||||
|
@ -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
@ -26,14 +26,12 @@
|
||||
#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"
|
||||
|
||||
|
||||
/**
|
||||
@ -308,10 +306,8 @@ batch_withdraw_transaction (void *cls,
|
||||
struct BatchWithdrawContext *wc = cls;
|
||||
uint64_t ruuid;
|
||||
enum GNUNET_DB_QueryStatus qs;
|
||||
bool found = false;
|
||||
bool balance_ok = false;
|
||||
bool age_ok = false;
|
||||
uint16_t required_age = 0;
|
||||
bool found = false;
|
||||
char *kyc_required;
|
||||
struct TALER_PaytoHashP reserve_h_payto;
|
||||
|
||||
@ -475,11 +471,9 @@ batch_withdraw_transaction (void *cls,
|
||||
wc->now,
|
||||
wc->reserve_pub,
|
||||
&wc->batch_total,
|
||||
TEH_age_restriction_enabled,
|
||||
/* TODO[oec]: add parameter for maximum age and [out]parameter for required age */
|
||||
&found,
|
||||
&balance_ok,
|
||||
&age_ok,
|
||||
&required_age,
|
||||
&ruuid);
|
||||
if (0 > qs)
|
||||
{
|
||||
@ -502,20 +496,7 @@ batch_withdraw_transaction (void *cls,
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
/* TODO[oec]: add error handling for age restriction requirements */
|
||||
|
||||
if (! balance_ok)
|
||||
{
|
||||
@ -741,12 +722,10 @@ parse_planchets (const struct TEH_RequestContext *rc,
|
||||
struct PlanchetContext *pc = &wc->planchets[i];
|
||||
struct TEH_DenominationKey *dk;
|
||||
|
||||
dk = TEH_keys_denomination_by_hash_from_state (
|
||||
ksh,
|
||||
&pc->collectable.denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
dk = TEH_keys_denomination_by_hash2 (ksh,
|
||||
&pc->collectable.denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
if (NULL == dk)
|
||||
{
|
||||
if (! check_request_idempotent (wc,
|
||||
|
@ -127,10 +127,10 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
|
||||
TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING,
|
||||
NULL);
|
||||
}
|
||||
dk = TEH_keys_denomination_by_hash_from_state (ksh,
|
||||
denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
dk = TEH_keys_denomination_by_hash2 (ksh,
|
||||
denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
if (NULL == dk)
|
||||
{
|
||||
return TEH_RESPONSE_reply_unknown_denom_pub_hash (
|
||||
@ -262,10 +262,10 @@ TEH_handler_csr_withdraw (struct TEH_RequestContext *rc,
|
||||
TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING,
|
||||
NULL);
|
||||
}
|
||||
dk = TEH_keys_denomination_by_hash_from_state (ksh,
|
||||
&denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
dk = TEH_keys_denomination_by_hash2 (ksh,
|
||||
&denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
if (NULL == dk)
|
||||
{
|
||||
return TEH_RESPONSE_reply_unknown_denom_pub_hash (
|
||||
|
@ -148,7 +148,7 @@ extension_update_event_cb (void *cls,
|
||||
TEH_age_restriction_enabled = false;
|
||||
if (NULL != conf)
|
||||
{
|
||||
TEH_age_restriction_enabled = extension->enabled;
|
||||
TEH_age_restriction_enabled = true;
|
||||
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",
|
||||
|
@ -1364,6 +1364,7 @@ denomination_info_cb (
|
||||
&dk->h_denom_pub.hash,
|
||||
dk,
|
||||
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1752,7 +1753,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_cherry_pick_date timestamp to use
|
||||
* @param last_cpd 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
|
||||
@ -1763,7 +1764,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_cherry_pick_date,
|
||||
struct GNUNET_TIME_Timestamp last_cpd,
|
||||
json_t *signkeys,
|
||||
json_t *recoup,
|
||||
json_t *denoms,
|
||||
@ -1777,8 +1778,7 @@ create_krd (struct TEH_KeyStateHandle *ksh,
|
||||
struct TALER_ExchangeSignatureP grouped_exchange_sig;
|
||||
json_t *keys;
|
||||
|
||||
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
|
||||
last_cherry_pick_date.abs_time));
|
||||
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (last_cpd.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_cherry_pick_date));
|
||||
GNUNET_TIME_timestamp2s (last_cpd));
|
||||
|
||||
/* 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_cherry_pick_date,
|
||||
last_cpd,
|
||||
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_cherry_pick_date,
|
||||
last_cpd,
|
||||
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_cherry_pick_date),
|
||||
last_cpd),
|
||||
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_cherry_pick_date;
|
||||
krd.cherry_pick_date = last_cpd;
|
||||
GNUNET_array_append (ksh->krd_array,
|
||||
ksh->krd_array_length,
|
||||
krd);
|
||||
@ -2054,17 +2054,14 @@ 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_cherry_pick_date;
|
||||
struct GNUNET_TIME_Timestamp last_cpd;
|
||||
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);
|
||||
@ -2097,7 +2094,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
|
||||
grouped_denominations = json_array ();
|
||||
GNUNET_assert (NULL != grouped_denominations);
|
||||
|
||||
last_cherry_pick_date = GNUNET_TIME_UNIT_ZERO_TS;
|
||||
last_cpd = GNUNET_TIME_UNIT_ZERO_TS;
|
||||
|
||||
// FIXME: This block contains the implementation of the DEPRECATED
|
||||
// "denom_pubs" array along with the new grouped "denominations".
|
||||
@ -2127,13 +2124,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_cherry_pick_date,
|
||||
if (GNUNET_TIME_timestamp_cmp (last_cpd,
|
||||
!=,
|
||||
dk->meta.start) &&
|
||||
(! GNUNET_TIME_absolute_is_zero (last_cherry_pick_date.abs_time)) )
|
||||
(! GNUNET_TIME_absolute_is_zero (last_cpd.abs_time)) )
|
||||
{
|
||||
/*
|
||||
* This is not the first entry in the heap (because last_cherry_pick_date !=
|
||||
* This is not the first entry in the heap (because last_cpd !=
|
||||
* GNUNET_TIME_UNIT_ZERO_TS) and the previous entry had a different
|
||||
* start time. Therefore, we create a new entry in ksh.
|
||||
*/
|
||||
@ -2146,7 +2143,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
|
||||
if (GNUNET_OK !=
|
||||
create_krd (ksh,
|
||||
&hc,
|
||||
last_cherry_pick_date,
|
||||
last_cpd,
|
||||
sctx.signkeys,
|
||||
recoup,
|
||||
denoms,
|
||||
@ -2155,17 +2152,21 @@ 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_cherry_pick_date));
|
||||
GNUNET_TIME_timestamp2s (last_cpd));
|
||||
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);
|
||||
goto CLEANUP;
|
||||
json_decref (denoms);
|
||||
json_decref (grouped_denominations);
|
||||
json_decref (sctx.signkeys);
|
||||
json_decref (recoup);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
}
|
||||
|
||||
last_cherry_pick_date = dk->meta.start;
|
||||
last_cpd = dk->meta.start;
|
||||
|
||||
{
|
||||
json_t *denom;
|
||||
@ -2263,11 +2264,7 @@ 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 */
|
||||
@ -2389,7 +2386,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
|
||||
}
|
||||
|
||||
GNUNET_CONTAINER_heap_destroy (heap);
|
||||
if (! GNUNET_TIME_absolute_is_zero (last_cherry_pick_date.abs_time))
|
||||
if (! GNUNET_TIME_absolute_is_zero (last_cpd.abs_time))
|
||||
{
|
||||
struct GNUNET_HashCode hc;
|
||||
|
||||
@ -2398,7 +2395,7 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
|
||||
if (GNUNET_OK !=
|
||||
create_krd (ksh,
|
||||
&hc,
|
||||
last_cherry_pick_date,
|
||||
last_cpd,
|
||||
sctx.signkeys,
|
||||
recoup,
|
||||
denoms,
|
||||
@ -2407,25 +2404,14 @@ 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_cherry_pick_date));
|
||||
goto CLEANUP;
|
||||
GNUNET_TIME_timestamp2s (last_cpd));
|
||||
json_decref (denoms);
|
||||
json_decref (grouped_denominations);
|
||||
json_decref (sctx.signkeys);
|
||||
json_decref (recoup);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
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
|
||||
{
|
||||
@ -2433,15 +2419,11 @@ 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 ret;
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -2751,16 +2733,16 @@ TEH_keys_denomination_by_hash (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return TEH_keys_denomination_by_hash_from_state (ksh,
|
||||
h_denom_pub,
|
||||
conn,
|
||||
mret);
|
||||
return TEH_keys_denomination_by_hash2 (ksh,
|
||||
h_denom_pub,
|
||||
conn,
|
||||
mret);
|
||||
}
|
||||
|
||||
|
||||
struct TEH_DenominationKey *
|
||||
TEH_keys_denomination_by_hash_from_state (
|
||||
const struct TEH_KeyStateHandle *ksh,
|
||||
TEH_keys_denomination_by_hash2 (
|
||||
struct TEH_KeyStateHandle *ksh,
|
||||
const struct TALER_DenominationHashP *h_denom_pub,
|
||||
struct MHD_Connection *conn,
|
||||
MHD_RESULT *mret)
|
||||
|
@ -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_hash_from_state (
|
||||
const struct TEH_KeyStateHandle *ksh,
|
||||
TEH_keys_denomination_by_hash2 (
|
||||
struct TEH_KeyStateHandle *ksh,
|
||||
const struct TALER_DenominationHashP *h_denom_pub,
|
||||
struct MHD_Connection *conn,
|
||||
MHD_RESULT *mret);
|
||||
|
@ -511,7 +511,7 @@ resolve_refreshes_reveal_denominations (
|
||||
}
|
||||
}
|
||||
|
||||
old_dk = TEH_keys_denomination_by_hash_from_state (
|
||||
old_dk = TEH_keys_denomination_by_hash2 (
|
||||
ksh,
|
||||
&rctx->melt.session.coin.denom_pub_hash,
|
||||
connection,
|
||||
@ -536,10 +536,10 @@ resolve_refreshes_reveal_denominations (
|
||||
-1);
|
||||
if (GNUNET_OK != res)
|
||||
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
|
||||
dks[i] = TEH_keys_denomination_by_hash_from_state (ksh,
|
||||
&rrcs[i].h_denom_pub,
|
||||
connection,
|
||||
&ret);
|
||||
dks[i] = TEH_keys_denomination_by_hash2 (ksh,
|
||||
&rrcs[i].h_denom_pub,
|
||||
connection,
|
||||
&ret);
|
||||
if (NULL == dks[i])
|
||||
return ret;
|
||||
if ( (TALER_DENOMINATION_CS == dks[i]->denom_pub.cipher) &&
|
||||
|
@ -1084,20 +1084,6 @@ 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,
|
||||
|
@ -75,20 +75,6 @@ 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
|
||||
|
@ -488,13 +488,10 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
|
||||
GNUNET_JSON_parse_free (spec);
|
||||
return mret;
|
||||
}
|
||||
|
||||
dk = TEH_keys_denomination_by_hash_from_state (
|
||||
ksh,
|
||||
&wc.collectable.denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
dk = TEH_keys_denomination_by_hash2 (ksh,
|
||||
&wc.collectable.denom_pub_hash,
|
||||
NULL,
|
||||
NULL);
|
||||
if (NULL == dk)
|
||||
{
|
||||
if (! check_request_idempotent (rc,
|
||||
|
@ -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)'
|
||||
',birthdate INT4 NOT NULL DEFAULT(0)'
|
||||
',max_age 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'
|
||||
,'birthdate'
|
||||
,'max_age'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--
|
||||
-- This file is part of TALER
|
||||
-- Copyright (C) 2023 Taler Systems SA
|
||||
-- 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
|
||||
@ -13,28 +13,26 @@
|
||||
-- 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(
|
||||
CREATE FUNCTION create_table_age_withdraw_commitments(
|
||||
IN partition_suffix VARCHAR DEFAULT NULL
|
||||
)
|
||||
RETURNS VOID
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
table_name VARCHAR DEFAULT 'age_withdraw';
|
||||
table_name VARCHAR DEFAULT 'age_withdraw_commitments';
|
||||
BEGIN
|
||||
PERFORM create_partitioned_table(
|
||||
'CREATE TABLE %I'
|
||||
'(age_withdraw_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
|
||||
'(age_withdraw_commitment_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)'
|
||||
',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))'
|
||||
',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))'
|
||||
') %s ;'
|
||||
,table_name
|
||||
,'PARTITION BY HASH (reserve_pub)'
|
||||
@ -42,7 +40,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, their signatures and denominations.'
|
||||
'It also contains the blindly signed coins and related denominations.'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
@ -78,18 +76,12 @@ BEGIN
|
||||
);
|
||||
PERFORM comment_partitioned_column(
|
||||
'Array of references to the denominations'
|
||||
,'denom_serials'
|
||||
,'denominations_serials'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
PERFORM comment_partitioned_column(
|
||||
'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'
|
||||
'Array of signatures over the blinded envelopes'
|
||||
,'denom_sigs'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
@ -98,14 +90,14 @@ END
|
||||
$$;
|
||||
|
||||
|
||||
CREATE FUNCTION constrain_table_age_withdraw(
|
||||
CREATE FUNCTION constrain_table_age_withdraw_commitments(
|
||||
IN partition_suffix VARCHAR
|
||||
)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
table_name VARCHAR DEFAULT 'age_withdraw';
|
||||
table_name VARCHAR DEFAULT 'age_withdraw_commitments';
|
||||
BEGIN
|
||||
table_name = concat_ws('_', table_name, partition_suffix);
|
||||
EXECUTE FORMAT (
|
||||
@ -119,25 +111,25 @@ BEGIN
|
||||
);
|
||||
EXECUTE FORMAT (
|
||||
'ALTER TABLE ' || table_name ||
|
||||
' ADD CONSTRAINT ' || table_name || '_age_withdraw_id_key'
|
||||
' UNIQUE (age_withdraw_id);'
|
||||
' ADD CONSTRAINT ' || table_name || '_age_withdraw_commitment_id_key'
|
||||
' UNIQUE (age_withdraw_commitment_id);'
|
||||
);
|
||||
END
|
||||
$$;
|
||||
|
||||
|
||||
CREATE FUNCTION foreign_table_age_withdraw()
|
||||
CREATE FUNCTION foreign_table_age_withdraw_commitments()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
DECLARE
|
||||
table_name VARCHAR DEFAULT 'age_withdraw';
|
||||
table_name VARCHAR DEFAULT 'age_withdraw_commitments';
|
||||
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
|
||||
$$;
|
||||
@ -150,6 +142,6 @@ INSERT INTO exchange_tables
|
||||
,partitioned
|
||||
,by_range)
|
||||
VALUES
|
||||
('age_withdraw', 'exchange-0003', 'create', TRUE ,FALSE),
|
||||
('age_withdraw', 'exchange-0003', 'constrain',TRUE ,FALSE),
|
||||
('age_withdraw', 'exchange-0003', 'foreign', TRUE ,FALSE);
|
||||
('age_withdraw_commitments', 'exchange-0003', 'create', TRUE ,FALSE),
|
||||
('age_withdraw_commitments', 'exchange-0003', 'constrain',TRUE ,FALSE),
|
||||
('age_withdraw_commitments', 'exchange-0003', 'foreign', TRUE ,FALSE);
|
125
src/exchangedb/0003-age_withdraw_reveals.sql
Normal file
125
src/exchangedb/0003-age_withdraw_reveals.sql
Normal file
@ -0,0 +1,125 @@
|
||||
--
|
||||
-- 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);
|
@ -128,8 +128,7 @@ 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.c pg_get_age_withdraw.h \
|
||||
pg_do_age_withdraw.h pg_do_age_withdraw.c \
|
||||
pg_get_age_withdraw_info.c pg_get_age_withdraw_info.h \
|
||||
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 \
|
||||
|
@ -25,7 +25,8 @@ SET search_path TO exchange;
|
||||
#include "0003-aml_status.sql"
|
||||
#include "0003-aml_staff.sql"
|
||||
#include "0003-aml_history.sql"
|
||||
#include "0003-age_withdraw.sql"
|
||||
#include "0003-age_withdraw_commitments.sql"
|
||||
#include "0003-age_withdraw_reveals.sql"
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
@ -1,181 +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/>
|
||||
--
|
||||
-- @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';
|
||||
|
@ -1,6 +1,6 @@
|
||||
--
|
||||
-- This file is part of TALER
|
||||
-- Copyright (C) 2014--2023 Taler Systems SA
|
||||
-- Copyright (C) 2014--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
|
||||
@ -13,8 +13,6 @@
|
||||
-- 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,
|
||||
@ -22,20 +20,18 @@ CREATE OR REPLACE FUNCTION exchange_do_batch_withdraw(
|
||||
IN rpub BYTEA,
|
||||
IN now INT8,
|
||||
IN min_reserve_gc INT8,
|
||||
IN do_age_check BOOLEAN,
|
||||
-- TODO[oec]: add [IN] parameter for maximum age and [OUT] parameter for required age
|
||||
OUT reserve_found BOOLEAN,
|
||||
OUT balance_ok BOOLEAN,
|
||||
OUT age_ok BOOLEAN,
|
||||
OUT allowed_maximum_age INT4, -- in years
|
||||
OUT ruuid INT8
|
||||
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
|
||||
@ -48,13 +44,12 @@ 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;
|
||||
@ -64,32 +59,11 @@ THEN
|
||||
-- reserve unknown
|
||||
reserve_found=FALSE;
|
||||
balance_ok=FALSE;
|
||||
age_ok=FALSE;
|
||||
allowed_maximum_age=0;
|
||||
ruuid=2;
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
|
||||
-- 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;
|
||||
-- TODO[oec]: check age requirements
|
||||
|
||||
-- Check reserve balance is sufficient.
|
||||
IF (reserve_val > amount_val)
|
||||
@ -108,6 +82,7 @@ ELSE
|
||||
reserve_val=0;
|
||||
reserve_frac=reserve_frac - amount_frac;
|
||||
ELSE
|
||||
reserve_found=TRUE;
|
||||
balance_ok=FALSE;
|
||||
RETURN;
|
||||
END IF;
|
||||
@ -129,6 +104,9 @@ balance_ok=TRUE;
|
||||
|
||||
END $$;
|
||||
|
||||
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.';
|
||||
-- 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.';
|
||||
|
||||
|
||||
|
||||
|
@ -14,11 +14,14 @@
|
||||
-- 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, -- FIXME: denom_serials should really be a parameter to this FUNCTION.
|
||||
IN h_denom_pub BYTEA,
|
||||
IN ruuid INT8,
|
||||
IN reserve_sig BYTEA,
|
||||
IN h_coin_envelope BYTEA,
|
||||
@ -42,8 +45,6 @@ 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
|
||||
|
@ -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 birthday=in_birthday WHERE reserve_pub=X;
|
||||
-- UPDATE exchange.reserves SET max_age=in_birthday WHERE reserve_pub=X;
|
||||
|
||||
IF in_require_aml
|
||||
THEN
|
||||
|
@ -1,104 +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_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);
|
||||
}
|
@ -1,55 +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_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
|
@ -17,7 +17,6 @@
|
||||
* @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"
|
||||
@ -32,12 +31,10 @@ 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;
|
||||
@ -45,7 +42,6 @@ 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
|
||||
@ -55,10 +51,6 @@ 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
|
||||
@ -76,9 +68,8 @@ 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,
|
||||
|
@ -33,11 +33,8 @@
|
||||
* @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
|
||||
*/
|
||||
@ -47,11 +44,8 @@ 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
|
||||
|
@ -14,24 +14,24 @@
|
||||
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file exchangedb/pg_get_age_withdraw.c
|
||||
* @brief Implementation of the get_age_withdraw function for Postgres
|
||||
* @file exchangedb/pg_get_age_withdraw_info.c
|
||||
* @brief Implementation of the get_age_withdraw_info 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.h"
|
||||
#include "pg_get_age_withdraw_info.h"
|
||||
#include "pg_helper.h"
|
||||
|
||||
|
||||
enum GNUNET_DB_QueryStatus
|
||||
TEH_PG_get_age_withdraw (
|
||||
TEH_PG_get_age_withdraw_info (
|
||||
void *cls,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *ach,
|
||||
struct TALER_EXCHANGEDB_AgeWithdraw *aw)
|
||||
struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc)
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
@ -41,44 +41,26 @@ TEH_PG_get_age_withdraw (
|
||||
};
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_auto_from_type ("h_commitment",
|
||||
&aw->h_commitment),
|
||||
&awc->h_commitment),
|
||||
GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
|
||||
&aw->reserve_sig),
|
||||
&awc->reserve_sig),
|
||||
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
|
||||
&aw->reserve_pub),
|
||||
&awc->reserve_pub),
|
||||
GNUNET_PQ_result_spec_uint16 ("max_age",
|
||||
&aw->max_age),
|
||||
&awc->max_age),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
|
||||
&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),
|
||||
&awc->amount_with_fee),
|
||||
GNUNET_PQ_result_spec_uint32 ("noreveal_index",
|
||||
&awc->noreveal_index),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
/* 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. */
|
||||
/* 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. */
|
||||
PREPARE (pg,
|
||||
"get_age_withdraw",
|
||||
"get_age_withdraw_info",
|
||||
"SELECT"
|
||||
" h_commitment"
|
||||
",reserve_sig"
|
||||
@ -87,20 +69,10 @@ TEH_PG_get_age_withdraw (
|
||||
",amount_with_fee_val"
|
||||
",amount_with_fee_frac"
|
||||
",noreveal_index"
|
||||
",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"
|
||||
" FROM age_withdraw_commitments"
|
||||
" WHERE reserve_pub=$1 and h_commitment=$2;");
|
||||
|
||||
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||
"get_age_withdraw",
|
||||
"get_age_withdraw_info",
|
||||
params,
|
||||
rs);
|
||||
}
|
@ -14,12 +14,12 @@
|
||||
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file exchangedb/pg_get_age_withdraw.h
|
||||
* @brief implementation of the get_age_withdraw function for Postgres
|
||||
* @file exchangedb/pg_get_age_withdraw_info.h
|
||||
* @brief implementation of the get_age_withdraw_info function for Postgres
|
||||
* @author Özgür KESIM
|
||||
*/
|
||||
#ifndef PG_GET_AGE_WITHDRAW_H
|
||||
#define PG_GET_AGE_WITHDRAW_H
|
||||
#ifndef PG_GET_AGE_WITHDRAW_INFO_H
|
||||
#define PG_GET_AGE_WITHDRAW_INFO_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] aw corresponding details of the previous age-withdraw request if an entry was found
|
||||
* @param[out] awc 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 (
|
||||
TEH_PG_get_age_withdraw_info (
|
||||
void *cls,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *ach,
|
||||
struct TALER_EXCHANGEDB_AgeWithdraw *aw);
|
||||
struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc);
|
||||
#endif
|
@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
enum GNUNET_DB_QueryStatus
|
||||
TEH_PG_get_withdraw (
|
||||
TEH_PG_get_withdraw_info (
|
||||
void *cls,
|
||||
const struct TALER_BlindedCoinHashP *bch,
|
||||
struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable)
|
||||
|
106
src/exchangedb/pg_insert_age_withdraw_reveal.c
Normal file
106
src/exchangedb/pg_insert_age_withdraw_reveal.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
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
|
||||
}
|
43
src/exchangedb/pg_insert_age_withdraw_reveal.h
Normal file
43
src/exchangedb/pg_insert_age_withdraw_reveal.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
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
|
@ -2057,37 +2057,38 @@ irbt_cb_table_purse_deletion (struct PostgresClosure *pg,
|
||||
|
||||
|
||||
/**
|
||||
* Function called with age_withdraw records to insert into table.
|
||||
* Function called with age_withdraw_commitments records to insert into table.
|
||||
*
|
||||
* @param pg plugin context
|
||||
* @param td record to insert
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
irbt_cb_table_age_withdraw (struct PostgresClosure *pg,
|
||||
const struct
|
||||
TALER_EXCHANGEDB_TableData *td)
|
||||
irbt_cb_table_age_withdraw_commitments (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.h_commitment),
|
||||
&td->details.age_withdraw_commitments.h_commitment),
|
||||
TALER_PQ_query_param_amount (
|
||||
&td->details.age_withdraw.amount_with_fee),
|
||||
&td->details.age_withdraw_commitments.amount_with_fee),
|
||||
GNUNET_PQ_query_param_uint16 (
|
||||
&td->details.age_withdraw.max_age),
|
||||
&td->details.age_withdraw_commitments.max_age),
|
||||
GNUNET_PQ_query_param_auto_from_type (
|
||||
&td->details.age_withdraw.reserve_pub),
|
||||
&td->details.age_withdraw_commitments.reserve_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (
|
||||
&td->details.age_withdraw.reserve_sig),
|
||||
&td->details.age_withdraw_commitments.reserve_sig),
|
||||
GNUNET_PQ_query_param_uint32 (
|
||||
&td->details.age_withdraw.noreveal_index),
|
||||
/* TODO: other fields, too! */
|
||||
&td->details.age_withdraw_commitments.noreveal_index),
|
||||
GNUNET_PQ_query_param_absolute_time (
|
||||
&td->details.age_withdraw_commitments.timestamp),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
PREPARE (pg,
|
||||
"insert_into_table_age_withdraw",
|
||||
"INSERT INTO age_withdraw"
|
||||
"insert_into_table_age_withdraw_commitments",
|
||||
"INSERT INTO age_withdraw_commitments"
|
||||
"(age_withdraw_commitment_id"
|
||||
",h_commitment"
|
||||
",amount_with_fee_val"
|
||||
@ -2096,10 +2097,64 @@ irbt_cb_table_age_withdraw (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",
|
||||
"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",
|
||||
params);
|
||||
}
|
||||
|
||||
@ -2251,8 +2306,11 @@ 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_AGE_WITHDRAW:
|
||||
rh = &irbt_cb_table_age_withdraw;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
if (NULL == rh)
|
||||
|
@ -72,8 +72,6 @@ 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",
|
||||
@ -147,8 +145,7 @@ TEH_PG_iterate_denominations (void *cls,
|
||||
PREPARE (pg,
|
||||
"select_denominations",
|
||||
"SELECT"
|
||||
" denominations_serial"
|
||||
",denominations.master_sig"
|
||||
" denominations.master_sig"
|
||||
",denom_revocations_serial_id IS NOT NULL AS revoked"
|
||||
",valid_from"
|
||||
",expire_withdraw"
|
||||
|
@ -2762,48 +2762,109 @@ lrbt_cb_table_purse_deletion (void *cls,
|
||||
|
||||
|
||||
/**
|
||||
* Function called with age_withdraw table entries.
|
||||
* Function called with age_withdraw_commitments 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 (void *cls,
|
||||
PGresult *result,
|
||||
unsigned int num_results)
|
||||
lrbt_cb_table_age_withdraw_commitments (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_AGE_WITHDRAW
|
||||
.table = TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; i<num_results; i++)
|
||||
{
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 (
|
||||
"age_withdraw_id",
|
||||
"age_withdraw_commitment_id",
|
||||
&td.serial),
|
||||
GNUNET_PQ_result_spec_auto_from_type (
|
||||
"h_commitment",
|
||||
&td.details.age_withdraw.h_commitment),
|
||||
&td.details.age_withdraw_commitments.h_commitment),
|
||||
GNUNET_PQ_result_spec_uint16 (
|
||||
"max_age",
|
||||
&td.details.age_withdraw.max_age),
|
||||
&td.details.age_withdraw_commitments.max_age),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT (
|
||||
"amount_with_fee",
|
||||
&td.details.age_withdraw.amount_with_fee),
|
||||
&td.details.age_withdraw_commitments.amount_with_fee),
|
||||
GNUNET_PQ_result_spec_auto_from_type (
|
||||
"reserve_pub",
|
||||
&td.details.age_withdraw.reserve_pub),
|
||||
&td.details.age_withdraw_commitments.reserve_pub),
|
||||
GNUNET_PQ_result_spec_auto_from_type (
|
||||
"reserve_sig",
|
||||
&td.details.age_withdraw.reserve_sig),
|
||||
&td.details.age_withdraw_commitments.reserve_sig),
|
||||
GNUNET_PQ_result_spec_uint32 (
|
||||
"noreveal_index",
|
||||
&td.details.age_withdraw.noreveal_index),
|
||||
/* TODO[oec]: more fields! */
|
||||
&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),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
@ -3530,10 +3591,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_AGE_WITHDRAW:
|
||||
XPREPARE ("select_above_serial_by_table_age_withdraw",
|
||||
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
|
||||
XPREPARE ("select_above_serial_by_table_age_withdraw_commitments",
|
||||
"SELECT"
|
||||
" age_withdraw_id"
|
||||
" age_withdraw_commitment_id"
|
||||
",h_commitment"
|
||||
",amount_with_fee_val"
|
||||
",amount_with_fee_frac"
|
||||
@ -3541,11 +3602,26 @@ TEH_PG_lookup_records_by_table (void *cls,
|
||||
",reserve_pub"
|
||||
",reserve_sig"
|
||||
",noreveal_index"
|
||||
" FROM age_withdraw"
|
||||
" WHERE age_withdraw_id > $1"
|
||||
" ORDER BY age_withdraw_id ASC;");
|
||||
/* TODO[oec]: MORE FIELDS! */
|
||||
rh = &lrbt_cb_table_age_withdraw;
|
||||
" 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;
|
||||
break;
|
||||
}
|
||||
if (NULL == rh)
|
||||
|
@ -426,14 +426,23 @@ TEH_PG_lookup_serial_by_table (void *cls,
|
||||
" LIMIT 1;");
|
||||
statement = "select_serial_by_table_purse_deletion";
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_AGE_WITHDRAW:
|
||||
XPREPARE ("select_serial_by_table_age_withdraw",
|
||||
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
|
||||
XPREPARE ("select_serial_by_table_age_withdraw_commitments",
|
||||
"SELECT"
|
||||
" age_withdraw_id AS serial"
|
||||
" FROM age_withdraw"
|
||||
" ORDER BY age_withdraw_id DESC"
|
||||
" age_withdraw_commitment_id AS serial"
|
||||
" FROM age_withdraw_commitments"
|
||||
" ORDER BY age_withdraw_commitment_id DESC"
|
||||
" LIMIT 1;");
|
||||
statement = "select_serial_by_table_age_withdraw";
|
||||
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";
|
||||
break;
|
||||
}
|
||||
if (NULL == statement)
|
||||
|
@ -117,9 +117,8 @@
|
||||
#include "pg_drain_kyc_alert.h"
|
||||
#include "pg_reserves_in_insert.h"
|
||||
#include "pg_get_withdraw_info.h"
|
||||
#include "pg_get_age_withdraw.h"
|
||||
#include "pg_get_age_withdraw_info.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"
|
||||
@ -582,10 +581,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
|
||||
= &TEH_PG_get_withdraw_info;
|
||||
plugin->do_batch_withdraw
|
||||
= &TEH_PG_do_batch_withdraw;
|
||||
plugin->do_age_withdraw
|
||||
= &TEH_PG_do_age_withdraw;
|
||||
plugin->get_age_withdraw
|
||||
= &TEH_PG_get_age_withdraw;
|
||||
plugin->get_age_withdraw_info
|
||||
= &TEH_PG_get_age_withdraw_info;
|
||||
plugin->get_policy_details
|
||||
= &TEH_PG_get_policy_details;
|
||||
plugin->persist_policy_details
|
||||
|
@ -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)'
|
||||
',birthdate INT4 NOT NULL DEFAULT(0)' -- 0 means: no age restriction.
|
||||
',max_age INT4 NOT NULL DEFAULT(120)'
|
||||
',expiration_date INT8 NOT NULL'
|
||||
',gc_date INT8 NOT NULL'
|
||||
') %s ;'
|
||||
|
@ -154,7 +154,6 @@ 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,
|
||||
|
@ -3728,8 +3728,7 @@ 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 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 max_age_group maximum age group that the withdrawn coins must be restricted to
|
||||
* @param reserve_priv private key to sign with
|
||||
* @param[out] reserve_sig resulting signature
|
||||
*/
|
||||
@ -3737,8 +3736,7 @@ void
|
||||
TALER_wallet_age_withdraw_sign (
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||
const struct TALER_Amount *amount_with_fee,
|
||||
const struct TALER_AgeMask *mask,
|
||||
uint8_t max_age,
|
||||
uint32_t max_age_group,
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||
struct TALER_ReserveSignatureP *reserve_sig);
|
||||
|
||||
@ -3747,8 +3745,7 @@ 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 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 max_age_group maximum age group 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
|
||||
@ -3757,8 +3754,7 @@ enum GNUNET_GenericReturnValue
|
||||
TALER_wallet_age_withdraw_verify (
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
|
||||
const struct TALER_Amount *amount_with_fee,
|
||||
const struct TALER_AgeMask *mask,
|
||||
uint8_t max_age,
|
||||
uint32_t max_age_group,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_ReserveSignatureP *reserve_sig);
|
||||
|
||||
@ -5877,7 +5873,7 @@ TALER_age_commitment_hash (
|
||||
enum GNUNET_GenericReturnValue
|
||||
TALER_age_restriction_commit (
|
||||
const struct TALER_AgeMask *mask,
|
||||
uint8_t age,
|
||||
const uint8_t age,
|
||||
const struct GNUNET_HashCode *seed,
|
||||
struct TALER_AgeCommitmentProof *comm_proof);
|
||||
|
||||
|
@ -623,20 +623,15 @@ enum TALER_EXCHANGE_CheckKeysFlags
|
||||
|
||||
/**
|
||||
* Check if our current response for /keys is valid, and if
|
||||
* not, trigger /keys download. If @a cb is given, changes
|
||||
* the @a exchange callback for the /keys response.
|
||||
* not, trigger /keys download.
|
||||
*
|
||||
* @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,
|
||||
TALER_EXCHANGE_CertificationCallback cb,
|
||||
void *cb_cls);
|
||||
enum TALER_EXCHANGE_CheckKeysFlags flags);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -301,7 +301,8 @@ enum TALER_EXCHANGEDB_ReplicatedTable
|
||||
TALER_EXCHANGEDB_RT_AML_HISTORY,
|
||||
TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES,
|
||||
TALER_EXCHANGEDB_RT_PURSE_DELETION,
|
||||
TALER_EXCHANGEDB_RT_AGE_WITHDRAW,
|
||||
TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS,
|
||||
TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS,
|
||||
};
|
||||
|
||||
|
||||
@ -772,14 +773,22 @@ 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;
|
||||
uint64_t num_coins;
|
||||
uint64_t *denominations_serials;
|
||||
void *h_blind_evs;
|
||||
struct TALER_BlindedDenominationSignature denom_sigs;
|
||||
} age_withdraw;
|
||||
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;
|
||||
|
||||
} details;
|
||||
|
||||
@ -939,13 +948,6 @@ 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.
|
||||
*/
|
||||
@ -1180,11 +1182,11 @@ struct TALER_EXCHANGEDB_CollectableBlindcoin
|
||||
|
||||
|
||||
/**
|
||||
* @brief Information we keep for an age-withdraw request
|
||||
* @brief Information we keep for an age-withdraw commitment
|
||||
* to reproduce the /age-withdraw operation if needed, and to have proof
|
||||
* that a reserve was drained by this amount.
|
||||
*/
|
||||
struct TALER_EXCHANGEDB_AgeWithdraw
|
||||
struct TALER_EXCHANGEDB_AgeWithdrawCommitment
|
||||
{
|
||||
/**
|
||||
* Total amount (with fee) committed to withdraw
|
||||
@ -1192,7 +1194,7 @@ struct TALER_EXCHANGEDB_AgeWithdraw
|
||||
struct TALER_Amount amount_with_fee;
|
||||
|
||||
/**
|
||||
* Maximum age (in years) that the coins are restricted to.
|
||||
* Maximum age that the coins are restricted to.
|
||||
*/
|
||||
uint16_t max_age;
|
||||
|
||||
@ -1206,7 +1208,7 @@ struct TALER_EXCHANGEDB_AgeWithdraw
|
||||
* revealed during cut and choose. This value applies to all n coins in the
|
||||
* commitment.
|
||||
*/
|
||||
uint16_t noreveal_index;
|
||||
uint32_t noreveal_index;
|
||||
|
||||
/**
|
||||
* Public key of the reserve that was drained.
|
||||
@ -1221,35 +1223,9 @@ struct TALER_EXCHANGEDB_AgeWithdraw
|
||||
struct TALER_ReserveSignatureP reserve_sig;
|
||||
|
||||
/**
|
||||
* Number of coins to be withdrawn.
|
||||
* The exchange's signature of the response.
|
||||
*/
|
||||
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;
|
||||
struct TALER_ExchangeSignatureP sig;
|
||||
};
|
||||
|
||||
|
||||
@ -2775,6 +2751,28 @@ 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.
|
||||
@ -3762,15 +3760,6 @@ 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
|
||||
@ -3780,11 +3769,8 @@ 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
|
||||
*/
|
||||
@ -3794,11 +3780,8 @@ 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);
|
||||
|
||||
|
||||
@ -3828,49 +3811,73 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
bool *nonce_reuse);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* @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] aw corresponding details of the previous age-withdraw request if an entry was found
|
||||
* @param[out] awc corresponding details of the previous age-withdraw request if an entry was found
|
||||
* @return statement execution status
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*get_age_withdraw)(
|
||||
(*get_age_withdraw_info)(
|
||||
void *cls,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *ach,
|
||||
struct TALER_EXCHANGEDB_AgeWithdraw *aw);
|
||||
struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc);
|
||||
|
||||
/**
|
||||
* Perform an age-withdraw operation, checking for sufficient balance and
|
||||
* fulfillment of age requirements and possibly persisting the withdrawal
|
||||
* details.
|
||||
* Perform an age-withdraw operation, checking for sufficient balance
|
||||
* 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_AgeWithdraw *commitment,
|
||||
struct GNUNET_TIME_Timestamp now,
|
||||
const struct TALER_EXCHANGEDB_AgeWithdrawCommitment *commitment,
|
||||
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
|
||||
*
|
||||
|
@ -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
@ -558,18 +558,6 @@ 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" }.
|
||||
*
|
||||
@ -582,18 +570,6 @@ 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.
|
||||
|
@ -102,7 +102,7 @@ struct TALER_AUDITOR_Handle
|
||||
void *version_cb_cls;
|
||||
|
||||
/**
|
||||
* Data for the request to get the /config of a auditor,
|
||||
* Data for the request to get the /version 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 /config request.
|
||||
* Task for retrying /version request.
|
||||
*/
|
||||
struct GNUNET_SCHEDULER_Task *retry_task;
|
||||
|
||||
/**
|
||||
* /config data of the auditor, only valid if
|
||||
* /version 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 /config frequency.
|
||||
* Retry /version frequency.
|
||||
*/
|
||||
struct GNUNET_TIME_Relative retry_delay;
|
||||
|
||||
@ -141,10 +141,10 @@ struct TALER_AUDITOR_Handle
|
||||
};
|
||||
|
||||
|
||||
/* ***************** Internal /config fetching ************* */
|
||||
/* ***************** Internal /version fetching ************* */
|
||||
|
||||
/**
|
||||
* Decode the JSON in @a resp_obj from the /config response and store the data
|
||||
* Decode the JSON in @a resp_obj from the /version 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 /config from the auditor.
|
||||
* Initiate download of /version from the auditor.
|
||||
*
|
||||
* @param cls auditor where to download /config from
|
||||
* @param cls auditor where to download /version from
|
||||
*/
|
||||
static void
|
||||
request_version (void *cls);
|
||||
|
||||
|
||||
/**
|
||||
* Callback used when downloading the reply to a /config request
|
||||
* Callback used when downloading the reply to a /version 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 /config\n");
|
||||
TALER_LOG_WARNING ("NULL body for a 200-OK /version\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,
|
||||
"/config failed for auditor %s: %u!\n",
|
||||
"/version 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 ready!\n",
|
||||
"Auditor %s is now 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 /config from the auditor.
|
||||
* Initiate download of /version from the auditor.
|
||||
*
|
||||
* @param cls auditor where to download /config from
|
||||
* @param cls auditor where to download /version 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,
|
||||
"/config");
|
||||
"/version");
|
||||
if (NULL == auditor->vr_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
|
@ -1268,24 +1268,14 @@ 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,
|
||||
TALER_EXCHANGE_CertificationCallback cb,
|
||||
void *cb_cls)
|
||||
enum TALER_EXCHANGE_CheckKeysFlags flags)
|
||||
{
|
||||
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,
|
||||
@ -2279,9 +2269,7 @@ 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,
|
||||
NULL,
|
||||
NULL);
|
||||
TALER_EXCHANGE_CKF_NONE);
|
||||
return &exchange->key_data;
|
||||
}
|
||||
|
||||
@ -2290,9 +2278,7 @@ json_t *
|
||||
TALER_EXCHANGE_get_keys_raw (struct TALER_EXCHANGE_Handle *exchange)
|
||||
{
|
||||
(void) TALER_EXCHANGE_check_keys_current (exchange,
|
||||
TALER_EXCHANGE_CKF_NONE,
|
||||
NULL,
|
||||
NULL);
|
||||
TALER_EXCHANGE_CKF_NONE);
|
||||
return json_deep_copy (exchange->key_data_raw);
|
||||
}
|
||||
|
||||
|
9
src/testing/.gitignore
vendored
9
src/testing/.gitignore
vendored
@ -46,12 +46,3 @@ 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/
|
||||
|
@ -13,9 +13,6 @@ endif
|
||||
clean-local:
|
||||
rm -rf report*
|
||||
|
||||
bin_SCRIPTS = \
|
||||
taler-unified-setup.sh
|
||||
|
||||
# Libraries
|
||||
|
||||
lib_LTLIBRARIES = \
|
||||
@ -57,11 +54,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 \
|
||||
@ -73,8 +70,6 @@ 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 \
|
||||
@ -90,6 +85,7 @@ 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 \
|
||||
@ -105,14 +101,12 @@ 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_run_fakebank.c \
|
||||
testing_api_cmd_rewind.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 \
|
||||
@ -120,15 +114,14 @@ 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 \
|
||||
@ -147,16 +140,15 @@ 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 \
|
||||
test_auditor_api_version_rsa \
|
||||
test_auditor_api_version_cs \
|
||||
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 \
|
||||
@ -219,9 +211,22 @@ test_auditor_api_rsa_LDADD = \
|
||||
$(XLIB)
|
||||
|
||||
|
||||
test_auditor_api_version_SOURCES = \
|
||||
test_auditor_api_version_cs_SOURCES = \
|
||||
test_auditor_api_version.c
|
||||
test_auditor_api_version_LDADD = \
|
||||
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 = \
|
||||
libtalertesting.la \
|
||||
$(top_builddir)/src/lib/libtalerauditor.la \
|
||||
$(LIBGCRYPT_LIBS) \
|
||||
@ -236,7 +241,7 @@ test_bank_api_with_nexus_SOURCES = \
|
||||
test_bank_api.c
|
||||
test_bank_api_with_nexus_LDADD = \
|
||||
libtalertesting.la \
|
||||
$(top_builddir)/src/lib/libtalerexchange.la \
|
||||
-ltalerexchange \
|
||||
-lgnunetutil \
|
||||
$(top_builddir)/src/bank-lib/libtalerbank.la \
|
||||
$(XLIB)
|
||||
@ -245,7 +250,7 @@ test_bank_api_with_fakebank_SOURCES = \
|
||||
test_bank_api.c
|
||||
test_bank_api_with_fakebank_LDADD = \
|
||||
libtalertesting.la \
|
||||
$(top_builddir)/src/lib/libtalerexchange.la \
|
||||
-ltalerexchange \
|
||||
-lgnunetutil \
|
||||
$(top_builddir)/src/bank-lib/libtalerbank.la \
|
||||
$(XLIB)
|
||||
@ -537,14 +542,10 @@ 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 \
|
||||
|
@ -1,118 +0,0 @@
|
||||
|
||||
# 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
|
@ -1,128 +0,0 @@
|
||||
# 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
|
@ -1,43 +1,75 @@
|
||||
# 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
|
||||
LEGAL_RESERVE_EXPIRATION_TIME = 7 years
|
||||
|
||||
[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]
|
||||
|
||||
# What is the account URL?
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
ENABLE_DEBIT = YES
|
||||
@ -49,6 +81,7 @@ WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
PASSWORD = x
|
||||
|
||||
|
||||
[bank]
|
||||
HTTP_PORT = 8082
|
||||
|
||||
|
@ -1,40 +1,61 @@
|
||||
# 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/"
|
||||
PORT = 8083
|
||||
|
||||
[auditordb-postgres]
|
||||
CONFIG = "postgres:///talercheck"
|
||||
# HTTP port the auditor listens to
|
||||
PORT = 8083
|
||||
|
||||
[exchange-account-1]
|
||||
# What is the account URL?
|
||||
|
@ -1,4 +1,141 @@
|
||||
|
||||
# This file is in the public domain.
|
||||
#
|
||||
@INLINE@ coins-cs.conf
|
||||
@INLINE@ test_exchange_api.conf
|
||||
[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
|
||||
|
@ -1,4 +1,147 @@
|
||||
|
||||
# This file is in the public domain.
|
||||
#
|
||||
@INLINE@ coins-rsa.conf
|
||||
@INLINE@ test_exchange_api.conf
|
||||
[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
|
||||
|
@ -45,9 +45,14 @@ static char *config_file;
|
||||
static char *config_file_expire_reserve_now;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Execute the taler-exchange-wirewatch command with
|
||||
@ -78,8 +83,8 @@ static struct TALER_TESTING_Credentials cred;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
|
||||
/**
|
||||
* Run the taler-auditor.
|
||||
@ -111,7 +116,7 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer
|
||||
("check-create-reserve-1",
|
||||
"EUR:5.01", cred.user42_payto, cred.exchange_payto,
|
||||
"EUR:5.01", bc.user42_payto, bc.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous transfer.
|
||||
@ -135,7 +140,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-simple",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -152,7 +157,7 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer
|
||||
("check-refresh-create-reserve-1",
|
||||
"EUR:5.01", cred.user42_payto, cred.exchange_payto,
|
||||
"EUR:5.01", bc.user42_payto, bc.exchange_payto,
|
||||
"refresh-create-reserve-1"),
|
||||
/**
|
||||
* Make previous command effective.
|
||||
@ -173,7 +178,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
||||
"refresh-withdraw-coin-1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -198,7 +203,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
|
||||
"refresh-reveal-1",
|
||||
3,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.1",
|
||||
@ -220,75 +225,75 @@ run (void *cls,
|
||||
*/
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-499c",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:4.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-99c1",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-99c",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.08",
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
|
||||
/* The following transactions got originated within
|
||||
* the "massive deposit confirms" batch. */
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check-massive-transfer-1",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-2",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-3",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-4",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-5",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-6",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-7",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-8",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-9",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer
|
||||
("check-massive-transfer-10",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto, cred.user43_payto),
|
||||
bc.exchange_payto, bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -306,8 +311,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check_bank_transfer-unaggregated",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-unaggregated"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
|
||||
"create-reserve-unaggregated",
|
||||
@ -317,7 +322,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
|
||||
"withdraw-coin-unaggregated",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_relative_multiply
|
||||
(GNUNET_TIME_UNIT_YEARS,
|
||||
@ -354,7 +359,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-1",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:5",
|
||||
@ -371,7 +376,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-2",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:4.99",
|
||||
@ -461,7 +466,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
|
||||
"recoup-withdraw-coin-2a",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.5",
|
||||
@ -488,8 +493,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-massive-transfer",
|
||||
"EUR:10.10",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto, bc.exchange_payto,
|
||||
"massive-reserve"),
|
||||
CMD_EXEC_WIREWATCH ("massive-wirewatch"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-1",
|
||||
@ -546,7 +550,7 @@ run (void *cls,
|
||||
"massive-deposit-1",
|
||||
"massive-withdraw-1",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -555,7 +559,7 @@ run (void *cls,
|
||||
("massive-deposit-2",
|
||||
"massive-withdraw-2",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -564,7 +568,7 @@ run (void *cls,
|
||||
("massive-deposit-3",
|
||||
"massive-withdraw-3",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -573,7 +577,7 @@ run (void *cls,
|
||||
("massive-deposit-4",
|
||||
"massive-withdraw-4",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -582,7 +586,7 @@ run (void *cls,
|
||||
("massive-deposit-5",
|
||||
"massive-withdraw-5",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -591,7 +595,7 @@ run (void *cls,
|
||||
("massive-deposit-6",
|
||||
"massive-withdraw-6",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -600,7 +604,7 @@ run (void *cls,
|
||||
("massive-deposit-7",
|
||||
"massive-withdraw-7",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -609,7 +613,7 @@ run (void *cls,
|
||||
("massive-deposit-8",
|
||||
"massive-withdraw-8",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -618,7 +622,7 @@ run (void *cls,
|
||||
("massive-deposit-9",
|
||||
"massive-withdraw-9",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -627,12 +631,13 @@ run (void *cls,
|
||||
"massive-deposit-10",
|
||||
"massive-withdraw-10",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.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",
|
||||
@ -643,22 +648,21 @@ run (void *cls,
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-2"),
|
||||
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_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
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),
|
||||
TALER_TESTING_cmd_exec_auditor_offline ("auditor-offline",
|
||||
config_file),
|
||||
CMD_RUN_AUDITOR ("virgin-auditor"),
|
||||
@ -686,8 +690,9 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
@ -695,28 +700,60 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
char *cipher;
|
||||
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_auditor_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_asprintf (&config_file_expire_reserve_now,
|
||||
"test_auditor_api_expire_reserve_now-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (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_auditor_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_asprintf (&config_file_expire_reserve_now,
|
||||
"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 TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014-2023 Taler Systems SA
|
||||
Copyright (C) 2014-2018 Taler Systems SA
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
@ -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-rsa.conf"
|
||||
#define CONFIG_FILE "test_auditor_api.conf"
|
||||
|
||||
static struct TALER_AUDITOR_Handle *ah;
|
||||
|
||||
@ -51,7 +51,6 @@ static int global_ret;
|
||||
|
||||
static struct GNUNET_SCHEDULER_Task *tt;
|
||||
|
||||
|
||||
static void
|
||||
do_shutdown (void *cls)
|
||||
{
|
||||
@ -149,16 +148,15 @@ 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;
|
||||
}
|
||||
global_ret = TALER_TESTING_wait_httpd_ready ("http://localhost:8083/");
|
||||
if (0 != global_ret)
|
||||
if (0 != TALER_TESTING_wait_auditor_ready ("http://localhost:8083/"))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to launch `taler-auditor-httpd`\n");
|
||||
@ -168,8 +166,7 @@ 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;
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "taler_testing_lib.h"
|
||||
|
||||
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank.conf"
|
||||
|
||||
#define CONFIG_FILE_NEXUS "test_bank_api_nexus.conf"
|
||||
|
||||
|
||||
@ -42,19 +41,28 @@
|
||||
* Configuration file. It changes based on
|
||||
* whether Nexus or Fakebank are used.
|
||||
*/
|
||||
static const char *cfgfile;
|
||||
const char *cfgfile;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Which bank is the test running against?
|
||||
* Set up at runtime.
|
||||
* Flag indicating whether the test is running against the
|
||||
* Fakebank. Set up at runtime.
|
||||
*/
|
||||
static enum TALER_TESTING_BankSystem bs;
|
||||
static int with_fakebank;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -67,36 +75,20 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
const char *ssoptions;
|
||||
|
||||
(void) cls;
|
||||
switch (bs)
|
||||
{
|
||||
case TALER_TESTING_BS_FAKEBANK:
|
||||
ssoptions = "-f";
|
||||
break;
|
||||
case TALER_TESTING_BS_IBAN:
|
||||
ssoptions = "-ns";
|
||||
break;
|
||||
}
|
||||
memset (&wtid,
|
||||
42,
|
||||
sizeof (wtid));
|
||||
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",
|
||||
&cred.ba,
|
||||
&bc.exchange_auth,
|
||||
NULL,
|
||||
1),
|
||||
TALER_TESTING_cmd_admin_add_incoming ("credit-1",
|
||||
"EUR:5.01",
|
||||
&cred.ba,
|
||||
cred.user42_payto),
|
||||
"KUDOS:5.01",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto),
|
||||
/**
|
||||
* This CMD doesn't care about the HTTP response code; that's
|
||||
* because Fakebank and euFin behaves differently when a reserve
|
||||
@ -104,9 +96,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",
|
||||
"EUR:2.01",
|
||||
&cred.ba,
|
||||
cred.user42_payto,
|
||||
"KUDOS:2.01",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto,
|
||||
"credit-1",
|
||||
-1),
|
||||
TALER_TESTING_cmd_sleep ("Waiting 4s for 'credit-1' to settle",
|
||||
@ -116,28 +108,28 @@ run (void *cls,
|
||||
* reserve public key didn't make it to the exchange.
|
||||
*/
|
||||
TALER_TESTING_cmd_bank_credits ("history-1c",
|
||||
&cred.ba,
|
||||
&bc.exchange_auth,
|
||||
NULL,
|
||||
5),
|
||||
TALER_TESTING_cmd_bank_debits ("history-1d",
|
||||
&cred.ba,
|
||||
&bc.exchange_auth,
|
||||
NULL,
|
||||
5),
|
||||
TALER_TESTING_cmd_admin_add_incoming ("credit-2",
|
||||
"EUR:3.21",
|
||||
&cred.ba,
|
||||
cred.user42_payto),
|
||||
"KUDOS:3.21",
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_transfer ("debit-1",
|
||||
"EUR:3.22",
|
||||
&cred.ba,
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto,
|
||||
"KUDOS:3.22",
|
||||
&bc.exchange_auth,
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto,
|
||||
&wtid,
|
||||
"http://exchange.example.com/"),
|
||||
|
||||
TALER_TESTING_cmd_sleep ("Waiting 5s for 'debit-1' to settle",
|
||||
5),
|
||||
(bs == TALER_TESTING_BS_IBAN)
|
||||
with_libeufin
|
||||
? TALER_TESTING_cmd_nexus_fetch_transactions (
|
||||
"fetch-transactions-at-nexus",
|
||||
"exchange", /* from taler-nexus-prepare */
|
||||
@ -147,7 +139,7 @@ run (void *cls,
|
||||
: TALER_TESTING_cmd_sleep ("nop",
|
||||
0),
|
||||
TALER_TESTING_cmd_bank_debits ("history-2b",
|
||||
&cred.ba,
|
||||
&bc.exchange_auth,
|
||||
NULL,
|
||||
5),
|
||||
TALER_TESTING_cmd_end ()
|
||||
@ -155,44 +147,116 @@ run (void *cls,
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Bank serves at `%s'\n",
|
||||
cred.ba.wire_gateway_url);
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
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
|
||||
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;
|
||||
if (TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_fakebank"))
|
||||
(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)
|
||||
{
|
||||
bs = TALER_TESTING_BS_FAKEBANK;
|
||||
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
||||
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 (TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_nexus"))
|
||||
else if (GNUNET_YES == TALER_TESTING_has_in_name (argv[0],
|
||||
"_with_nexus"))
|
||||
{
|
||||
bs = TALER_TESTING_BS_IBAN;
|
||||
TALER_LOG_DEBUG ("Running with Nexus.\n");
|
||||
with_libeufin = GNUNET_YES;
|
||||
cfgfile = CONFIG_FILE_NEXUS;
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_libeufin (CONFIG_FILE_NEXUS,
|
||||
GNUNET_YES,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
{
|
||||
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 specified. */
|
||||
GNUNET_break (0);
|
||||
/* no bank service was ever invoked. */
|
||||
return 77;
|
||||
}
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
cfgfile,
|
||||
"exchange-account-2",
|
||||
bs,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
# 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
|
@ -1,14 +1,21 @@
|
||||
# This file is in the public domain.
|
||||
@INLINE@ test_bank_api.conf
|
||||
|
||||
[exchange-account-1]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost:8082/1?receiver-name=1"
|
||||
[taler]
|
||||
currency = KUDOS
|
||||
|
||||
[exchange-account-2]
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost:8082/2?receiver-name=2"
|
||||
PAYTO_URI = "payto://x-taler-bank/localhost/2?receiver-name=2"
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = "http://localhost:8082/2/"
|
||||
WIRE_GATEWAY_URL = "http://localhost:8081/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/"
|
||||
|
@ -1,15 +1,12 @@
|
||||
# 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:8082"
|
||||
DESTINATION_BASE_URL = "http://localhost:8081"
|
||||
|
||||
# Control port for TCP
|
||||
# PORT = 8889
|
||||
@ -21,3 +18,20 @@ 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/"
|
||||
|
@ -1,19 +1,21 @@
|
||||
# This file is in the public domain.
|
||||
@INLINE@ test_bank_api.conf
|
||||
|
||||
[taler]
|
||||
currency = TESTKUDOS
|
||||
|
||||
[exchange-account-2]
|
||||
PAYTO_URI = payto://iban/BIC/ES9121000418450200051332?receiver-name=Exchange
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = http://localhost:8082/facades/test-facade/taler-wire-gateway/
|
||||
WIRE_GATEWAY_URL = http://localhost:5001/facades/my-facade/taler-wire-gateway/
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = exchange
|
||||
PASSWORD = x
|
||||
|
||||
[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"
|
||||
[bank]
|
||||
# not (!) used by the nexus, only by the helper
|
||||
# check to make sure the port is free for Nexus.
|
||||
HTTP_PORT = 5001
|
||||
|
||||
[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"
|
||||
[auditor]
|
||||
BASE_URL = "http://localhost:8083/"
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014-2023 Taler Systems SA
|
||||
Copyright (C) 2014-2018 Taler Systems SA
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
@ -17,7 +17,7 @@
|
||||
<http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file testing/test_bank_api_twisted.c
|
||||
* @file testing/test_bank_api_with_fakebank_twisted.c
|
||||
* @author Marcello Stanisci
|
||||
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
||||
* @author Christian Grothoff
|
||||
@ -42,20 +42,14 @@
|
||||
#define CONFIG_FILE_FAKEBANK "test_bank_api_fakebank_twisted.conf"
|
||||
|
||||
/**
|
||||
* Configuration file we use.
|
||||
* True when the test runs against Fakebank.
|
||||
*/
|
||||
static const char *cfgfile;
|
||||
static int with_fakebank;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
|
||||
/**
|
||||
* Which bank is the test running against?
|
||||
* Set up at runtime.
|
||||
*/
|
||||
static enum TALER_TESTING_BankSystem bs;
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* (real) Twister URL. Used at startup time to check if it runs.
|
||||
@ -67,6 +61,11 @@ 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
|
||||
@ -79,118 +78,156 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_WireTransferIdentifierRawP wtid;
|
||||
/* Authentication data to route our commands through twister. */
|
||||
/* 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,
|
||||
&cred.ba,
|
||||
&bc.exchange_auth,
|
||||
sizeof (struct TALER_BANK_AuthenticationData));
|
||||
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);
|
||||
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/";
|
||||
|
||||
{
|
||||
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",
|
||||
cfgfile),
|
||||
TALER_TESTING_cmd_transfer_retry (
|
||||
TALER_TESTING_cmd_transfer ("debit-1",
|
||||
"EUR:3.22",
|
||||
&exchange_auth_twisted,
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto,
|
||||
&wtid,
|
||||
"http://exchange.example.com/")),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
/* Test retrying transfer after failure. */
|
||||
TALER_TESTING_cmd_malform_response ("malform-transfer",
|
||||
CONFIG_FILE_FAKEBANK),
|
||||
TALER_TESTING_cmd_transfer_retry (
|
||||
TALER_TESTING_cmd_transfer ("debit-1",
|
||||
"KUDOS:3.22",
|
||||
&exchange_auth_twisted,
|
||||
bc.exchange_payto,
|
||||
bc.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[in] process process to purge.
|
||||
* @param 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;
|
||||
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; */
|
||||
}
|
||||
/* 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",
|
||||
"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)))
|
||||
{
|
||||
/* no bank service was specified. */
|
||||
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,
|
||||
"exchange-account-2",
|
||||
&bc))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
GNUNET_free (twister_url);
|
||||
return 77;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GNUNET_assert (0);
|
||||
}
|
||||
|
||||
/* 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",
|
||||
cfgfile,
|
||||
"exchange-account-2",
|
||||
bs,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
sleep (5);
|
||||
ret = GNUNET_CONFIGURATION_parse_and_run (cfgfilename,
|
||||
&setup_with_cfg,
|
||||
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);
|
||||
return ret;
|
||||
if (GNUNET_OK == ret)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,120 @@
|
||||
# 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
|
||||
|
@ -1,4 +1,130 @@
|
||||
# This file is in the public domain.
|
||||
#
|
||||
@INLINE@ test_exchange_api.conf
|
||||
@INLINE@ coins-rsa.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
|
||||
|
@ -49,9 +49,14 @@ static char *config_file;
|
||||
static char *config_file_expire_reserve_now;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Some tests behave differently when using CS as we cannot
|
||||
@ -92,8 +97,8 @@ static bool uses_cs;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
|
||||
/**
|
||||
* Main function that will tell the interpreter what commands to
|
||||
@ -137,8 +142,8 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
||||
"EUR:6.02",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -196,7 +201,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-simple",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -214,7 +219,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure",
|
||||
"withdraw-coin-1x",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -227,7 +232,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-double-1",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -241,7 +246,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-double-1",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -252,7 +257,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-double-2",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -277,8 +282,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"refresh-create-reserve-1"),
|
||||
/**
|
||||
* Make previous command effective.
|
||||
@ -299,7 +304,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial",
|
||||
"refresh-withdraw-coin-1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -336,7 +341,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a",
|
||||
"refresh-reveal-1-idempotency",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -347,7 +352,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b",
|
||||
"refresh-reveal-1",
|
||||
3,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.1",
|
||||
@ -385,8 +390,8 @@ run (void *cls,
|
||||
"EUR:6.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age",
|
||||
"EUR:6.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-age"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -412,7 +417,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-simple-age",
|
||||
"withdraw-coin-age-1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:4.99",
|
||||
@ -459,53 +464,53 @@ run (void *cls,
|
||||
* Check all the transfers took place.
|
||||
*/
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:4.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:4.97",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.08",
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.08",
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
bc.exchange_payto,
|
||||
bc.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",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.98",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto)
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto)
|
||||
: TALER_TESTING_cmd_sleep ("dummy",
|
||||
0),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||
@ -539,8 +544,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-create-reserve-unaggregated",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-unaggregated"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated",
|
||||
@ -551,7 +556,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-unaggregated",
|
||||
"withdraw-coin-unaggregated",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_relative_multiply (
|
||||
GNUNET_TIME_UNIT_YEARS,
|
||||
@ -573,8 +578,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"ck-refresh-create-reserve-age-1",
|
||||
"EUR:6.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"refresh-create-reserve-age-1"),
|
||||
/**
|
||||
* Make previous command effective.
|
||||
@ -595,7 +600,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age",
|
||||
"refresh-withdraw-coin-age-1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -632,7 +637,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a",
|
||||
"refresh-reveal-age-1-idempotency",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -643,7 +648,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b",
|
||||
"refresh-reveal-age-1",
|
||||
3,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.1",
|
||||
@ -675,8 +680,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-create-reserve-aggtest",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-aggtest"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-aggtest"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest",
|
||||
@ -687,7 +692,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-aggtest-1",
|
||||
"withdraw-coin-aggtest",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:2",
|
||||
@ -695,7 +700,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2",
|
||||
"withdraw-coin-aggtest",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:2",
|
||||
@ -703,10 +708,10 @@ run (void *cls,
|
||||
"deposit-aggtest-1"),
|
||||
CMD_EXEC_AGGREGATOR ("aggregation-aggtest"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:3.97",
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -720,8 +725,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-r1"),
|
||||
/**
|
||||
* Run wire-watch to trigger the reserve creation.
|
||||
@ -740,7 +745,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-1",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:5",
|
||||
@ -774,7 +779,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:4",
|
||||
@ -791,7 +796,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-2",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:4.99",
|
||||
@ -805,10 +810,10 @@ run (void *cls,
|
||||
* Check that deposit did run.
|
||||
*/
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:4.97",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
/**
|
||||
* Run failing refund, as past deadline & aggregation.
|
||||
*/
|
||||
@ -825,8 +830,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-rb"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-rb"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb",
|
||||
@ -837,7 +842,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-refund-1b",
|
||||
"withdraw-coin-rb",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -871,8 +876,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"recoup-create-reserve-1-check",
|
||||
"EUR:15.02",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"recoup-create-reserve-1"),
|
||||
/**
|
||||
* Run wire-watch to trigger the reserve creation.
|
||||
@ -1001,8 +1006,8 @@ run (void *cls,
|
||||
"EUR:5.01"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"short-lived-reserve"),
|
||||
TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation",
|
||||
config_file_expire_reserve_now),
|
||||
@ -1024,10 +1029,10 @@ run (void *cls,
|
||||
0, /* age restriction off */
|
||||
MHD_HTTP_CONFLICT),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:5",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.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
|
||||
@ -1037,8 +1042,8 @@ run (void *cls,
|
||||
"EUR:2.02"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2",
|
||||
"EUR:2.02",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"recoup-create-reserve-2"),
|
||||
/* Make previous command effective. */
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-5"),
|
||||
@ -1057,7 +1062,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-partial",
|
||||
"recoup-withdraw-coin-2a",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.5",
|
||||
@ -1085,7 +1090,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-revoked",
|
||||
"recoup-withdraw-coin-2b",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -1097,7 +1102,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup",
|
||||
"recoup-withdraw-coin-2a",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:0.5",
|
||||
@ -1108,8 +1113,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-recoup-create-reserve-3",
|
||||
"EUR:1.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"recoup-create-reserve-3"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-6"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked",
|
||||
@ -1139,8 +1144,8 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1",
|
||||
"EUR:6.03",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-batch-reserve-1"),
|
||||
/*
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -1179,7 +1184,7 @@ run (void *cls,
|
||||
* Spend the coins.
|
||||
*/
|
||||
TALER_TESTING_cmd_batch_deposit ("batch-deposit-1",
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
MHD_HTTP_OK,
|
||||
@ -1227,18 +1232,33 @@ run (void *cls,
|
||||
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
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"),
|
||||
/* 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",
|
||||
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),
|
||||
TALER_TESTING_cmd_batch ("wire",
|
||||
wire),
|
||||
TALER_TESTING_cmd_batch ("withdraw",
|
||||
@ -1271,8 +1291,9 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1281,30 +1302,62 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
char *cipher;
|
||||
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
uses_cs = (0 == strcmp (cipher,
|
||||
"cs"));
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_asprintf (&config_file_expire_reserve_now,
|
||||
"test_exchange_api_expire_reserve_now-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (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);
|
||||
uses_cs = (0 == strcmp (cipher, "cs"));
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_asprintf (&config_file_expire_reserve_now,
|
||||
"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 TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,64 +2,30 @@
|
||||
#
|
||||
|
||||
[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]
|
||||
@ -82,6 +48,68 @@ 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"
|
||||
|
@ -1 +0,0 @@
|
||||
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>
|
@ -43,9 +43,9 @@ lished
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
|
||||
/**
|
||||
@ -59,19 +59,27 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
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 ("initial-/keys"),
|
||||
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",
|
||||
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),
|
||||
TALER_TESTING_cmd_sleep ("sleep",
|
||||
6 /* seconds */),
|
||||
TALER_TESTING_cmd_check_keys ("check-keys-1"),
|
||||
TALER_TESTING_cmd_check_keys ("check-keys-1",
|
||||
2 /* generation */),
|
||||
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",
|
||||
@ -80,7 +88,8 @@ 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"),
|
||||
TALER_TESTING_cmd_check_keys ("check-keys-after-deserialization",
|
||||
4),
|
||||
/**
|
||||
* Use one of the deserialized keys.
|
||||
*/
|
||||
@ -101,25 +110,50 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
char *cipher;
|
||||
|
||||
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);
|
||||
(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 TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,21 +3,48 @@
|
||||
[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]
|
||||
@ -28,8 +55,6 @@ 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/"
|
||||
@ -41,9 +66,11 @@ ENABLE_CREDIT = YES
|
||||
|
||||
[exchange-accountcredentials-2]
|
||||
WIRE_GATEWAY_URL = "http://localhost:9082/2/"
|
||||
WIRE_GATEWAY_AUTH_METHOD = basic
|
||||
USERNAME = Exchange
|
||||
PASSWORD = x
|
||||
|
||||
# Authentication information for basic authentication
|
||||
TALER_BANK_AUTH_METHOD = "basic"
|
||||
USERNAME = user
|
||||
PASSWORD = pass
|
||||
|
||||
[bank]
|
||||
HTTP_PORT=8082
|
||||
|
@ -44,9 +44,9 @@
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
|
||||
/**
|
||||
@ -60,21 +60,22 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
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"),
|
||||
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),
|
||||
/* Causes GET /keys?last_denom_issue=0 */
|
||||
TALER_TESTING_cmd_check_keys_with_last_denom ("second-download",
|
||||
1,
|
||||
"zero"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -89,25 +90,50 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
char *cipher;
|
||||
|
||||
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);
|
||||
(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 TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014--2023 Taler Systems SA
|
||||
Copyright (C) 2014--2020 Taler Systems SA
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
@ -42,9 +42,14 @@
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
|
||||
/**
|
||||
@ -58,18 +63,6 @@ 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),
|
||||
@ -79,20 +72,20 @@ run (void *cls,
|
||||
false),
|
||||
TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
|
||||
config_file),
|
||||
#endif
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
/**
|
||||
* 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",
|
||||
&cred.ba,
|
||||
cred.user42_payto),
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
||||
"EUR:10.02",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
/**
|
||||
* Run wire-watch to trigger the reserve creation.
|
||||
@ -116,7 +109,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-partial",
|
||||
"withdraw-revocation-coin-1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -125,7 +118,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_deposit ("deposit-full",
|
||||
"withdraw-revocation-coin-2",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -248,8 +241,9 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run (is,
|
||||
revocation);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
revocation,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
@ -257,25 +251,56 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
char *cipher;
|
||||
|
||||
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);
|
||||
(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 TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,16 +43,21 @@
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -87,8 +92,8 @@ CMD_TRANSFER_TO_EXCHANGE (const char *label,
|
||||
{
|
||||
return TALER_TESTING_cmd_admin_add_incoming (label,
|
||||
amount,
|
||||
&cred.ba,
|
||||
cred.user42_payto);
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto);
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +132,7 @@ run (void *cls,
|
||||
"refresh-deposit-partial",
|
||||
"refresh-withdraw-coin",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:1",
|
||||
@ -173,7 +178,7 @@ run (void *cls,
|
||||
"deposit-refund-1",
|
||||
"withdraw-coin-r1",
|
||||
0,
|
||||
cred.user42_payto,
|
||||
bc.user42_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}",
|
||||
GNUNET_TIME_UNIT_MINUTES,
|
||||
"EUR:5",
|
||||
@ -196,7 +201,7 @@ run (void *cls,
|
||||
"deposit-refund-to-fail",
|
||||
"withdraw-coin-r1",
|
||||
0, /* coin index. */
|
||||
cred.user42_payto,
|
||||
bc.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. */
|
||||
@ -246,17 +251,17 @@ run (void *cls,
|
||||
#endif
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
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_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_batch (
|
||||
"refresh-reveal-409-conflict",
|
||||
refresh_409_conflict),
|
||||
@ -271,15 +276,16 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Kill, wait, and destroy convenience function.
|
||||
*
|
||||
* @param[in] process process to purge.
|
||||
* @param process process to purge.
|
||||
*/
|
||||
static void
|
||||
purge_process (struct GNUNET_OS_Process *process)
|
||||
@ -295,37 +301,57 @@ 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);
|
||||
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,
|
||||
"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))
|
||||
{
|
||||
char *cipher;
|
||||
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);
|
||||
purge_process (twisterd);
|
||||
GNUNET_free (twister_url);
|
||||
|
||||
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 != ret)
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
GNUNET_break (0);
|
||||
return 1;
|
||||
}
|
||||
/* 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",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
purge_process (twisterd);
|
||||
GNUNET_free (twister_url);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2020-2023 Taler Systems SA
|
||||
Copyright (C) 2020-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
|
||||
@ -35,10 +35,16 @@
|
||||
*/
|
||||
static char *config_file;
|
||||
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
|
||||
/**
|
||||
@ -52,20 +58,10 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
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,
|
||||
/* 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,
|
||||
false),
|
||||
TALER_TESTING_cmd_auditor_add ("add-auditor-BAD-SIG",
|
||||
MHD_HTTP_FORBIDDEN,
|
||||
@ -145,13 +141,15 @@ 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"),
|
||||
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
|
||||
1),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
@ -159,25 +157,56 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
char *cipher;
|
||||
|
||||
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);
|
||||
(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 TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,9 +42,14 @@
|
||||
static char *config_file;
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Some tests behave differently when using CS as we cannot
|
||||
@ -85,8 +90,8 @@ static bool uses_cs;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
|
||||
/**
|
||||
* Main function that will tell the interpreter what commands to
|
||||
@ -117,13 +122,13 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1",
|
||||
"EUR:5.04",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-2",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-2"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -375,15 +380,15 @@ run (void *cls,
|
||||
"EUR:1.04"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-100",
|
||||
"EUR:1.04",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.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",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-101"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-100"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-100",
|
||||
@ -495,18 +500,32 @@ run (void *cls,
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
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"),
|
||||
/* 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",
|
||||
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),
|
||||
TALER_TESTING_cmd_batch ("withdraw",
|
||||
withdraw),
|
||||
TALER_TESTING_cmd_batch ("push",
|
||||
@ -522,8 +541,9 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
@ -531,26 +551,59 @@ int
|
||||
main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
char *cipher;
|
||||
char *cipher;
|
||||
|
||||
cipher = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
|
||||
GNUNET_assert (NULL != cipher);
|
||||
uses_cs = (0 == strcmp (cipher, "cs"));
|
||||
GNUNET_asprintf (&config_file,
|
||||
"test_exchange_api-%s.conf",
|
||||
cipher);
|
||||
GNUNET_free (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);
|
||||
uses_cs = (0 == strcmp (cipher, "cs"));
|
||||
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 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 TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_file,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,10 +41,14 @@
|
||||
#define CONFIG_FILE "test_kyc_api.conf"
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Exchange configuration data.
|
||||
*/
|
||||
struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Execute the taler-exchange-wirewatch command with
|
||||
@ -75,8 +79,8 @@ struct TALER_TESTING_Credentials cred;
|
||||
*/
|
||||
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
|
||||
TALER_TESTING_cmd_admin_add_incoming (label, amount, \
|
||||
&cred.ba, \
|
||||
cred.user42_payto)
|
||||
&bc.exchange_auth, \
|
||||
bc.user42_payto)
|
||||
|
||||
/**
|
||||
* Main function that will tell the interpreter what commands to
|
||||
@ -94,8 +98,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"check-create-reserve-1",
|
||||
"EUR:15.02",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"create-reserve-1"),
|
||||
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-no-kyc",
|
||||
@ -146,7 +150,7 @@ run (void *cls,
|
||||
"deposit-simple",
|
||||
"withdraw-coin-1",
|
||||
0,
|
||||
cred.user43_payto,
|
||||
bc.user43_payto,
|
||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
"EUR:5",
|
||||
@ -192,10 +196,10 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-after-kyc"),
|
||||
TALER_TESTING_cmd_check_bank_transfer (
|
||||
"check_bank_transfer-499c",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:4.98",
|
||||
cred.exchange_payto,
|
||||
cred.user43_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user43_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
@ -251,13 +255,13 @@ run (void *cls,
|
||||
MHD_HTTP_OK),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-1",
|
||||
"EUR:5.04",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"p2p_create-reserve-1"),
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer ("p2p_check-create-reserve-2",
|
||||
"EUR:5.01",
|
||||
cred.user42_payto,
|
||||
cred.exchange_payto,
|
||||
bc.user42_payto,
|
||||
bc.exchange_payto,
|
||||
"p2p_create-reserve-2"),
|
||||
/**
|
||||
* Make a reserve exist, according to the previous
|
||||
@ -514,18 +518,29 @@ run (void *cls,
|
||||
};
|
||||
|
||||
struct TALER_TESTING_Command commands[] = {
|
||||
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_exec_offline_sign_fees ("offline-sign-fees",
|
||||
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),
|
||||
TALER_TESTING_cmd_batch ("withdraw",
|
||||
withdraw),
|
||||
TALER_TESTING_cmd_batch ("spend",
|
||||
@ -548,8 +563,9 @@ run (void *cls,
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run (is,
|
||||
commands);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
commands,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
@ -558,14 +574,48 @@ main (int argc,
|
||||
char *const *argv)
|
||||
{
|
||||
(void) argc;
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
CONFIG_FILE,
|
||||
"exchange-account-2",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
(void) argv;
|
||||
/* These environment variables get in the way... */
|
||||
unsetenv ("XDG_DATA_HOME");
|
||||
unsetenv ("XDG_CONFIG_HOME");
|
||||
GNUNET_log_setup ("test-kyc-api",
|
||||
"INFO",
|
||||
NULL);
|
||||
/* 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 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,51 @@
|
||||
|
||||
# This file is in the public domain.
|
||||
#
|
||||
@INLINE@ coins-rsa.conf
|
||||
@INLINE@ test_exchange_api.conf
|
||||
[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/"
|
||||
|
||||
|
||||
[kyc-provider-test-oauth2]
|
||||
COST = 0
|
||||
@ -39,3 +83,157 @@ 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
|
@ -31,9 +31,24 @@
|
||||
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Helper structure to keep exchange configuration values.
|
||||
*/
|
||||
struct TALER_TESTING_Credentials cred;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Name of the configuration file to use.
|
||||
@ -55,6 +70,24 @@ 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.
|
||||
*/
|
||||
@ -63,13 +96,11 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command all[] = {
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-1"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_filename,
|
||||
"-e",
|
||||
NULL),
|
||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||
config_filename,
|
||||
"EUR:0.01",
|
||||
"EUR:0.01"),
|
||||
// check no aggregation happens on a empty database
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty-db",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-on-start"),
|
||||
@ -77,7 +108,7 @@ run (void *cls,
|
||||
/* check aggregation happens on the simplest case:
|
||||
one deposit into the database. */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-1",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -88,15 +119,15 @@ run (void *cls,
|
||||
config_filename),
|
||||
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.89",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.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",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -105,7 +136,7 @@ run (void *cls,
|
||||
"EUR:0.1"),
|
||||
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-2b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -117,15 +148,15 @@ run (void *cls,
|
||||
config_filename),
|
||||
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-2",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:1.79",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.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",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
"4",
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -133,7 +164,7 @@ run (void *cls,
|
||||
"EUR:1",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
"5",
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -141,7 +172,7 @@ run (void *cls,
|
||||
"EUR:1",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-3c",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"alice",
|
||||
"4",
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -152,25 +183,25 @@ run (void *cls,
|
||||
config_filename),
|
||||
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3a",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.89",
|
||||
cred.exchange_payto,
|
||||
bc.exchange_payto,
|
||||
"payto://x-taler-bank/localhost/4?receiver-name=4"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3b",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.89",
|
||||
cred.exchange_payto,
|
||||
bc.exchange_payto,
|
||||
"payto://x-taler-bank/localhost/4?receiver-name=4"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-3c",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.89",
|
||||
cred.exchange_payto,
|
||||
bc.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",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -180,7 +211,7 @@ run (void *cls,
|
||||
"EUR:0.2",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-4b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -199,14 +230,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-4-delayed",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-4",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.19",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
|
||||
// test picking all deposits at earliest deadline
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-5a",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -217,7 +248,7 @@ run (void *cls,
|
||||
"EUR:0.1"),
|
||||
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-5b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -236,13 +267,13 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-5-delayed",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-5",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.19",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
/* Test NEVER running 'tiny' unless they make up minimum unit */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6a",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -254,7 +285,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-6a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -262,7 +293,7 @@ run (void *cls,
|
||||
"EUR:0.102",
|
||||
"EUR:0.1"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6c",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -274,7 +305,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-6c-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6d",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -286,7 +317,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-6d-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-6e",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -296,14 +327,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-6e",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-6",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.01",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
|
||||
/* Test profiteering if wire deadline is short */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7a",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -315,7 +346,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-7a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -325,14 +356,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-profit",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.01",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
|
||||
/* Now check profit was actually taken */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-7c",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -342,14 +373,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-7-loss",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-7",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.01",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
|
||||
/* Test that aggregation would happen fully if wire deadline is long */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8a",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -363,7 +394,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-8a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -379,7 +410,7 @@ run (void *cls,
|
||||
|
||||
/* now trigger aggregate with large transaction and short deadline */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-8c",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -389,14 +420,14 @@ run (void *cls,
|
||||
CMD_EXEC_AGGREGATOR ("run-aggregator-deposit-8",
|
||||
config_filename),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-8",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.03",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
|
||||
/* Test aggregation with fees and rounding profits. */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9a",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -410,7 +441,7 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_empty (
|
||||
"expect-empty-transactions-after-9a-tiny"),
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9b",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -426,7 +457,7 @@ run (void *cls,
|
||||
|
||||
/* now trigger aggregate with large transaction and short deadline */
|
||||
TALER_TESTING_cmd_insert_deposit ("do-deposit-9c",
|
||||
cred.cfg,
|
||||
&dbc,
|
||||
"bob",
|
||||
USER42_ACCOUNT,
|
||||
GNUNET_TIME_timestamp_get (),
|
||||
@ -437,15 +468,49 @@ 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",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:0.01",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
TALER_TESTING_run (is,
|
||||
all);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -454,6 +519,7 @@ main (int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
const char *plugin_name;
|
||||
char *testname;
|
||||
|
||||
if (NULL == (plugin_name = strrchr (argv[0], (int) '-')))
|
||||
{
|
||||
@ -461,17 +527,52 @@ main (int argc,
|
||||
return -1;
|
||||
}
|
||||
plugin_name++;
|
||||
(void) GNUNET_asprintf (&config_filename,
|
||||
"test-taler-exchange-aggregator-%s.conf",
|
||||
(void) GNUNET_asprintf (&testname,
|
||||
"test-taler-exchange-aggregator-%s",
|
||||
plugin_name);
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_filename,
|
||||
"exchange-account-1",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
(void) GNUNET_asprintf (&config_filename,
|
||||
"%s.conf",
|
||||
testname);
|
||||
|
||||
GNUNET_log_setup ("test_taler_exchange_aggregator",
|
||||
"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,
|
||||
"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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,9 +34,14 @@
|
||||
|
||||
|
||||
/**
|
||||
* Our credentials.
|
||||
* Bank configuration data.
|
||||
*/
|
||||
static struct TALER_TESTING_Credentials cred;
|
||||
static struct TALER_TESTING_BankConfiguration bc;
|
||||
|
||||
/**
|
||||
* Helper structure to keep exchange configuration values.
|
||||
*/
|
||||
static struct TALER_TESTING_ExchangeConfiguration ec;
|
||||
|
||||
/**
|
||||
* Name of the configuration file to use.
|
||||
@ -61,8 +66,8 @@ transfer_to_exchange (const char *label,
|
||||
{
|
||||
return TALER_TESTING_cmd_admin_add_incoming (label,
|
||||
amount,
|
||||
&cred.ba,
|
||||
cred.user42_payto);
|
||||
&bc.exchange_auth,
|
||||
bc.user42_payto);
|
||||
}
|
||||
|
||||
|
||||
@ -77,19 +82,21 @@ run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct TALER_TESTING_Command all[] = {
|
||||
TALER_TESTING_cmd_run_fakebank ("run-fakebank",
|
||||
cred.cfg,
|
||||
"exchange-account-1"),
|
||||
TALER_TESTING_cmd_system_start ("start-taler",
|
||||
config_filename,
|
||||
"-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_exec_offline_sign_fees ("offline-sign-fees",
|
||||
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),
|
||||
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",
|
||||
@ -104,8 +111,8 @@ run (void *cls,
|
||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||
"clear-good-transfer-to-the-exchange",
|
||||
"EUR:5",
|
||||
cred.user42_payto, // debit
|
||||
cred.exchange_payto, // credit
|
||||
bc.user42_payto, // debit
|
||||
bc.exchange_payto, // credit
|
||||
"run-transfer-good-to-exchange"),
|
||||
|
||||
TALER_TESTING_cmd_exec_closer ("run-closer-non-expired-reserve",
|
||||
@ -128,17 +135,18 @@ run (void *cls,
|
||||
|
||||
CMD_EXEC_AGGREGATOR ("run-closer-on-expired-reserve"),
|
||||
TALER_TESTING_cmd_check_bank_transfer ("expect-deposit-1",
|
||||
cred.exchange_url,
|
||||
ec.exchange_url,
|
||||
"EUR:4.99",
|
||||
cred.exchange_payto,
|
||||
cred.user42_payto),
|
||||
bc.exchange_payto,
|
||||
bc.user42_payto),
|
||||
TALER_TESTING_cmd_check_bank_empty ("expect-empty-transactions-2"),
|
||||
TALER_TESTING_cmd_end ()
|
||||
};
|
||||
|
||||
(void) cls;
|
||||
TALER_TESTING_run (is,
|
||||
all);
|
||||
TALER_TESTING_run_with_fakebank (is,
|
||||
all,
|
||||
bc.exchange_auth.wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
@ -146,29 +154,69 @@ int
|
||||
main (int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
(void) argc;
|
||||
{
|
||||
const char *plugin_name;
|
||||
const char *plugin_name;
|
||||
|
||||
plugin_name = strrchr (argv[0], (int) '-');
|
||||
if (NULL == plugin_name)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return -1;
|
||||
}
|
||||
plugin_name++;
|
||||
GNUNET_asprintf (&config_filename,
|
||||
"test-taler-exchange-wirewatch-%s.conf",
|
||||
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) '-')))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return -1;
|
||||
}
|
||||
return TALER_TESTING_main (argv,
|
||||
"INFO",
|
||||
config_filename,
|
||||
"exchange-account-1",
|
||||
TALER_TESTING_BS_FAKEBANK,
|
||||
&cred,
|
||||
&run,
|
||||
NULL);
|
||||
plugin_name++;
|
||||
{
|
||||
char *testname;
|
||||
|
||||
GNUNET_asprintf (&testname,
|
||||
"test-taler-exchange-wirewatch-%s",
|
||||
plugin_name);
|
||||
GNUNET_asprintf (&config_filename,
|
||||
"%s.conf",
|
||||
testname);
|
||||
GNUNET_free (testname);
|
||||
}
|
||||
/* 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,
|
||||
"exchange-account-1",
|
||||
&bc))
|
||||
return 77;
|
||||
|
||||
return (GNUNET_OK ==
|
||||
TALER_TESTING_setup_with_exchange (&run,
|
||||
NULL,
|
||||
config_filename)) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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,8 +75,16 @@ auditor_add_cb (
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != hr->http_status)
|
||||
{
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
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);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -98,43 +106,10 @@ 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,
|
||||
@ -143,22 +118,17 @@ auditor_add_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
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,
|
||||
TALER_exchange_offline_auditor_add_sign (&is->auditor_pub,
|
||||
is->auditor_url,
|
||||
now,
|
||||
master_priv,
|
||||
&is->master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_management_enable_auditor (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
auditor_pub,
|
||||
auditor_url,
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
&is->auditor_pub,
|
||||
is->auditor_url,
|
||||
"test-case auditor", /* human-readable auditor name */
|
||||
now,
|
||||
&master_sig,
|
||||
@ -188,8 +158,10 @@ auditor_add_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_management_enable_auditor_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
}
|
||||
|
@ -80,8 +80,16 @@ denom_sig_add_cb (
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != hr->http_status)
|
||||
{
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
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);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -104,11 +112,6 @@ 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 */
|
||||
@ -117,6 +120,7 @@ auditor_add_run (void *cls,
|
||||
|
||||
denom_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||
ds->denom_ref);
|
||||
|
||||
if (NULL == denom_cmd)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -129,31 +133,6 @@ 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,
|
||||
@ -162,33 +141,28 @@ auditor_add_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
const struct TALER_MasterPublicKeyP *master_pub;
|
||||
const struct TALER_AuditorPrivateKeyP *auditor_priv;
|
||||
struct TALER_MasterPublicKeyP master_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));
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&is->master_priv.eddsa_priv,
|
||||
&master_pub.eddsa_pub);
|
||||
TALER_auditor_denom_validity_sign (
|
||||
auditor_url,
|
||||
is->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,
|
||||
auditor_priv,
|
||||
&is->auditor_priv,
|
||||
&auditor_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_add_auditor_denomination (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
&h_denom_pub,
|
||||
auditor_pub,
|
||||
&is->auditor_pub,
|
||||
&auditor_sig,
|
||||
&denom_sig_add_cb,
|
||||
ds);
|
||||
@ -216,8 +190,10 @@ auditor_add_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_add_auditor_denomination_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
}
|
||||
|
@ -76,8 +76,16 @@ auditor_del_cb (
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != hr->http_status)
|
||||
{
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
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);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (ds->is);
|
||||
@ -99,36 +107,10 @@ 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,
|
||||
@ -137,20 +119,15 @@ auditor_del_run (void *cls,
|
||||
}
|
||||
else
|
||||
{
|
||||
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,
|
||||
TALER_exchange_offline_auditor_del_sign (&is->auditor_pub,
|
||||
now,
|
||||
master_priv,
|
||||
&is->master_priv,
|
||||
&master_sig);
|
||||
}
|
||||
ds->dh = TALER_EXCHANGE_management_disable_auditor (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
auditor_pub,
|
||||
is->ctx,
|
||||
is->exchange_url,
|
||||
&is->auditor_pub,
|
||||
now,
|
||||
&master_sig,
|
||||
&auditor_del_cb,
|
||||
@ -179,8 +156,10 @@ auditor_del_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
cmd->label);
|
||||
TALER_EXCHANGE_management_disable_auditor_cancel (ds->dh);
|
||||
ds->dh = NULL;
|
||||
}
|
||||
|
@ -68,6 +68,11 @@ struct DepositConfirmationState
|
||||
*/
|
||||
struct TALER_AUDITOR_DepositConfirmationHandle *dc;
|
||||
|
||||
/**
|
||||
* Auditor connection.
|
||||
*/
|
||||
struct TALER_AUDITOR_Handle *auditor;
|
||||
|
||||
/**
|
||||
* Interpreter state.
|
||||
*/
|
||||
@ -120,7 +125,8 @@ do_retry (void *cls)
|
||||
struct DepositConfirmationState *dcs = cls;
|
||||
|
||||
dcs->retry_task = NULL;
|
||||
TALER_TESTING_touch_cmd (dcs->is);
|
||||
dcs->is->commands[dcs->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
deposit_confirmation_run (dcs,
|
||||
NULL,
|
||||
dcs->is);
|
||||
@ -160,15 +166,21 @@ deposit_confirmation_cb (void *cls,
|
||||
else
|
||||
dcs->backoff = GNUNET_TIME_randomized_backoff (dcs->backoff,
|
||||
MAX_BACKOFF);
|
||||
TALER_TESTING_inc_tries (dcs->is);
|
||||
dcs->is->commands[dcs->is->ip].num_tries++;
|
||||
dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
|
||||
&do_retry,
|
||||
dcs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
TALER_TESTING_unexpected_status (dcs->is,
|
||||
hr->http_status);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
TALER_TESTING_interpreter_next (dcs->is);
|
||||
@ -208,31 +220,10 @@ 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);
|
||||
@ -260,7 +251,7 @@ deposit_confirmation_run (void *cls,
|
||||
dcs->coin_index,
|
||||
&wire_deadline));
|
||||
GNUNET_assert (NULL != exchange_timestamp);
|
||||
keys = TALER_EXCHANGE_get_keys (exchange);
|
||||
keys = TALER_EXCHANGE_get_keys (dcs->is->exchange);
|
||||
GNUNET_assert (NULL != keys);
|
||||
spk = TALER_EXCHANGE_get_signing_key_info (keys,
|
||||
exchange_pub);
|
||||
@ -317,7 +308,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 (auditor,
|
||||
dcs->dc = TALER_AUDITOR_deposit_confirmation (dcs->auditor,
|
||||
&h_wire,
|
||||
&no_h_policy,
|
||||
&h_contract_terms,
|
||||
@ -362,8 +353,10 @@ deposit_confirmation_cleanup (void *cls,
|
||||
|
||||
if (NULL != dcs->dc)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (dcs->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
dcs->is->ip,
|
||||
cmd->label);
|
||||
TALER_AUDITOR_deposit_confirmation_cancel (dcs->dc);
|
||||
dcs->dc = NULL;
|
||||
}
|
||||
@ -378,6 +371,7 @@ 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,
|
||||
@ -386,6 +380,7 @@ 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;
|
||||
|
@ -53,6 +53,11 @@ struct ExchangesState
|
||||
*/
|
||||
struct TALER_AUDITOR_ListExchangesHandle *leh;
|
||||
|
||||
/**
|
||||
* Auditor connection.
|
||||
*/
|
||||
struct TALER_AUDITOR_Handle *auditor;
|
||||
|
||||
/**
|
||||
* Interpreter state.
|
||||
*/
|
||||
@ -110,7 +115,8 @@ do_retry (void *cls)
|
||||
struct ExchangesState *es = cls;
|
||||
|
||||
es->retry_task = NULL;
|
||||
TALER_TESTING_touch_cmd (es->is);
|
||||
es->is->commands[es->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
exchanges_run (es,
|
||||
NULL,
|
||||
es->is);
|
||||
@ -153,15 +159,24 @@ exchanges_cb (void *cls,
|
||||
else
|
||||
es->backoff = GNUNET_TIME_randomized_backoff (es->backoff,
|
||||
MAX_BACKOFF);
|
||||
TALER_TESTING_inc_tries (es->is);
|
||||
es->is->commands[es->is->ip].num_tries++;
|
||||
es->retry_task = GNUNET_SCHEDULER_add_delayed (es->backoff,
|
||||
&do_retry,
|
||||
es);
|
||||
return;
|
||||
}
|
||||
}
|
||||
TALER_TESTING_unexpected_status (es->is,
|
||||
hr->http_status);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if (NULL != es->exchange_url)
|
||||
@ -202,26 +217,13 @@ 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 (auditor,
|
||||
&exchanges_cb,
|
||||
es);
|
||||
es->leh = TALER_AUDITOR_list_exchanges
|
||||
(is->auditor,
|
||||
&exchanges_cb,
|
||||
es);
|
||||
|
||||
if (NULL == es->leh)
|
||||
{
|
||||
@ -248,8 +250,10 @@ exchanges_cleanup (void *cls,
|
||||
|
||||
if (NULL != es->leh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (es->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
es->is->ip,
|
||||
cmd->label);
|
||||
TALER_AUDITOR_list_exchanges_cancel (es->leh);
|
||||
es->leh = NULL;
|
||||
}
|
||||
@ -271,7 +275,7 @@ exchanges_cleanup (void *cls,
|
||||
* @param index index number of the traits to be returned.
|
||||
* @return #GNUNET_OK on success
|
||||
*/
|
||||
static enum GNUNET_GenericReturnValue
|
||||
static int
|
||||
exchanges_traits (void *cls,
|
||||
const void **ret,
|
||||
const char *trait,
|
||||
@ -297,11 +301,13 @@ 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;
|
||||
|
||||
{
|
||||
|
@ -180,7 +180,8 @@ do_retry (void *cls)
|
||||
struct AdminAddIncomingState *fts = cls;
|
||||
|
||||
fts->retry_task = NULL;
|
||||
TALER_TESTING_touch_cmd (fts->is);
|
||||
fts->is->commands[fts->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
admin_add_incoming_run (fts,
|
||||
NULL,
|
||||
fts->is);
|
||||
@ -278,7 +279,7 @@ confirmation_cb (void *cls,
|
||||
else
|
||||
fts->backoff = GNUNET_TIME_randomized_backoff (fts->backoff,
|
||||
MAX_BACKOFF);
|
||||
TALER_TESTING_inc_tries (fts->is);
|
||||
fts->is->commands[fts->is->ip].num_tries++;
|
||||
fts->retry_task = GNUNET_SCHEDULER_add_delayed (
|
||||
fts->backoff,
|
||||
&do_retry,
|
||||
@ -313,7 +314,6 @@ 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,6 +364,7 @@ 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),
|
||||
@ -397,8 +398,9 @@ admin_add_incoming_cleanup (void *cls,
|
||||
|
||||
if (NULL != fts->aih)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (fts->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %s did not complete\n",
|
||||
cmd->label);
|
||||
TALER_BANK_admin_add_incoming_cancel (fts->aih);
|
||||
fts->aih = NULL;
|
||||
}
|
||||
@ -437,12 +439,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),
|
||||
@ -462,14 +464,13 @@ 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),
|
||||
|
@ -82,30 +82,8 @@ 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);
|
||||
@ -131,9 +109,9 @@ check_bank_admin_transfer_run (void *cls,
|
||||
&amount))
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to parse amount `%s' at %s\n",
|
||||
"Failed to parse amount `%s' at %u\n",
|
||||
bcs->amount,
|
||||
TALER_TESTING_interpreter_get_current_label (is));
|
||||
is->ip);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
@ -144,7 +122,7 @@ check_bank_admin_transfer_run (void *cls,
|
||||
debit_payto,
|
||||
debit_account);
|
||||
if (GNUNET_OK !=
|
||||
TALER_FAKEBANK_check_credit (fakebank,
|
||||
TALER_FAKEBANK_check_credit (is->fakebank,
|
||||
&amount,
|
||||
debit_account,
|
||||
credit_account,
|
||||
|
@ -91,48 +91,26 @@ 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;
|
||||
struct TALER_FAKEBANK_Handle *fakebank;
|
||||
const char **exchange_base_url;
|
||||
const char **debit_payto;
|
||||
const char **credit_payto;
|
||||
|
||||
(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 %s\n",
|
||||
"Failed to parse amount `%s' at %u\n",
|
||||
bcs->amount,
|
||||
TALER_TESTING_interpreter_get_current_label (is));
|
||||
is->ip);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
return;
|
||||
}
|
||||
@ -167,22 +145,27 @@ 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 (fakebank,
|
||||
TALER_FAKEBANK_check_debit (is->fakebank,
|
||||
&amount,
|
||||
debit_account,
|
||||
credit_account,
|
||||
exchange_base_url,
|
||||
*exchange_base_url,
|
||||
&bcs->wtid))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -234,7 +217,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 ()
|
||||
};
|
||||
|
||||
|
@ -58,33 +58,9 @@ 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;
|
||||
{
|
||||
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))
|
||||
if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
TALER_TESTING_interpreter_fail (is);
|
||||
|
@ -82,11 +82,6 @@ struct HistoryState
|
||||
*/
|
||||
struct TALER_BANK_CreditHistoryHandle *hh;
|
||||
|
||||
/**
|
||||
* The interpreter.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Authentication data for the operation.
|
||||
*/
|
||||
@ -148,139 +143,6 @@ print_expected (struct History *h,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closure for command_cb().
|
||||
*/
|
||||
struct IteratorContext
|
||||
{
|
||||
/**
|
||||
* Array of history items to return.
|
||||
*/
|
||||
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 struct TALER_Amount *amount;
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
const char *exchange_credit_url;
|
||||
|
||||
/**
|
||||
* The following command allows us to skip over those CMDs
|
||||
* that do not offer a "row_id" trait. Such skipped CMDs are
|
||||
* not interesting for building a history.
|
||||
*/
|
||||
if ( (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_bank_row (cmd,
|
||||
&row_id)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_credit_payto_uri (cmd,
|
||||
&credit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_debit_payto_uri (cmd,
|
||||
&debit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_amount (cmd,
|
||||
&amount)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_reserve_pub (cmd,
|
||||
&reserve_pub)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_exchange_bank_account_url (
|
||||
cmd,
|
||||
&exchange_credit_url)) )
|
||||
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 != ic->row_id_start) &&
|
||||
(*(ic->row_id_start) == *row_id) &&
|
||||
(! ic->ok) )
|
||||
{
|
||||
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 (! ic->ok)
|
||||
return;
|
||||
if (0 != strcasecmp (hs->account_url,
|
||||
exchange_credit_url))
|
||||
return; // Account mismatch
|
||||
if (ic->total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
return;
|
||||
}
|
||||
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
|
||||
debit_account,
|
||||
credit_account,
|
||||
hs->account_url);
|
||||
/* found matching record, make sure we have room */
|
||||
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
|
||||
@ -294,18 +156,23 @@ command_cb (void *cls,
|
||||
* @return number of entries in @a rh.
|
||||
*/
|
||||
static unsigned int
|
||||
build_history (struct HistoryState *hs,
|
||||
build_history (struct TALER_TESTING_Interpreter *is,
|
||||
struct History **rh)
|
||||
{
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
struct IteratorContext ic = {
|
||||
.hs = hs
|
||||
};
|
||||
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)
|
||||
{
|
||||
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);
|
||||
@ -315,28 +182,131 @@ build_history (struct HistoryState *hs,
|
||||
GNUNET_assert (NULL != add_incoming_cmd);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_row (add_incoming_cmd,
|
||||
&ic.row_id_start));
|
||||
&row_id_start));
|
||||
}
|
||||
|
||||
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)
|
||||
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.
|
||||
*/
|
||||
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];
|
||||
const uint64_t *row_id;
|
||||
const char **credit_account;
|
||||
const char **debit_account;
|
||||
const struct TALER_Amount *amount;
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||
const char **exchange_credit_url;
|
||||
|
||||
/**
|
||||
* The following command allows us to skip over those CMDs
|
||||
* that do not offer a "row_id" trait. Such skipped CMDs are
|
||||
* not interesting for building a history.
|
||||
*/
|
||||
if ( (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_bank_row (cmd,
|
||||
&row_id)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_credit_payto_uri (cmd,
|
||||
&credit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_debit_payto_uri (cmd,
|
||||
&debit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_amount (cmd,
|
||||
&amount)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_reserve_pub (cmd,
|
||||
&reserve_pub)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_exchange_bank_account_url (
|
||||
cmd,
|
||||
&exchange_credit_url)) )
|
||||
continue; // 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) )
|
||||
{
|
||||
ok = GNUNET_YES;
|
||||
continue;
|
||||
}
|
||||
/**
|
||||
* 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 (0 != strcasecmp (hs->account_url,
|
||||
*exchange_credit_url))
|
||||
continue; // Account mismatch
|
||||
if (total >= GNUNET_MAX (hs->num_results,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
break;
|
||||
}
|
||||
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
|
||||
*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++;
|
||||
}
|
||||
GNUNET_assert (GNUNET_YES == ok);
|
||||
GNUNET_array_grow (h,
|
||||
total,
|
||||
pos);
|
||||
if (0 == pos)
|
||||
TALER_LOG_DEBUG ("Empty credit history computed\n");
|
||||
*rh = ic.h;
|
||||
return ic.pos;
|
||||
*rh = h;
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
@ -406,8 +376,8 @@ static void
|
||||
history_cb (void *cls,
|
||||
const struct TALER_BANK_CreditHistoryResponse *chr)
|
||||
{
|
||||
struct HistoryState *hs = cls;
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
struct TALER_TESTING_Interpreter *is = cls;
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
|
||||
hs->hh = NULL;
|
||||
switch (chr->http_status)
|
||||
@ -500,7 +470,6 @@ 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)
|
||||
{
|
||||
@ -521,16 +490,15 @@ history_run (void *cls,
|
||||
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
|
||||
(unsigned long long) row_id);
|
||||
}
|
||||
hs->total = build_history (hs,
|
||||
hs->total = build_history (is,
|
||||
&hs->h);
|
||||
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,
|
||||
hs);
|
||||
hs->hh = TALER_BANK_credit_history (is->ctx,
|
||||
&hs->auth,
|
||||
row_id,
|
||||
hs->num_results,
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
&history_cb,
|
||||
is);
|
||||
GNUNET_assert (NULL != hs->hh);
|
||||
}
|
||||
|
||||
@ -551,8 +519,7 @@ history_cleanup (void *cls,
|
||||
(void) cmd;
|
||||
if (NULL != hs->hh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (hs->is,
|
||||
cmd->label);
|
||||
TALER_LOG_WARNING ("/history/incoming did not complete\n");
|
||||
TALER_BANK_credit_history_cancel (hs->hh);
|
||||
}
|
||||
GNUNET_free (hs->account_url);
|
||||
|
@ -91,11 +91,6 @@ struct HistoryState
|
||||
*/
|
||||
struct TALER_BANK_DebitHistoryHandle *hh;
|
||||
|
||||
/**
|
||||
* Our interpreter.
|
||||
*/
|
||||
struct TALER_TESTING_Interpreter *is;
|
||||
|
||||
/**
|
||||
* Expected number of results (= rows).
|
||||
*/
|
||||
@ -151,131 +146,6 @@ print_expected (struct History *h,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closure for command_cb().
|
||||
*/
|
||||
struct IteratorContext
|
||||
{
|
||||
/**
|
||||
* Array of history items to return.
|
||||
*/
|
||||
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 *debit_account;
|
||||
const char *credit_account;
|
||||
const struct TALER_Amount *amount;
|
||||
const struct TALER_WireTransferIdentifierRawP *wtid;
|
||||
const char *exchange_base_url;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Checking if command %s is relevant for debit history\n",
|
||||
cmd->label);
|
||||
if ( (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_bank_row (cmd,
|
||||
&row_id)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_debit_payto_uri (cmd,
|
||||
&debit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_credit_payto_uri (cmd,
|
||||
&credit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_amount (cmd,
|
||||
&amount)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_wtid (cmd,
|
||||
&wtid)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_exchange_url (cmd,
|
||||
&exchange_base_url)) )
|
||||
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 != ic->row_id_start) &&
|
||||
(*(ic->row_id_start) == *row_id) &&
|
||||
(! ic->ok) )
|
||||
{
|
||||
/* Until here, nothing counted. */
|
||||
ic->ok = true;
|
||||
return;
|
||||
}
|
||||
/* when 'start' was _not_ given, then ok == GNUNET_YES */
|
||||
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");
|
||||
return;
|
||||
}
|
||||
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
|
||||
debit_account,
|
||||
credit_account,
|
||||
hs->account_url);
|
||||
/* found matching record, make sure we have room */
|
||||
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
|
||||
@ -283,25 +153,32 @@ command_cb (void *cls,
|
||||
* to be allocated, and the second to actually populate every
|
||||
* element.
|
||||
*
|
||||
* @param hs history state command context
|
||||
* @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,
|
||||
build_history (struct TALER_TESTING_Interpreter *is,
|
||||
struct History **rh)
|
||||
{
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
struct IteratorContext ic = {
|
||||
.hs = hs
|
||||
};
|
||||
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;
|
||||
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)
|
||||
{
|
||||
const struct TALER_TESTING_Command *add_incoming_cmd;
|
||||
|
||||
TALER_LOG_INFO (
|
||||
"`%s': start row given via reference `%s'\n",
|
||||
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 (
|
||||
@ -310,28 +187,124 @@ build_history (struct HistoryState *hs,
|
||||
GNUNET_assert (NULL != add_incoming_cmd);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_row (add_incoming_cmd,
|
||||
&ic.row_id_start));
|
||||
&row_id_start));
|
||||
}
|
||||
|
||||
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;
|
||||
if (0 == is->ip)
|
||||
{
|
||||
TALER_LOG_DEBUG ("Checking history at first CMD..\n");
|
||||
*rh = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 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! */
|
||||
}
|
||||
|
||||
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 struct TALER_Amount *amount;
|
||||
const struct TALER_WireTransferIdentifierRawP *wtid;
|
||||
const char **exchange_base_url;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"Checking if command %s is relevant for debit history\n",
|
||||
cmd->label);
|
||||
if ( (GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_bank_row (cmd,
|
||||
&row_id)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_debit_payto_uri (cmd,
|
||||
&debit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_credit_payto_uri (cmd,
|
||||
&credit_account)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_amount (cmd,
|
||||
&amount)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_wtid (cmd,
|
||||
&wtid)) ||
|
||||
(GNUNET_OK !=
|
||||
TALER_TESTING_get_trait_exchange_url (cmd,
|
||||
&exchange_base_url)) )
|
||||
continue; /* 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) )
|
||||
{
|
||||
/* Until here, nothing counted. */
|
||||
ok = GNUNET_YES;
|
||||
continue;
|
||||
}
|
||||
/* 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,
|
||||
-hs->num_results) )
|
||||
{
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
break;
|
||||
}
|
||||
TALER_LOG_INFO ("Found history: %s->%s for account %s\n",
|
||||
*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++;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -395,8 +368,8 @@ static void
|
||||
history_cb (void *cls,
|
||||
const struct TALER_BANK_DebitHistoryResponse *dhr)
|
||||
{
|
||||
struct HistoryState *hs = cls;
|
||||
struct TALER_TESTING_Interpreter *is = hs->is;
|
||||
struct TALER_TESTING_Interpreter *is = cls;
|
||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||
|
||||
hs->hh = NULL;
|
||||
switch (dhr->http_status)
|
||||
@ -489,7 +462,6 @@ 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)
|
||||
{
|
||||
@ -510,16 +482,14 @@ history_run (void *cls,
|
||||
TALER_LOG_DEBUG ("row id (from trait) is %llu\n",
|
||||
(unsigned long long) row_id);
|
||||
}
|
||||
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,
|
||||
hs);
|
||||
hs->total = build_history (is, &hs->h);
|
||||
hs->hh = TALER_BANK_debit_history (is->ctx,
|
||||
&hs->auth,
|
||||
row_id,
|
||||
hs->num_results,
|
||||
GNUNET_TIME_UNIT_ZERO,
|
||||
&history_cb,
|
||||
is);
|
||||
GNUNET_assert (NULL != hs->hh);
|
||||
}
|
||||
|
||||
@ -540,8 +510,7 @@ history_cleanup (void *cls,
|
||||
(void) cmd;
|
||||
if (NULL != hs->hh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (hs->is,
|
||||
cmd->label);
|
||||
TALER_LOG_WARNING ("/history/outgoing did not complete\n");
|
||||
TALER_BANK_debit_history_cancel (hs->hh);
|
||||
}
|
||||
for (unsigned int off = 0; off<hs->total; off++)
|
||||
|
@ -149,7 +149,8 @@ do_retry (void *cls)
|
||||
struct TransferState *fts = cls;
|
||||
|
||||
fts->retry_task = NULL;
|
||||
TALER_TESTING_touch_cmd (fts->is);
|
||||
fts->is->commands[fts->is->ip].last_req_time
|
||||
= GNUNET_TIME_absolute_get ();
|
||||
transfer_run (fts,
|
||||
NULL,
|
||||
fts->is);
|
||||
@ -190,7 +191,7 @@ confirmation_cb (void *cls,
|
||||
fts->backoff = GNUNET_TIME_UNIT_ZERO;
|
||||
else
|
||||
fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff);
|
||||
TALER_TESTING_inc_tries (fts->is);
|
||||
fts->is->commands[fts->is->ip].num_tries++;
|
||||
fts->retry_task
|
||||
= GNUNET_SCHEDULER_add_delayed (fts->backoff,
|
||||
&do_retry,
|
||||
@ -198,8 +199,12 @@ confirmation_cb (void *cls,
|
||||
return;
|
||||
}
|
||||
}
|
||||
TALER_TESTING_unexpected_status (is,
|
||||
tr->http_status);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -271,8 +276,9 @@ transfer_cleanup (void *cls,
|
||||
|
||||
if (NULL != fts->weh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (fts->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %s did not complete\n",
|
||||
cmd->label);
|
||||
TALER_BANK_transfer_cancel (fts->weh);
|
||||
fts->weh = NULL;
|
||||
}
|
||||
@ -305,12 +311,12 @@ transfer_traits (void *cls,
|
||||
struct TransferState *fts = cls;
|
||||
struct TALER_TESTING_Trait traits[] = {
|
||||
TALER_TESTING_make_trait_exchange_url (
|
||||
fts->exchange_base_url),
|
||||
(const char **) &fts->exchange_base_url),
|
||||
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
|
||||
TALER_TESTING_make_trait_credit_payto_uri (
|
||||
fts->payto_credit_account),
|
||||
(const char **) &fts->payto_credit_account),
|
||||
TALER_TESTING_make_trait_debit_payto_uri (
|
||||
fts->payto_debit_account),
|
||||
(const char **) &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),
|
||||
|
@ -37,11 +37,6 @@ struct BatchState
|
||||
*/
|
||||
struct TALER_TESTING_Command *batch;
|
||||
|
||||
/**
|
||||
* My command (the batch command).
|
||||
*/
|
||||
const struct TALER_TESTING_Command *cmd;
|
||||
|
||||
/**
|
||||
* Internal command pointer.
|
||||
*/
|
||||
@ -63,7 +58,6 @@ 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);
|
||||
@ -173,33 +167,19 @@ TALER_TESTING_cmd_batch (const char *label,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is,
|
||||
void *cls)
|
||||
void
|
||||
TALER_TESTING_cmd_batch_next (struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct BatchState *bs = cls;
|
||||
struct TALER_TESTING_Command *bcmd = &bs->batch[bs->batch_ip];
|
||||
struct BatchState *bs = is->commands[is->ip].cls;
|
||||
|
||||
if (NULL == bcmd->label)
|
||||
if (NULL == bs->batch[bs->batch_ip].label)
|
||||
{
|
||||
/* This batch is done */
|
||||
return true;
|
||||
is->commands[is->ip].finish_time = GNUNET_TIME_absolute_get ();
|
||||
is->ip++;
|
||||
return;
|
||||
}
|
||||
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[bs->batch_ip].finish_time = GNUNET_TIME_absolute_get ();
|
||||
bs->batch_ip++;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,8 +198,16 @@ batch_deposit_cb (void *cls,
|
||||
ds->dh = NULL;
|
||||
if (ds->expected_response_code != dr->hr.http_status)
|
||||
{
|
||||
TALER_TESTING_unexpected_status (ds->is,
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if (MHD_HTTP_OK == dr->hr.http_status)
|
||||
@ -251,12 +259,8 @@ 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));
|
||||
@ -383,7 +387,7 @@ batch_deposit_run (void *cls,
|
||||
.refund_deadline = ds->refund_deadline
|
||||
};
|
||||
|
||||
ds->dh = TALER_EXCHANGE_batch_deposit (exchange,
|
||||
ds->dh = TALER_EXCHANGE_batch_deposit (is->exchange,
|
||||
&dcd,
|
||||
ds->num_coins,
|
||||
cdds,
|
||||
@ -418,8 +422,10 @@ batch_deposit_cleanup (void *cls,
|
||||
|
||||
if (NULL != ds->dh)
|
||||
{
|
||||
TALER_TESTING_command_incomplete (ds->is,
|
||||
cmd->label);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||
"Command %u (%s) did not complete\n",
|
||||
ds->is->ip,
|
||||
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
Loading…
Reference in New Issue
Block a user