fix #5315, including more testing

This commit is contained in:
Christian Grothoff 2018-09-15 22:20:07 +02:00
parent 46e4ea696c
commit 528faeab81
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
10 changed files with 83 additions and 4922 deletions

View File

@ -48,6 +48,7 @@ libtalertesting_la_SOURCES = \
testing_api_cmd_refund.c \
testing_api_cmd_status.c \
testing_api_cmd_deposit.c \
testing_api_cmd_sleep.c \
testing_api_cmd_refresh.c \
testing_api_cmd_track.c \
testing_api_cmd_bank_check.c \
@ -95,9 +96,7 @@ endif
check_PROGRAMS = \
test_exchange_api_keys_cherry_picking_new \
test_exchange_api_new \
test_exchange_api_keys_cherry_picking \
test_exchange_api
test_exchange_api_new
if HAVE_TWISTER
check_PROGRAMS += \
@ -126,19 +125,6 @@ AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=
TESTS = \
$(check_PROGRAMS)
test_exchange_api_SOURCES = \
test_exchange_api.c
test_exchange_api_LDADD = \
libtalerexchange.la \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/bank-lib/libtalerfakebank.la \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetcurl \
-lgnunetutil \
-ljansson
test_exchange_api_new_SOURCES = \
test_exchange_api_new.c
test_exchange_api_new_LDADD = \
@ -166,17 +152,6 @@ test_exchange_api_keys_cherry_picking_new_LDADD = \
-lgnunetutil \
-ljansson
test_exchange_api_keys_cherry_picking_SOURCES = \
test_exchange_api_keys_cherry_picking.c
test_exchange_api_keys_cherry_picking_LDADD = \
libtalerexchange.la \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetcurl \
-lgnunetutil \
-ljansson
EXTRA_DIST = \
test_exchange_api_home/.local/share/taler/exchange/offline-keys/master.priv \
test_exchange_api_home/.config/taler/test.json \

View File

@ -426,14 +426,15 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
&kv.auditor_url_hash);
kv.master = key_data->master_pub;
len = json_array_size (keys);
auditor->denom_keys = GNUNET_new_array (len,
const struct TALER_EXCHANGE_DenomPublicKey *);
auditor->denom_key_offsets = GNUNET_new_array (len,
unsigned int);
i = 0;
off = 0;
json_array_foreach (keys, i, key) {
struct TALER_AuditorSignatureP auditor_sig;
struct GNUNET_HashCode denom_h;
const struct TALER_EXCHANGE_DenomPublicKey *dk;
unsigned int dk_off;
struct GNUNET_JSON_Specification kspec[] = {
GNUNET_JSON_spec_fixed_auto ("denom_pub_h",
&denom_h),
@ -451,6 +452,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
continue;
}
dk = NULL;
dk_off = UINT_MAX;
for (unsigned int j=0;j<key_data->num_denom_keys;j++)
{
if (0 == memcmp (&denom_h,
@ -458,6 +460,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
sizeof (struct GNUNET_HashCode)))
{
dk = &key_data->denom_keys[j];
dk_off = j;
break;
}
}
@ -492,7 +495,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
auditor->denom_keys[off] = dk;
auditor->denom_key_offsets[off] = dk_off;
off++;
}
auditor->num_denom_keys = off;
@ -628,7 +631,8 @@ decode_keys_json (const json_t *resp_obj,
unsigned int index;
EXITIF (NULL == (denom_keys_array =
json_object_get (resp_obj, "denoms")));
json_object_get (resp_obj,
"denoms")));
EXITIF (JSON_ARRAY != json_typeof (denom_keys_array));
index = 0;
@ -694,6 +698,7 @@ decode_keys_json (const json_t *resp_obj,
for (unsigned int j=0;j<key_data->num_auditors;j++)
{
struct TALER_EXCHANGE_AuditorInformation *aix = &key_data->auditors[j];
if (0 == memcmp (&ai.auditor_pub,
&aix->auditor_pub,
sizeof (struct TALER_AuditorPublicKeyP)))
@ -701,12 +706,12 @@ decode_keys_json (const json_t *resp_obj,
found = true;
/* Merge denomination key signatures of downloaded /keys into existing
auditor information 'aix'. */
GNUNET_array_grow (aix->denom_keys,
GNUNET_array_grow (aix->denom_key_offsets,
aix->num_denom_keys,
aix->num_denom_keys + ai.num_denom_keys);
memcpy (&aix->denom_keys[aix->num_denom_keys - ai.num_denom_keys],
ai.denom_keys,
ai.num_denom_keys * sizeof (struct TALER_EXCHANGE_DenomPublicKey *));
memcpy (&aix->denom_key_offsets[aix->num_denom_keys - ai.num_denom_keys],
ai.denom_key_offsets,
ai.num_denom_keys * sizeof (unsigned int));
break;
}
}
@ -762,7 +767,7 @@ free_key_data (struct TALER_EXCHANGE_Keys *key_data)
0);
for (unsigned int i=0;i<key_data->num_auditors;i++)
{
GNUNET_array_grow (key_data->auditors[i].denom_keys,
GNUNET_array_grow (key_data->auditors[i].denom_key_offsets,
key_data->auditors[i].num_denom_keys,
0);
GNUNET_free (key_data->auditors[i].auditor_url);
@ -827,10 +832,11 @@ keys_completed_cb (void *cls,
struct TALER_EXCHANGE_Keys kd_old;
enum TALER_EXCHANGE_VersionCompatibility vc;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Received keys from URL `%s' with status %ld.\n",
kr->url,
response_code);
json_dumpf (resp_obj, stderr, 0);
kd_old = exchange->key_data;
memset (&kd,
0,
@ -878,17 +884,12 @@ keys_completed_cb (void *cls,
anew->auditor_pub = aold->auditor_pub;
anew->auditor_url = GNUNET_strdup (aold->auditor_url);
GNUNET_array_grow (anew->denom_keys,
GNUNET_array_grow (anew->denom_key_offsets,
anew->num_denom_keys,
aold->num_denom_keys);
for (unsigned int j=0;j<aold->num_denom_keys;j++)
{
/* offsets will map 1:1 */
unsigned int off = aold->denom_keys[j] - kd_old.denom_keys;
/* FIXME(#5315): this should not be an assert! */
GNUNET_assert (off < kd_old.num_denom_keys);
anew->denom_keys[j] = &kd.denom_keys[off];
}
memcpy (anew->denom_key_offsets,
aold->denom_key_offsets,
aold->num_denom_keys * sizeof (unsigned int));
}
if (GNUNET_OK !=
@ -921,10 +922,10 @@ keys_completed_cb (void *cls,
NULL,
vc);
if (NULL != exchange->key_data_raw)
{
json_decref (exchange->key_data_raw);
exchange->key_data_raw = NULL;
}
{
json_decref (exchange->key_data_raw);
exchange->key_data_raw = NULL;
}
free_key_data (&kd_old);
return;
}
@ -1157,13 +1158,10 @@ request_keys (void *cls)
kr = GNUNET_new (struct KeysRequest);
kr->exchange = exchange;
if (GNUNET_YES ==
MAH_handle_is_ready (exchange) && !TALER_EXCHANGE_API_DISABLE_CHERRYPICKING)
MAH_handle_is_ready (exchange))
{
char *arg;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Doing cherry-picking\n");
GNUNET_asprintf (&arg,
"/keys?last_issue_date=%llu",
(unsigned long long) exchange->key_data.last_denom_issue_date.abs_value_us / 1000000LLU);

File diff suppressed because it is too large Load Diff

View File

@ -1,803 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2014-2017 GNUnet e.V. and Inria
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 exchange/test_exchange_api_keys_cherry_picking.c
* @brief testcase to test exchange's /keys cherry picking ability
* @author Christian Grothoff
*/
#include "platform.h"
#include "taler_util.h"
#include "taler_signatures.h"
#include "taler_exchange_service.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
/**
* Main execution context for the main loop.
*/
static struct GNUNET_CURL_Context *ctx;
/**
* Handle to access the exchange.
*/
static struct TALER_EXCHANGE_Handle *exchange;
/**
* Context for running the CURL event loop.
*/
static struct GNUNET_CURL_RescheduleContext *rc;
/**
* Handle to the exchange process.
*/
static struct GNUNET_OS_Process *exchanged;
/**
* Task run on timeout.
*/
static struct GNUNET_SCHEDULER_Task *timeout_task;
/**
* Result of the testcases, #GNUNET_OK on success
*/
static int result;
/**
* Opcodes for the interpreter.
*/
enum OpCode
{
/**
* Termination code, stops the interpreter loop (with success).
*/
OC_END = 0,
/**
* Run a process.
*/
OC_RUN_PROCESS,
/**
* Signal the exchange to reload the keys.
*/
OC_SIGNAL_EXCHANGE,
/**
* Check the /keys.
*/
OC_CHECK_KEYS
};
/**
* Details for a exchange operation to execute.
*/
struct Command
{
/**
* Opcode of the command.
*/
enum OpCode oc;
/**
* Label for the command, can be NULL.
*/
const char *label;
/**
* Details about the command.
*/
union
{
struct {
/**
* Binary to execute.
*/
const char *binary;
/**
* Command-line arguments for the process to be run.
*/
char *const *argv;
/**
* Process handle.
*/
struct GNUNET_OS_Process *proc;
/**
* ID of task called whenever we get a SIGCHILD.
*/
struct GNUNET_SCHEDULER_Task *child_death_task;
} run_process;
struct {
/**
* Expected number of denomination keys.
*/
unsigned int num_denom_keys;
/**
* Which generation of /keys are we verifying here?
* Used to make sure we got the right number of
* interactions.
*/
unsigned int generation;
} check_keys;
} details;
};
/**
* State of the interpreter loop.
*/
struct InterpreterState
{
/**
* Keys from the exchange.
*/
const struct TALER_EXCHANGE_Keys *keys;
/**
* Commands the interpreter will run.
*/
struct Command *commands;
/**
* Interpreter task (if one is scheduled).
*/
struct GNUNET_SCHEDULER_Task *task;
/**
* Instruction pointer. Tells #interpreter_run() which
* instruction to run next.
*/
unsigned int ip;
/**
* Is the interpreter running (#GNUNET_YES) or waiting
* for /keys (#GNUNET_NO)?
*/
int working;
/**
* How often have we gotten a /keys response so far?
*/
unsigned int key_generation;
};
/**
* Pipe used to communicate child death via signal.
*/
static struct GNUNET_DISK_PipeHandle *sigpipe;
/**
* The testcase failed, return with an error code.
*
* @param is interpreter state to clean up
*/
static void
fail (struct InterpreterState *is)
{
result = GNUNET_SYSERR;
GNUNET_SCHEDULER_shutdown ();
}
/**
* Run the main interpreter loop that performs exchange operations.
*
* @param cls contains the `struct InterpreterState`
*/
static void
interpreter_run (void *cls);
/**
* Run the next command with the interpreter.
*
* @param is current interpeter state.
*/
static void
next_command (struct InterpreterState *is)
{
if (GNUNET_SYSERR == result)
return; /* ignore, we already failed! */
is->ip++;
is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
is);
}
/**
* Task triggered whenever we receive a SIGCHLD (child
* process died).
*
* @param cls closure, NULL if we need to self-restart
*/
static void
maint_child_death (void *cls)
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
const struct GNUNET_DISK_FileHandle *pr;
char c[16];
switch (cmd->oc) {
case OC_RUN_PROCESS:
cmd->details.run_process.child_death_task = NULL;
pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c)));
GNUNET_OS_process_wait (cmd->details.run_process.proc);
GNUNET_OS_process_destroy (cmd->details.run_process.proc);
cmd->details.run_process.proc = NULL;
break;
default:
GNUNET_break (0);
fail (is);
return;
}
next_command (is);
}
/**
* Run the main interpreter loop that performs exchange operations.
*
* @param cls contains the `struct InterpreterState`
*/
static void
interpreter_run (void *cls)
{
struct InterpreterState *is = cls;
struct Command *cmd = &is->commands[is->ip];
const struct GNUNET_SCHEDULER_TaskContext *tc;
is->task = NULL;
tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
fprintf (stderr,
"Test aborted by shutdown request\n");
fail (is);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Running command `%s'\n",
cmd->label);
switch (cmd->oc)
{
case OC_END:
result = GNUNET_OK;
GNUNET_SCHEDULER_shutdown ();
return;
case OC_RUN_PROCESS:
{
const struct GNUNET_DISK_FileHandle *pr;
cmd->details.run_process.proc
= GNUNET_OS_start_process_vap (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
cmd->details.run_process.binary,
cmd->details.run_process.argv);
if (NULL == cmd->details.run_process.proc)
{
GNUNET_break (0);
fail (is);
return;
}
pr = GNUNET_DISK_pipe_handle (sigpipe,
GNUNET_DISK_PIPE_END_READ);
cmd->details.run_process.child_death_task
= GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
pr,
&maint_child_death,
is);
return;
}
case OC_SIGNAL_EXCHANGE:
{
GNUNET_break (0 ==
GNUNET_OS_process_kill (exchanged,
SIGUSR1));
/* give exchange time to process the signal */
sleep (1);
next_command (is);
return;
}
case OC_CHECK_KEYS:
{
if (is->key_generation < cmd->details.check_keys.generation)
{
/* Go back to waiting for /keys signal! */
is->working = GNUNET_NO;
GNUNET_break (0 ==
TALER_EXCHANGE_check_keys_current (exchange,
GNUNET_YES).abs_value_us);
return;
}
if (is->key_generation > cmd->details.check_keys.generation)
{
/* We got /keys too often, strange. Fatal. May theoretically happen if
somehow we were really unlucky and /keys expired "naturally", but
obviously with a sane configuration this should also not be. */
GNUNET_break (0);
fail (is);
return;
}
/* /keys was updated, let's check they were OK! */
if (cmd->details.check_keys.num_denom_keys !=
is->keys->num_denom_keys)
{
/* Did not get the expected number of denomination keys! */
GNUNET_break (0);
fprintf (stderr,
"Got %u keys in step %s\n",
is->keys->num_denom_keys,
cmd->label);
fail (is);
return;
}
next_command (is);
return;
}
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unknown instruction %d at %u (%s)\n",
cmd->oc,
is->ip,
cmd->label);
fail (is);
return;
}
}
/**
* Signal handler called for SIGCHLD. Triggers the
* respective handler by writing to the trigger pipe.
*/
static void
sighandler_child_death ()
{
static char c;
int old_errno = errno; /* back-up errno */
GNUNET_break (1 ==
GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle
(sigpipe, GNUNET_DISK_PIPE_END_WRITE),
&c, sizeof (c)));
errno = old_errno; /* restore errno */
}
/**
* Function run when the test terminates (good or bad) with timeout.
*
* @param cls NULL
*/
static void
do_timeout (void *cls)
{
timeout_task = NULL;
GNUNET_SCHEDULER_shutdown ();
}
/**
* Function run when the test terminates (good or bad).
* Cleans up our state.
*
* @param cls the interpreter state.
*/
static void
do_shutdown (void *cls)
{
struct InterpreterState *is = cls;
struct Command *cmd;
for (unsigned int i=0;OC_END != (cmd = &is->commands[i])->oc;i++)
{
switch (cmd->oc)
{
case OC_END:
GNUNET_assert (0);
break;
case OC_RUN_PROCESS:
if (NULL != cmd->details.run_process.proc)
{
GNUNET_break (0 ==
GNUNET_OS_process_kill (cmd->details.run_process.proc,
SIGKILL));
GNUNET_OS_process_wait (cmd->details.run_process.proc);
GNUNET_OS_process_destroy (cmd->details.run_process.proc);
cmd->details.run_process.proc = NULL;
}
if (NULL != cmd->details.run_process.child_death_task)
{
GNUNET_SCHEDULER_cancel (cmd->details.run_process.child_death_task);
cmd->details.run_process.child_death_task = NULL;
}
break;
case OC_SIGNAL_EXCHANGE:
/* nothing to do */
break;
case OC_CHECK_KEYS:
/* nothing to do */
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unknown instruction %d at %u (%s)\n",
cmd->oc,
i,
cmd->label);
break;
}
}
if (NULL != is->task)
{
GNUNET_SCHEDULER_cancel (is->task);
is->task = NULL;
}
GNUNET_free (is);
if (NULL != exchange)
{
TALER_EXCHANGE_disconnect (exchange);
exchange = NULL;
}
if (NULL != ctx)
{
GNUNET_CURL_fini (ctx);
ctx = NULL;
}
if (NULL != rc)
{
GNUNET_CURL_gnunet_rc_destroy (rc);
rc = NULL;
}
if (NULL != timeout_task)
{
GNUNET_SCHEDULER_cancel (timeout_task);
timeout_task = NULL;
}
}
/**
* Functions of this type are called to provide the retrieved signing and
* denomination keys of the exchange. No TALER_EXCHANGE_*() functions should be called
* in this callback.
*
* @param cls closure
* @param keys information about keys of the exchange
* @param vc version compatibility
*/
static void
cert_cb (void *cls,
const struct TALER_EXCHANGE_Keys *keys,
enum TALER_EXCHANGE_VersionCompatibility vc)
{
struct InterpreterState *is = cls;
/* check that keys is OK */
#define ERR(cond) do { if(!(cond)) break; GNUNET_break (0); GNUNET_SCHEDULER_shutdown(); return; } while (0)
ERR (NULL == keys);
ERR (0 == keys->num_sign_keys);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Read %u signing keys\n",
keys->num_sign_keys);
ERR (0 == keys->num_denom_keys);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Read %u denomination keys\n",
keys->num_denom_keys);
#undef ERR
/* run actual tests via interpreter-loop */
is->keys = keys;
if (GNUNET_YES == is->working)
return;
is->working = GNUNET_YES;
is->key_generation++;
is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
is);
}
/**
* Main function that will be run by the scheduler.
*
* @param cls closure
*/
static void
run (void *cls)
{
struct InterpreterState *is;
static char *keyup[] = {
"taler-exchange-keyup",
"-c", "test_exchange_api_keys_cherry_picking_extended.conf",
"-o", "auditor.in",
NULL
};
static char *auditorsign[] = {
"taler-auditor-sign",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-u", "http://auditor/",
"-m", "98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG",
"-r", "auditor.in",
"-o", "test_exchange_api_home/.local/share/taler/auditors/auditor.out",
NULL
};
static struct Command commands[] =
{
/* Test signal handling by itself */
{ .oc = OC_SIGNAL_EXCHANGE },
/* Check we got /keys properly */
{ .oc = OC_CHECK_KEYS,
.details.check_keys.generation = 1,
.details.check_keys.num_denom_keys = 4
},
/* Generate more keys */
{ .oc = OC_RUN_PROCESS,
.details.run_process.binary = "taler-exchange-keyup",
.details.run_process.argv = keyup
},
/* Auditor-sign them */
{ .oc = OC_RUN_PROCESS,
.details.run_process.binary = "taler-auditor-sign",
.details.run_process.argv = auditorsign
},
/* Load new keys into exchange via signal */
{ .oc = OC_SIGNAL_EXCHANGE },
/* Re-download and check /keys */
{ .oc = OC_CHECK_KEYS,
.details.check_keys.generation = 2,
#if TALER_EXCHANGE_API_DISABLE_CHERRYPICKING
.details.check_keys.num_denom_keys = 12
#else
.details.check_keys.num_denom_keys = 8
#endif
},
{ .oc = OC_END }
};
is = GNUNET_new (struct InterpreterState);
is->commands = commands;
ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
&rc);
GNUNET_assert (NULL != ctx);
rc = GNUNET_CURL_gnunet_rc_create (ctx);
exchange = TALER_EXCHANGE_connect (ctx,
"http://localhost:8081",
&cert_cb,
is,
TALER_EXCHANGE_OPTION_END);
GNUNET_assert (NULL != exchange);
timeout_task
= GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 300),
&do_timeout,
NULL);
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
is);
}
/**
* Remove files from previous runs
*/
static void
cleanup_files ()
{
struct GNUNET_CONFIGURATION_Handle *cfg;
char *dir;
cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK !=
GNUNET_CONFIGURATION_load (cfg,
"test_exchange_api.conf"))
{
GNUNET_break (0);
GNUNET_CONFIGURATION_destroy (cfg);
exit (77);
}
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_filename (cfg,
"exchange",
"keydir",
&dir));
if (GNUNET_YES ==
GNUNET_DISK_directory_test (dir,
GNUNET_NO))
GNUNET_break (GNUNET_OK ==
GNUNET_DISK_directory_remove (dir));
GNUNET_free (dir);
GNUNET_CONFIGURATION_destroy (cfg);
}
/**
* Main function for the testcase for the exchange API.
*
* @param argc expected to be 1
* @param argv expected to only contain the program name
*/
int
main (int argc,
char * const *argv)
{
struct GNUNET_OS_Process *proc;
struct GNUNET_SIGNAL_Context *shc_chld;
enum GNUNET_OS_ProcessStatusType type;
unsigned long code;
unsigned int iter;
/* These might get in the way... */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
GNUNET_log_setup ("test-exchange-api-keys-cherry-picking",
"INFO",
NULL);
if (GNUNET_OK !=
GNUNET_NETWORK_test_port_free (IPPROTO_TCP,
8081))
{
fprintf (stderr,
"Required port %u not available, skipping.\n",
8081);
return 77;
}
cleanup_files ();
proc = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-exchange-keyup",
"taler-exchange-keyup",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-o", "auditor.in",
NULL);
if (NULL == proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to run `taler-exchange-keyup`, is your PATH correct?\n");
return 77;
}
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc);
proc = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-auditor-sign",
"taler-auditor-sign",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-u", "http://auditor/",
"-m", "98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG",
"-r", "auditor.in",
"-o", "test_exchange_api_home/.local/share/taler/auditors/auditor.out",
NULL);
if (NULL == proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to run `taler-exchange-keyup`, is your PATH correct?\n");
return 77;
}
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc);
proc = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-exchange-dbinit",
"taler-exchange-dbinit",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-r",
NULL);
if (NULL == proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to run `taler-exchange-dbinit`, is your PATH correct?\n");
return 77;
}
if (GNUNET_SYSERR ==
GNUNET_OS_process_wait_status (proc,
&type,
&code))
{
GNUNET_break (0);
GNUNET_OS_process_destroy (proc);
return 1;
}
GNUNET_OS_process_destroy (proc);
if ( (type == GNUNET_OS_PROCESS_EXITED) &&
(0 != code) )
{
fprintf (stderr,
"Failed to setup database\n");
return 77;
}
if ( (type != GNUNET_OS_PROCESS_EXITED) ||
(0 != code) )
{
fprintf (stderr,
"Unexpected error running `taler-exchange-dbinit'!\n");
return 1;
}
exchanged = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL,
"taler-exchange-httpd",
"taler-exchange-httpd",
"-c", "test_exchange_api_keys_cherry_picking.conf",
"-i",
NULL);
/* give child time to start and bind against the socket */
fprintf (stderr,
"Waiting for `taler-exchange-httpd' to be ready");
iter = 0;
do
{
if (10 == iter)
{
fprintf (stderr,
"Failed to launch `taler-exchange-httpd' (or `wget')\n");
GNUNET_OS_process_kill (exchanged,
SIGTERM);
GNUNET_OS_process_wait (exchanged);
GNUNET_OS_process_destroy (exchanged);
return 77;
}
fprintf (stderr, ".");
sleep (1);
iter++;
}
while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8081/keys -o /dev/null -O /dev/null"));
fprintf (stderr, "\n");
result = GNUNET_NO;
sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
GNUNET_assert (NULL != sigpipe);
shc_chld = GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
&sighandler_child_death);
GNUNET_SCHEDULER_run (&run, NULL);
GNUNET_SIGNAL_handler_uninstall (shc_chld);
shc_chld = NULL;
GNUNET_DISK_pipe_close (sigpipe);
GNUNET_break (0 ==
GNUNET_OS_process_kill (exchanged,
SIGTERM));
GNUNET_break (GNUNET_OK ==
GNUNET_OS_process_wait (exchanged));
GNUNET_OS_process_destroy (exchanged);
return (GNUNET_OK == result) ? 0 : 1;
}
/* end of test_exchange_api_keys_cherry_picking.c */

View File

@ -11,14 +11,14 @@ CURRENCY = EUR
[exchange]
# how long is one signkey valid?
signkey_duration = 4 weeks
signkey_duration = 5 seconds
# how long are the signatures with the signkey valid?
legal_duration = 2 years
# how long do we provide to clients denomination and signing keys
# ahead of time?
lookahead_provide = 4 weeks 1 day
lookahead_provide = 30 seconds
# Keep it short so we can prolong later!
LOOKAHEAD_SIGN = 60 s
@ -132,8 +132,8 @@ CLOSING-FEE-2026 = EUR:0.01
[coin_eur_ct_1]
value = EUR:0.01
duration_overlap = 5 s
duration_withdraw = 35 s
duration_overlap = 1 s
duration_withdraw = 25 s
duration_spend = 40 s
duration_legal = 60 s
fee_withdraw = EUR:0.00
@ -144,8 +144,8 @@ rsa_keysize = 1024
[coin_eur_ct_2]
value = EUR:0.02
duration_overlap = 5 s
duration_withdraw = 35 s
duration_overlap = 1 s
duration_withdraw = 25 s
duration_spend = 40 s
duration_legal = 60 s
fee_withdraw = EUR:0.01

View File

@ -71,6 +71,9 @@ run (void *cls,
1,
4,
is->exchange),
/* sleep a bit */
TALER_TESTING_cmd_sleep ("sleep",
25),
/* 1st keyup happens at start-up */
TALER_TESTING_cmd_exec_keyup ("keyup-2",
CONFIG_FILE_EXTENDED),
@ -81,11 +84,23 @@ run (void *cls,
SIGUSR1),
TALER_TESTING_cmd_check_keys ("check-keys-2",
2,
#if TALER_EXCHANGE_API_DISABLE_CHERRYPICKING
12,
#else
8,
#endif
6,
is->exchange),
/* sleep a bit */
TALER_TESTING_cmd_sleep ("sleep",
24),
/* Do 2nd keyup */
TALER_TESTING_cmd_exec_keyup ("keyup-3",
CONFIG_FILE_EXTENDED),
TALER_TESTING_cmd_exec_auditor_sign ("sign-keys-2",
CONFIG_FILE),
TALER_TESTING_cmd_signal ("trigger-keys-reload-2",
is->exchanged,
SIGUSR1),
TALER_TESTING_cmd_check_keys ("check-keys-3",
3,
10,
is->exchange),
TALER_TESTING_cmd_end ()
};

View File

@ -71,8 +71,8 @@ check_keys_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"cmd `%s', key generation: %d\n",
cmd->label, is->key_generation);
cmd->label,
is->key_generation);
if (is->key_generation < cks->generation)
{
/* Go back to waiting for /keys signal! */
@ -99,10 +99,11 @@ check_keys_run (void *cls,
{
/* Did not get the expected number of denomination keys! */
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got %u keys in step %s\n",
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Got %u keys in step %s, expected %u\n",
is->keys->num_denom_keys,
cmd->label);
cmd->label,
cks->num_denom_keys);
TALER_TESTING_interpreter_fail (is);
return;
}

View File

@ -639,6 +639,15 @@ get_cointype_params (const char *ct,
return GNUNET_SYSERR;
}
GNUNET_TIME_round_rel (&params->duration_overlap);
if (params->duration_overlap.rel_value_us >=
params->duration_withdraw.rel_value_us)
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
ct,
"duration_overlap",
"duration_overlap must be smaller than duration_withdraw!");
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (kcfg,
ct,
@ -814,8 +823,9 @@ exchange_keys_update_cointype (void *cls,
{
dkf = get_cointype_file (&p,
p.anchor);
GNUNET_break (GNUNET_YES != GNUNET_DISK_file_test (dkf));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_break (GNUNET_YES !=
GNUNET_DISK_file_test (dkf));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Generating denomination key for type `%s', start %s at %s\n",
coin_alias,
GNUNET_STRINGS_absolute_time_to_string (p.anchor),

View File

@ -1192,6 +1192,10 @@ build_keys_response (const struct ResponseFactoryContext *rfc,
krd->cherry_pick_date = cherry_pick_date;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Creating /keys for cherry pick date %s\n",
GNUNET_STRINGS_absolute_time_to_string (cherry_pick_date));
/* Initialize `rbc` */
memset (&rbc,
0,
@ -2062,6 +2066,11 @@ TEH_KS_handler_keys (struct TEH_RequestHandler *rh,
sizeof (struct KeysResponseData),
&krd_search_comparator);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Filtering /keys by cherry pick date %s found entry %u/%u\n",
GNUNET_STRINGS_absolute_time_to_string (last_issue_date),
(unsigned int) (krd - key_state->krd_array),
key_state->krd_array_length);
if ( (NULL == krd) &&
(key_state->krd_array_length > 0) )
{

View File

@ -30,14 +30,6 @@
/* ********************* /keys *********************** */
/**
* Temporarily disable cherrypicking until it's fixed.
* See #5315.
*/
#define TALER_EXCHANGE_API_DISABLE_CHERRYPICKING 1
/**
* List of possible options to be passed to
* #TALER_EXCHANGE_connect().
@ -170,11 +162,10 @@ struct TALER_EXCHANGE_AuditorInformation
/**
* Array of length @a num_denom_keys with the denomination
* keys audited by this auditor. Note that the array
* elements point to the same locations as the entries
* in the key's main `denom_keys` array.
* keys audited by this auditor. Offsets into the
* key's main `denom_keys` array.
*/
const struct TALER_EXCHANGE_DenomPublicKey **denom_keys;
unsigned int *denom_key_offsets;
};