donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit d5e3574e32ac64555512f60dab2277ed5aa16ba7
parent e8dcc2f7c60c6e0fc734810b1d675c86f72132b5
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Thu, 11 Jan 2024 00:07:55 +0100

[lib] resolve errors

Diffstat:
Msrc/Makefile.am | 4++--
Msrc/include/donau_crypto_lib.h | 4++--
Msrc/include/donau_json_lib.h | 23+++++++++++++++++++++--
Msrc/include/donau_service.h | 12++++++------
Msrc/json/donau_json.c | 79++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/lib/donau_api_handle.c | 100+++++++++++++++++++++++++++++++++++--------------------------------------------
Dsrc/lib/donau_api_handle.h | 31-------------------------------
Msrc/testing/Makefile.am | 7+------
Msrc/testing/test_api_cmd_get_donau.c | 88-------------------------------------------------------------------------------
Msrc/testing/test_donau_api.c | 1178+------------------------------------------------------------------------------
Asrc/testing/testing_api_loop.c | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/util/donau_signatures.c | 6+++---
12 files changed, 234 insertions(+), 1366 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am @@ -18,6 +18,6 @@ SUBDIRS = \ $(PQ_DIR) \ donaudb \ donau \ - #lib \ + lib \ donau-tools \ - #testing + testing diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -299,7 +299,7 @@ DONAU_charity_budi_key_pair_verify ( void DONAU_donation_statement_sign ( const struct TALER_Amount *amount_tot, - const unsigned int year, + const uint32_t year, const struct DONAU_HashDonorTaxId *i, const struct DONAU_PrivateKeyP *donau_priv, struct DONAU_DonauSignatureP *statement_sig); @@ -318,7 +318,7 @@ DONAU_donation_statement_sign ( enum GNUNET_GenericReturnValue DONAU_donation_statement_verify ( const struct TALER_Amount *amount_tot, - const unsigned int year, + const uint32_t year, const struct DONAU_HashDonorTaxId *i, const struct DONAU_DonauPublicKeyP *donau_pub, const struct DONAU_DonauSignatureP *statement_sig); diff --git a/src/include/donau_json_lib.h b/src/include/donau_json_lib.h @@ -24,8 +24,11 @@ #include <jansson.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> +#include <gnunet/gnunet_json_lib.h> #include "taler/taler_util.h" #include "taler/taler_error_codes.h" +#include "donau_util.h" +#include "taler/taler_json_lib.h" /** * Generate a parser specification for a donation unit public key of a given @@ -40,4 +43,20 @@ struct GNUNET_JSON_Specification DONAU_JSON_spec_donation_unit_pub_cipher ( const char *field, enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, - struct DONAU_DonationUnitPublicKey *pk); -\ No newline at end of file + struct DONAU_DonationUnitPublicKey *pk); + + +/** + * Generate a parser for a group of donation units. + * + * @param[in] field name of the field, maybe NULL + * @param[in] currency name of the currency + * @param[out] group donation unit group information + * @return corresponding field spec + */ +struct GNUNET_JSON_Specification +DONAU_JSON_spec_donation_unit_group (const char *field, + const char *currency, + struct DONAU_DonationUnitGroup *group); + +#endif +\ No newline at end of file diff --git a/src/include/donau_service.h b/src/include/donau_service.h @@ -47,7 +47,7 @@ struct DONAU_SigningPublicKeyAndValidity /** * Tax year this key is valid for. */ - unsigned int year; + uint32_t year; }; @@ -69,7 +69,7 @@ struct DONAU_DonationUnitInformation /** * Year of validity */ - unsigned int year; + uint32_t year; }; @@ -383,7 +383,7 @@ DONAU_keys_decref (struct DONAU_Keys *keys); // enum GNUNET_GenericReturnValue // DONAU_test_signing_key ( // const struct DONAU_Keys *keys, -// const unsigned int year, +// const uint32_t year, // const struct DONAU_DonauPublicKeyP *pub); @@ -409,7 +409,7 @@ DONAU_get_donation_unit_key ( * @return details about the given donation unit key, returns NULL * if the key is not available or deprecated. */ -const struct DONAU_DonationUnitPublicKey * +const struct DONAU_DonationUnitInformation * DONAU_get_donation_unit_key_by_hash ( const struct DONAU_Keys *keys, const struct DONAU_DonationUnitHashP *hc); @@ -459,7 +459,7 @@ struct DONAU_BatchIssueReceipts struct { - unsigned int num_donau_sigs; + uint32_t num_donau_sigs; /** * Blind signature provided by the donau @@ -920,7 +920,7 @@ struct CharityHistoryYear /** * year */ - unsigned int year; + uint32_t year; /** * final donation amount at the end of @a year; diff --git a/src/json/donau_json.c b/src/json/donau_json.c @@ -24,7 +24,6 @@ #include "taler/taler_json_lib.h" #include <unistr.h> #include "donau_json_lib.h" -#include "donau_util.h" /** * Parse given JSON object partially into a donation unit public key. @@ -135,4 +134,82 @@ DONAU_JSON_spec_donation_unit_pub_cipher (const char *field, }; return ret; +} + +/** + * Convert string value to numeric cipher value. + * + * @param cipher_s input string + * @return numeric cipher value + */ +static enum GNUNET_CRYPTO_BlindSignatureAlgorithm +string_to_cipher (const char *cipher_s) +{ + if (0 == strcasecmp (cipher_s, + "RSA")) + return GNUNET_CRYPTO_BSA_RSA; + if (0 == strcasecmp (cipher_s, + "CS")) + return GNUNET_CRYPTO_BSA_CS; + return GNUNET_CRYPTO_BSA_INVALID; +} + +static enum GNUNET_GenericReturnValue +parse_donation_unit_group (void *cls, + json_t *root, + struct GNUNET_JSON_Specification *spec) +{ + struct DonationUnitGroup *group = spec->ptr; + const char *cipher; + const char *currency = cls; + struct GNUNET_JSON_Specification gspec[] = { + GNUNET_JSON_spec_string ("cipher", + &cipher), + TALER_JSON_spec_amount ("value", + currency, + &group->value), + GNUNET_JSON_spec_end () + }; + const char *emsg; + unsigned int eline; + + if (GNUNET_OK != + GNUNET_JSON_parse (root, + gspec, + &emsg, + &eline)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failed to parse %s at %u: %s\n", + spec[eline].field, + eline, + emsg); + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + + group->cipher = string_to_cipher (cipher); + if (GNUNET_CRYPTO_BSA_INVALID == group->cipher) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + + return GNUNET_OK; +} + +struct GNUNET_JSON_Specification +DONAU_JSON_spec_donation_unit_group (const char *name, + const char *currency, + struct DONAU_DonationUnitGroup *group) +{ + struct GNUNET_JSON_Specification ret = { + .cls = (void *) currency, + .parser = &parse_donation_unit_group, + .field = name, + .ptr = group, + .ptr_size = sizeof(*group) + }; + + return ret; } \ No newline at end of file diff --git a/src/lib/donau_api_handle.c b/src/lib/donau_api_handle.c @@ -30,11 +30,12 @@ #include "taler/taler_json_lib.h" #include "donau_service.h" #include "taler/taler_signatures.h" -#include "donau_api_handle.h" #include "donau_api_curl_defaults.h" -//#include "backoff.h" #include "taler/taler_curl_lib.h" #include <gnunet/gnunet_util_lib.h> +#include "donau_json_lib.h" +#include "taler/taler_util.h" +#include "taler/taler_curl_lib.h" /** * Which version of the Donau protocol is implemented @@ -143,7 +144,7 @@ parse_json_signkey (struct DONAU_SigningPublicKeyAndValidity *sign_key, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("key", &sign_key->key), - GNUNET_JSON_spec_varsize ("year_of_validity", + GNUNET_JSON_spec_uint32 ("year_of_validity", &sign_key->year), GNUNET_JSON_spec_end () }; @@ -353,9 +354,9 @@ decode_keys_json (const json_t *resp_obj, struct DONAU_DonationUnitGroup group = {0}; // what must be given to be a part of a group? const json_t *donation_unit_keys_array; struct GNUNET_JSON_Specification group_spec[] = { - TALER_JSON_spec_denomination_group (NULL, // TODO: write method - key_data->currency, - &group), + // DONAU_JSON_spec_donation_unit_group (NULL, + // key_data->currency, + // &group), GNUNET_JSON_spec_array_const ("donation_units", &donation_unit_keys_array), GNUNET_JSON_spec_end () @@ -378,15 +379,15 @@ decode_keys_json (const json_t *resp_obj, donation unit. Required to make the validity check inside parse_json_denomkey_partially pass */ struct DONAU_DonationUnitInformation dk = { - .value = group.value, - .year = group.year + .value = group.value + //.year = group.year }; bool found = false; struct GNUNET_JSON_Specification kspec[] = { - DONAU_JSON_spec_donation_unit_pub_cipher (NULL, - group.cipher, - &dk->key), + // DONAU_JSON_spec_donation_unit_pub_cipher (NULL, + // group.cipher, + // &dk->key), GNUNET_JSON_spec_end () }; @@ -403,7 +404,7 @@ decode_keys_json (const json_t *resp_obj, j<key_data->num_donation_unit_keys; j++) { - if (0 == donation_units_cmp (&dk.key, + if (0 == donation_units_cmp (&dk, &key_data->donation_unit_keys[j])) { found = true; @@ -488,7 +489,6 @@ keys_completed_cb (void *cls, if (GNUNET_OK != decode_keys_json (j, - true, kd, &kresp.details.ok.compat)) { @@ -554,41 +554,30 @@ keys_completed_cb (void *cls, * @param userdata the `struct DONAU_GetKeysHandle` * @return `size * nitems` on success (everything else aborts) */ -static size_t -header_cb (char *buffer, - size_t size, - size_t nitems, - void *userdata) -{ - struct DONAU_GetKeysHandle *kr = userdata; - size_t total = size * nitems; - char *val; - - if (total < strlen (MHD_HTTP_HEADER_EXPIRES ": ")) - return total; - if (0 != strncasecmp (MHD_HTTP_HEADER_EXPIRES ": ", - buffer, - strlen (MHD_HTTP_HEADER_EXPIRES ": "))) - return total; - val = GNUNET_strndup (&buffer[strlen (MHD_HTTP_HEADER_EXPIRES ": ")], - total - strlen (MHD_HTTP_HEADER_EXPIRES ": ")); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Found %s header `%s'\n", - MHD_HTTP_HEADER_EXPIRES, - val); - // if (GNUNET_OK != - // parse_date_string (val, - // &kr->expire)) - // { - // GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - // "Failed to parse %s-header `%s'\n", - // MHD_HTTP_HEADER_EXPIRES, - // val); - // kr->expire = GNUNET_TIME_UNIT_ZERO_TS; - // } - GNUNET_free (val); - return total; -} +// static size_t +// header_cb (char *buffer, +// size_t size, +// size_t nitems, +// void *userdata) +// { +// size_t total = size * nitems; +// char *val; + +// if (total < strlen (MHD_HTTP_HEADER_EXPIRES ": ")) +// return total; +// if (0 != strncasecmp (MHD_HTTP_HEADER_EXPIRES ": ", +// buffer, +// strlen (MHD_HTTP_HEADER_EXPIRES ": "))) +// return total; +// val = GNUNET_strndup (&buffer[strlen (MHD_HTTP_HEADER_EXPIRES ": ")], +// total - strlen (MHD_HTTP_HEADER_EXPIRES ": ")); +// GNUNET_log (GNUNET_ERROR_TYPE_INFO, +// "Found %s header `%s'\n", +// MHD_HTTP_HEADER_EXPIRES, +// val); +// GNUNET_free (val); +// return total; +// } struct DONAU_GetKeysHandle * @@ -707,7 +696,7 @@ DONAU_get_donation_unit_key_by_hash ( for (unsigned int i = 0; i<keys->num_donation_unit_keys; i++) // memcmp needs two pointer of the same type if (0 == GNUNET_memcmp (&hc->hash, - &keys->donation_unit_keys[i].key.bsign_pub_key.pub_key_hash)) + &keys->donation_unit_keys[i].key.bsign_pub_key->pub_key_hash)) return &keys->donation_unit_keys[i]; return NULL; } @@ -782,7 +771,6 @@ DONAU_keys_from_json (const json_t *j) keys = GNUNET_new (struct DONAU_Keys); if (GNUNET_OK != decode_keys_json (jkeys, - false, keys, &compat)) { @@ -865,7 +853,7 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) { json_t *keys; json_t *signkeys; - json_t *donation_units; + json_t *donation_units_by_group; signkeys = json_array (); GNUNET_assert (NULL != signkeys); @@ -876,9 +864,9 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) signkey = GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("key", - &sk->key), - GNUNET_JSON_pack_uint64 ("year", - &sk->year)); + &sk->key)); + // GNUNET_JSON_pack_uint32 ("year", + // &sk->year)); GNUNET_assert (NULL != signkey); GNUNET_assert (0 == json_array_append_new (signkeys, @@ -943,7 +931,7 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) GNUNET_assert (false); } donation_unit = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_data_varsize ("year", + GNUNET_JSON_pack_uint64 ("year", dk->year), key_spec ); @@ -953,7 +941,7 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd) } GNUNET_CONTAINER_multihashmap_iterate (dbg, &add_grp, - donation_unit_by_group); + donation_units_by_group); GNUNET_CONTAINER_multihashmap_destroy (dbg); } diff --git a/src/lib/donau_api_handle.h b/src/lib/donau_api_handle.h @@ -1,31 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015, 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 CHARITYABILITY 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 lib/donau_api_handle.h - * @brief Internal interface to the handle part of the donau's HTTP API - * @author Christian Grothoff - */ -#ifndef DONAU_API_HANDLE_H -#define DONAU_API_HANDLE_H - -#include <gnunet/gnunet_curl_lib.h> -#include "donau_service.h" -#include <taler/taler_util.h> - - -/* end of donau_api_handle.h */ -#endif diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am @@ -23,7 +23,7 @@ libdonautesting_la_LDFLAGS = \ -version-info 0:0:0 \ -no-undefined libdonautesting_la_SOURCES = \ - testing_api_cmd_get_donau.c + test_api_cmd_get_donau.c AM_TESTS_ENVIRONMENT=export DONAU_PREFIX=$${DONAU_PREFIX:-@libdir@};export PATH=$${DONAU_PREFIX:-@prefix@}/bin:$$PATH; @@ -69,8 +69,3 @@ EXTRA_DIST = \ coins-rsa.conf \ test_donau_api.conf -libdonautesting_la_LDFLAGS = \ - -version-info 0:0:0 \ - -no-undefined -libdonautesting_la_SOURCES = \ - test_api_cmd_get_donau.c diff --git a/src/testing/test_api_cmd_get_donau.c b/src/testing/test_api_cmd_get_donau.c @@ -55,17 +55,6 @@ struct GetDonauState char *donau_url; /** - * Label of a command to use to obtain existing - * keys. - */ - // const char *last_keys_ref; - - /** - * Last denomination date we received when doing this request. - */ - // struct GNUNET_TIME_Timestamp my_denom_date; - - /** * Are we waiting for /keys before continuing? */ bool wait_for_keys; @@ -99,7 +88,6 @@ cert_cb (void *cls, TALER_TESTING_interpreter_next (is); return; } - // ges->my_denom_date = kr->details.ok.keys->last_denom_issue_date; return; default: GNUNET_break (0); @@ -130,7 +118,6 @@ get_donau_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct GetDonauState *ges = cls; - // struct DONAU_Keys *xkeys = NULL; (void) cmd; if (NULL == ges->donau_url) @@ -139,81 +126,13 @@ get_donau_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - // if (NULL != ges->last_keys_ref) - // { - // const struct TALER_TESTING_Command *state_cmd; - // struct TALER_EXCHANGE_Keys *old_keys; - // const char *donau_url; - // json_t *s_keys; - - // state_cmd - // = TALER_TESTING_interpreter_lookup_command (is, - // ges->last_keys_ref); - // if (NULL == state_cmd) - // { - // /* Command providing serialized keys not found. */ - // GNUNET_break (0); - // TALER_TESTING_interpreter_fail (is); - // return; - // } - // if (GNUNET_OK != - // TALER_TESTING_get_trait_keys (state_cmd, - // &old_keys)) - // { - // GNUNET_break (0); - // TALER_TESTING_interpreter_fail (is); - // return; - // } - // if (NULL == old_keys) - // { - // GNUNET_break (0); - // TALER_TESTING_interpreter_fail (is); - // return; - // } - // if (GNUNET_OK != - // TALER_TESTING_get_trait_exchange_url (state_cmd, - // &donau_url)) - // { - // GNUNET_break (0); - // TALER_TESTING_interpreter_fail (is); - // return; - // } - // if (0 != strcmp (donau_url, - // ges->donau_url)) - // { - // GNUNET_break (0); - // TALER_TESTING_interpreter_fail (is); - // return; - // } - // s_keys = TALER_EXCHANGE_keys_to_json (old_keys); - // if (NULL == s_keys) - // { - // GNUNET_break (0); - // TALER_TESTING_interpreter_fail (is); - // return; - // } - // xkeys = TALER_EXCHANGE_keys_from_json (s_keys); - // if (NULL == xkeys) - // { - // GNUNET_break (0); - // json_dumpf (s_keys, - // stderr, - // JSON_INDENT (2)); - // json_decref (s_keys); - // TALER_TESTING_interpreter_fail (is); - // return; - // } - // json_decref (s_keys); - // } ges->is = is; ges->donau = DONAU_get_keys (TALER_TESTING_interpreter_get_context (is), ges->donau_url, - // xkeys, &cert_cb, ges); - // DONAU_keys_decref (xkeys); if (NULL == ges->donau) { GNUNET_break (0); @@ -271,10 +190,7 @@ get_donau_traits (void *cls, if (NULL != ges->keys) { struct TALER_TESTING_Trait traits[] = { - // TALER_TESTING_make_trait_donau_keys (ges->keys), TALER_TESTING_make_trait_exchange_url (ges->donau_url), - // TALER_TESTING_make_trait_timestamp (0, - // &ges->my_denom_date), TALER_TESTING_trait_end () }; @@ -287,8 +203,6 @@ get_donau_traits (void *cls, { struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_exchange_url (ges->donau_url), - // TALER_TESTING_make_trait_timestamp (0, - // &ges->my_denom_date), TALER_TESTING_trait_end () }; @@ -331,7 +245,6 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_get_donau ( const char *label, const struct GNUNET_CONFIGURATION_Handle *cfg, - // const char *last_keys_ref, bool wait_for_keys, bool load_private_key) { @@ -339,7 +252,6 @@ TALER_TESTING_cmd_get_donau ( ges = GNUNET_new (struct GetDonauState); ges->donau_url = get_donau_base_url (cfg); - // ges->last_keys_ref = last_keys_ref; ges->wait_for_keys = wait_for_keys; { struct TALER_TESTING_Command cmd = { diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c @@ -22,6 +22,7 @@ * @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Christian Grothoff * @author Marcello Stanisci + * @author Lukas Matyja */ #include "taler/platform.h" #include "taler/taler_util.h" @@ -32,9 +33,8 @@ #include <gnunet/gnunet_testing_lib.h> #include <microhttpd.h> #include "taler/taler_bank_service.h" -#include "taler/taler_fakebank_lib.h" #include "taler/taler_testing_lib.h" -#include "taler/taler_extensions.h" +#include "donau_testing_lib.h" /** * Configuration file we use. One (big) configuration is used @@ -43,12 +43,6 @@ static char *config_file; /** - * Special configuration file to use when we want reserves - * to expire 'immediately'. - */ -static char *config_file_expire_reserve_now; - -/** * Our credentials. */ static struct TALER_TESTING_Credentials cred; @@ -63,39 +57,6 @@ static struct TALER_TESTING_Credentials cred; static bool uses_cs; /** - * Execute the taler-exchange-wirewatch command with - * our configuration file. - * - * @param label label to use for the command. - */ -#define CMD_EXEC_WIREWATCH(label) \ - TALER_TESTING_cmd_exec_wirewatch2 (label, config_file, "exchange-account-2") - -/** - * Execute the taler-exchange-aggregator, closer and transfer commands with - * our configuration file. - * - * @param label label to use for the command. - */ -#define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_sleep ("sleep-before-aggregator", 2), \ - TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \ - TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file) - - -/** - * Run wire transfer of funds from some user's account to the - * exchange. - * - * @param label label to use for the command. - * @param amount amount to transfer, i.e. "EUR:1" - */ -#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \ - TALER_TESTING_cmd_admin_add_incoming (label, amount, \ - &cred.ba, \ - cred.user42_payto) - -/** * Main function that will tell the interpreter what commands to * run. * @@ -106,1127 +67,9 @@ static void run (void *cls, struct TALER_TESTING_Interpreter *is) { - /** - * Test withdrawal plus spending. - */ - //struct TALER_TESTING_Command withdraw[] = { - /** - * Move money to the exchange's bank account. - */ - // CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1", - // "EUR:6.02"), - // TALER_TESTING_cmd_reserve_poll ("poll-reserve-1", - // "create-reserve-1", - // "EUR:6.02", - // GNUNET_TIME_UNIT_MINUTES, - // MHD_HTTP_OK), - // TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-1", - // "EUR:6.02", - // cred.user42_payto, - // cred.exchange_payto, - // "create-reserve-1"), - // /** - // * Make a reserve exist, according to the previous - // * transfer. - // */ - // D_EXEC_WIREWATCH ("wirewatch-1"), - // TALER_TESTING_cmd_reserve_poll_finish ("finish-poll-reserve-1", - // GNUNET_TIME_UNIT_SECONDS, - // "poll-reserve-1"), - // /** - // * Withdraw EUR:5. - // */ - // TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", - // "create-reserve-1", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // /** - // * Withdraw EUR:1 using the SAME private coin key as for the previous coin - // * (in violation of the specification, to be detected on spending!). - // * However, note that this does NOT work with 'CS', as for a different - // * denomination we get different R0/R1 values from the exchange, and - // * thus will generate a different coin private key as R0/R1 are hashed - // * into the coin priv. So here, we fail to 'reuse' the key due to the - // * cryptographic construction! - // */ - // TALER_TESTING_cmd_withdraw_amount_reuse_key ("withdraw-coin-1x", - // "create-reserve-1", - // "EUR:1", - // 0, /* age restriction off */ - // "withdraw-coin-1", - // MHD_HTTP_OK), - // /** - // * Check the reserve is depleted. - // */ - // TALER_TESTING_cmd_status ("status-1", - // "create-reserve-1", - // "EUR:0", - // MHD_HTTP_OK), - // /* - // * Try to overdraw. - // */ - // TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", - // "create-reserve-1", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_CONFLICT), - // TALER_TESTING_cmd_end () - // }; - - // //struct TALER_TESTING_Command spend[] = { - // /** - // * Spend the coin. - // */ - // //TALER_TESTING_cmd_deposit ("deposit-simple", - // "withdraw-coin-1", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:5", - // MHD_HTTP_OK), - // //TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-1", - // "deposit-simple", - // MHD_HTTP_OK), - // //TALER_TESTING_cmd_sleep ("sleep-before-deposit-replay", - // 1), - // //TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-2", - // "deposit-simple", - // MHD_HTTP_OK), - // /* This creates a conflict, as we have the same coin public key (reuse!), - // but different denomination public keys (which is not allowed). - // However, note that this does NOT work with 'CS', as for a different - // denomination we get different R0/R1 values from the exchange, and - // thus will generate a different coin private key as R0/R1 are hashed - // into the coin priv. So here, we fail to 'reuse' the key due to the - // cryptographic construction! */ - // //TALER_TESTING_cmd_deposit ("deposit-reused-coin-key-failure", - // "withdraw-coin-1x", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:1", - // uses_cs - // ? MHD_HTTP_OK - // : MHD_HTTP_CONFLICT), - // /** - // * Try to double spend using different wire details. - // */ - // //TALER_TESTING_cmd_deposit ("deposit-double-1", - // "withdraw-coin-1", - // 0, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:5", - // MHD_HTTP_CONFLICT), - // /* Try to double spend using a different transaction id. - // * The test needs the contract terms to differ. This - // * is currently the case because of the "timestamp" field, - // * which is set automatically by #TALER_TESTING_cmd_deposit(). - // * This could theoretically fail if at some point a deposit - // * command executes in less than 1 ms. */// - // //TALER_TESTING_cmd_deposit ("deposit-double-1", - // "withdraw-coin-1", - // 0, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:5", - // MHD_HTTP_CONFLICT), - // /** - // * Try to double spend with different proposal. - // */ - // //TALER_TESTING_cmd_deposit ("deposit-double-2", - // "withdraw-coin-1", - // 0, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":2}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:5", - // MHD_HTTP_CONFLICT), - // TALER_TESTING_cmd_end () - // }; - - // struct TALER_TESTING_Command refresh[] = { - // /** - // * Try to melt the coin that shared the private key with another - // * coin (should fail). Note that in the CS-case, we fail also - // * with MHD_HTTP_CONFLICT, but for a different reason: here it - // * is not a denomination conflict, but a double-spending conflict. - // */ - // //TALER_TESTING_cmd_melt ("refresh-melt-reused-coin-key-failure", - // "withdraw-coin-1x", - // MHD_HTTP_CONFLICT, - // NULL), - - // /* Fill reserve with EUR:5, 1ct is for fees. */ - // //CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-1", - // "EUR:5.01"), - // //TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1", - // "EUR:5.01", - // cred.user42_payto, - // cred.exchange_payto, - // "refresh-create-reserve-1"), - // /** - // * Make previous command effective. - // */ - // //CMD_EXEC_WIREWATCH ("wirewatch-2"), - // /** - // * Withdraw EUR:5. - // */ - // //TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-1", - // "refresh-create-reserve-1", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // /* Try to partially spend (deposit) 1 EUR of the 5 EUR coin - // * (in full) (merchant would receive EUR:0.99 due to 1 ct - // * deposit fee) - // */ - // //TALER_TESTING_cmd_deposit ("refresh-deposit-partial", - // "refresh-withdraw-coin-1", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:1", - // MHD_HTTP_OK), - // /** - // * Melt the rest of the coin's value - // * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ - // //TALER_TESTING_cmd_melt_double ("refresh-melt-1", - // "refresh-withdraw-coin-1", - // MHD_HTTP_OK, - // NULL), - // /** - // * Complete (successful) melt operation, and - // * withdraw the coins - // */ - // //TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1", - // "refresh-melt-1", - // MHD_HTTP_OK), - // /** - // * Do it again to check idempotency - // */ - // //TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-1-idempotency", - // "refresh-melt-1", - // MHD_HTTP_OK), - // /** - // * Test that /refresh/link works - // */ - // //TALER_TESTING_cmd_refresh_link ("refresh-link-1", - // "refresh-reveal-1", - // MHD_HTTP_OK), - // /** - // * Try to spend a refreshed EUR:1 coin - // */ - // //TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1a", - // "refresh-reveal-1-idempotency", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:1", - // MHD_HTTP_OK), - // /** - // * Try to spend a refreshed EUR:0.1 coin - // */ - // TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-1b", - // "refresh-reveal-1", - // 3, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:0.1", - // MHD_HTTP_OK), - // /* Test running a failing melt operation (same operation - // * again must fail) */ - // TALER_TESTING_cmd_melt ("refresh-melt-failing", - // "refresh-withdraw-coin-1", - // MHD_HTTP_CONFLICT, - // NULL), - // /* Test running a failing melt operation (on a coin that - // was itself revealed and subsequently deposited) */ - // TALER_TESTING_cmd_melt ("refresh-melt-failing-2", - // "refresh-reveal-1", - // MHD_HTTP_CONFLICT, - // NULL), - - // TALER_TESTING_cmd_end () - // }; - - // /** - // * Test withdrawal with age restriction. Success is expected, so it MUST be - // * called _after_ TALER_TESTING_cmd_exec_offline_sign_extensions is called, - // * i. e. age restriction is activated in the exchange! - // * - // * TODO: create a test that tries to withdraw coins with age restriction but - // * (expectedly) fails because the exchange doesn't support age restriction - // * yet. - // */ - // struct TALER_TESTING_Command withdraw_age[] = { - // /** - // * Move money to the exchange's bank account. - // */ - // CMD_TRANSFER_TO_EXCHANGE ("create-reserve-age", - // "EUR:6.01"), - // TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age", - // "EUR:6.01", - // cred.user42_payto, - // cred.exchange_payto, - // "create-reserve-age"), - // /** - // * Make a reserve exist, according to the previous - // * transfer. - // */ - // CMD_EXEC_WIREWATCH ("wirewatch-age"), - // /** - // * Withdraw EUR:5. - // */ - // TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-age-1", - // "create-reserve-age", - // "EUR:5", - // 13, - // MHD_HTTP_OK), - - // TALER_TESTING_cmd_end () - // }; - - // struct TALER_TESTING_Command spend_age[] = { - // /** - // * Spend the coin. - // */ - // TALER_TESTING_cmd_deposit ("deposit-simple-age", - // "withdraw-coin-age-1", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:4.99", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age", - // "deposit-simple-age", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age-1", - // "deposit-simple-age", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_sleep ("sleep-before-age-deposit-replay", - // 1), - // TALER_TESTING_cmd_deposit_replay ("deposit-simple-replay-age-2", - // "deposit-simple-age", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_end () - // }; - - // struct TALER_TESTING_Command track[] = { - // /* Try resolving a deposit's WTID, as we never triggered - // * execution of transactions, the answer should be that - // * the exchange knows about the deposit, but has no WTID yet. - // */ - // TALER_TESTING_cmd_track_transaction ("deposit-wtid-found", - // "deposit-simple", - // 0, - // MHD_HTTP_ACCEPTED, - // NULL), - // /* Try resolving a deposit's WTID for a failed deposit. - // * As the deposit failed, the answer should be that the - // * exchange does NOT know about the deposit. - // */ - // TALER_TESTING_cmd_track_transaction ("deposit-wtid-failing", - // "deposit-double-2", - // 0, - // MHD_HTTP_NOT_FOUND, - // NULL), - // /* Try resolving an undefined (all zeros) WTID; this - // * should fail as obviously the exchange didn't use that - // * WTID value for any transaction. - // */ - // TALER_TESTING_cmd_track_transfer_empty ("wire-deposit-failing", - // NULL, - // MHD_HTTP_NOT_FOUND), - // /* Run transfers. Note that _actual_ aggregation will NOT - // * happen here, as each deposit operation is run with a - // * fresh merchant public key, so the aggregator will treat - // * them as "different" merchants and do the wire transfers - // * individually. */ - // CMD_EXEC_AGGREGATOR ("run-aggregator"), - // /** - // * Check all the transfers took place. - // */ - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c", - // cred.exchange_url, - // "EUR:4.98", - // cred.exchange_payto, - // cred.user42_payto), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-499c2", - // cred.exchange_url, - // "EUR:4.97", - // cred.exchange_payto, - // cred.user42_payto), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c1", - // cred.exchange_url, - // "EUR:0.98", - // cred.exchange_payto, - // cred.user42_payto), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c2", - // cred.exchange_url, - // "EUR:0.98", - // cred.exchange_payto, - // cred.user42_payto), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c3", - // cred.exchange_url, - // "EUR:0.98", - // cred.exchange_payto, - // cred.user42_payto), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-99c4", - // cred.exchange_url, - // "EUR:0.98", - // cred.exchange_payto, - // cred.user42_payto), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c", - // cred.exchange_url, - // "EUR:0.08", - // cred.exchange_payto, - // cred.user43_payto), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-08c2", - // cred.exchange_url, - // "EUR:0.08", - // cred.exchange_payto, - // cred.user43_payto), - // /* In case of CS, one transaction above succeeded that - // failed for RSA, hence we need to check for an extra transfer here */ - // uses_cs - // ? TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-98c", - // cred.exchange_url, - // "EUR:0.98", - // cred.exchange_payto, - // cred.user42_payto) - // : TALER_TESTING_cmd_sleep ("dummy", - // 0), - // TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"), - // TALER_TESTING_cmd_track_transaction ("deposit-wtid-ok", - // "deposit-simple", - // 0, - // MHD_HTTP_OK, - // "check_bank_transfer-499c"), - // TALER_TESTING_cmd_track_transfer ("wire-deposit-success-bank", - // "check_bank_transfer-99c1", - // MHD_HTTP_OK, - // "EUR:0.98", - // "EUR:0.01"), - // TALER_TESTING_cmd_track_transfer ("wire-deposits-success-wtid", - // "deposit-wtid-ok", - // MHD_HTTP_OK, - // "EUR:4.98", - // "EUR:0.01"), - // TALER_TESTING_cmd_end () - // }; - - // /** - // * This block checks whether a wire deadline - // * very far in the future does NOT get aggregated now. - // */ - // struct TALER_TESTING_Command unaggregation[] = { - // TALER_TESTING_cmd_check_bank_empty ("far-future-aggregation-a"), - // CMD_TRANSFER_TO_EXCHANGE ("create-reserve-unaggregated", - // "EUR:5.01"), - // /* "consume" reserve creation transfer. */ - // TALER_TESTING_cmd_check_bank_admin_transfer ( - // "check-create-reserve-unaggregated", - // "EUR:5.01", - // cred.user42_payto, - // cred.exchange_payto, - // "create-reserve-unaggregated"), - // CMD_EXEC_WIREWATCH ("wirewatch-unaggregated"), - // TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-unaggregated", - // "create-reserve-unaggregated", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // TALER_TESTING_cmd_deposit ("deposit-unaggregated", - // "withdraw-coin-unaggregated", - // 0, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - // GNUNET_TIME_relative_multiply ( - // GNUNET_TIME_UNIT_YEARS, - // 3000), - // "EUR:5", - // MHD_HTTP_OK), - // CMD_EXEC_AGGREGATOR ("aggregation-attempt"), - - // TALER_TESTING_cmd_check_bank_empty ( - // "far-future-aggregation-b"), - - // TALER_TESTING_cmd_end () - // }; - - // struct TALER_TESTING_Command refresh_age[] = { - // /* Fill reserve with EUR:5, 1ct is for fees. */ - // CMD_TRANSFER_TO_EXCHANGE ("refresh-create-reserve-age-1", - // "EUR:6.01"), - // TALER_TESTING_cmd_check_bank_admin_transfer ( - // "ck-refresh-create-reserve-age-1", - // "EUR:6.01", - // cred.user42_payto, - // cred.exchange_payto, - // "refresh-create-reserve-age-1"), - // /** - // * Make previous command effective. - // */ - // CMD_EXEC_WIREWATCH ("wirewatch-age-2"), - // /** - // * Withdraw EUR:7 with age restriction for age 13. - // */ - // TALER_TESTING_cmd_withdraw_amount ("refresh-withdraw-coin-age-1", - // "refresh-create-reserve-age-1", - // "EUR:5", - // 13, - // MHD_HTTP_OK), - // /* Try to partially spend (deposit) 1 EUR of the 5 EUR coin - // * (in full) (merchant would receive EUR:0.99 due to 1 ct - // * deposit fee) - // */ - // TALER_TESTING_cmd_deposit ("refresh-deposit-partial-age", - // "refresh-withdraw-coin-age-1", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:1\"}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:1", - // MHD_HTTP_OK), - // /** - // * Melt the rest of the coin's value - // * (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ - // TALER_TESTING_cmd_melt_double ("refresh-melt-age-1", - // "refresh-withdraw-coin-age-1", - // MHD_HTTP_OK, - // NULL), - // /** - // * Complete (successful) melt operation, and - // * withdraw the coins - // */ - // TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1", - // "refresh-melt-age-1", - // MHD_HTTP_OK), - // /** - // * Do it again to check idempotency - // */ - // TALER_TESTING_cmd_refresh_reveal ("refresh-reveal-age-1-idempotency", - // "refresh-melt-age-1", - // MHD_HTTP_OK), - // /** - // * Test that /refresh/link works - // */ - // TALER_TESTING_cmd_refresh_link ("refresh-link-age-1", - // "refresh-reveal-age-1", - // MHD_HTTP_OK), - // /** - // * Try to spend a refreshed EUR:1 coin - // */ - // TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1a", - // "refresh-reveal-age-1-idempotency", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:1", - // MHD_HTTP_OK), - // /** - // * Try to spend a refreshed EUR:0.1 coin - // */ - // TALER_TESTING_cmd_deposit ("refresh-deposit-refreshed-age-1b", - // "refresh-reveal-age-1", - // 3, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":3}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:0.1", - // MHD_HTTP_OK), - // /* Test running a failing melt operation (same operation - // * again must fail) */ - // TALER_TESTING_cmd_melt ("refresh-melt-failing-age", - // "refresh-withdraw-coin-age-1", - // MHD_HTTP_CONFLICT, - // NULL), - // /* Test running a failing melt operation (on a coin that - // was itself revealed and subsequently deposited) */ - // TALER_TESTING_cmd_melt ("refresh-melt-failing-age-2", - // "refresh-reveal-age-1", - // MHD_HTTP_CONFLICT, - // NULL), - // TALER_TESTING_cmd_end () - // }; - - /** - * This block exercises the aggretation logic by making two payments - * to the same merchant. - */ - // struct TALER_TESTING_Command aggregation[] = { - // CMD_TRANSFER_TO_EXCHANGE ("create-reserve-aggtest", - // "EUR:5.01"), - // /* "consume" reserve creation transfer. */ - // TALER_TESTING_cmd_check_bank_admin_transfer ( - // "check-create-reserve-aggtest", - // "EUR:5.01", - // cred.user42_payto, - // cred.exchange_payto, - // "create-reserve-aggtest"), - // CMD_EXEC_WIREWATCH ("wirewatch-aggtest"), - // TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aggtest", - // "create-reserve-aggtest", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // TALER_TESTING_cmd_deposit ("deposit-aggtest-1", - // "withdraw-coin-aggtest", - // 0, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:2", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_deposit_with_ref ("deposit-aggtest-2", - // "withdraw-coin-aggtest", - // 0, - // cred.user43_payto, - // "{\"items\":[{\"name\":\"foo bar\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:2", - // MHD_HTTP_OK, - // "deposit-aggtest-1"), - // CMD_EXEC_AGGREGATOR ("aggregation-aggtest"), - // TALER_TESTING_cmd_check_bank_transfer ("check-bank-transfer-aggtest", - // cred.exchange_url, - // "EUR:3.97", - // cred.exchange_payto, - // cred.user43_payto), - // TALER_TESTING_cmd_check_bank_empty ("check-bank-empty-aggtest"), - // TALER_TESTING_cmd_end () - // }; - - // struct TALER_TESTING_Command refund[] = { - // /** - // * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per - // * config. - // */ - // CMD_TRANSFER_TO_EXCHANGE ("create-reserve-r1", - // "EUR:5.01"), - // TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1", - // "EUR:5.01", - // cred.user42_payto, - // cred.exchange_payto, - // "create-reserve-r1"), - // /** - // * Run wire-watch to trigger the reserve creation. - // */ - // CMD_EXEC_WIREWATCH ("wirewatch-3"), - // /* Withdraw a 5 EUR coin, at fee of 1 ct */ - // TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-r1", - // "create-reserve-r1", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // /** - // * Spend 5 EUR of the 5 EUR coin (in full) (merchant would - // * receive EUR:4.99 due to 1 ct deposit fee) - // */ - // TALER_TESTING_cmd_deposit ("deposit-refund-1", - // "withdraw-coin-r1", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", - // GNUNET_TIME_UNIT_MINUTES, - // "EUR:5", - // MHD_HTTP_OK), - // /** - // * Run transfers. Should do nothing as refund deadline blocks it - // */ - // CMD_EXEC_AGGREGATOR ("run-aggregator-refund"), - // /* Check that aggregator didn't do anything, as expected. - // * Note, this operation takes two commands: one to "flush" - // * the preliminary transfer (used to withdraw) from the - // * fakebank and the second to actually check there are not - // * other transfers around. */ - // TALER_TESTING_cmd_check_bank_empty ("check_bank_transfer-pre-refund"), - // TALER_TESTING_cmd_refund_with_id ("refund-ok", - // MHD_HTTP_OK, - // "EUR:3", - // "deposit-refund-1", - // 3), - // TALER_TESTING_cmd_refund_with_id ("refund-ok-double", - // MHD_HTTP_OK, - // "EUR:3", - // "deposit-refund-1", - // 3), - // /* Previous /refund(s) had id == 0. */ - // TALER_TESTING_cmd_refund_with_id ("refund-conflicting", - // MHD_HTTP_CONFLICT, - // "EUR:5", - // "deposit-refund-1", - // 1), - // TALER_TESTING_cmd_deposit ("deposit-refund-insufficient-refund", - // "withdraw-coin-r1", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:4\"}]}", - // GNUNET_TIME_UNIT_MINUTES, - // "EUR:4", - // MHD_HTTP_CONFLICT), - // TALER_TESTING_cmd_refund_with_id ("refund-ok-increase", - // MHD_HTTP_OK, - // "EUR:2", - // "deposit-refund-1", - // 2), - // /** - // * Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone - // * due to refund) (merchant would receive EUR:4.98 due to - // * 1 ct deposit fee) */ - // TALER_TESTING_cmd_deposit ("deposit-refund-2", - // "withdraw-coin-r1", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"more ice cream\",\"value\":\"EUR:5\"}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:4.99", - // MHD_HTTP_OK), - // /** - // * Run transfers. This will do the transfer as refund deadline - // * was 0 - // */ - // CMD_EXEC_AGGREGATOR ("run-aggregator-3"), - // /** - // * Check that deposit did run. - // */ - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-pre-refund", - // cred.exchange_url, - // "EUR:4.97", - // cred.exchange_payto, - // cred.user42_payto), - // /** - // * Run failing refund, as past deadline & aggregation. - // */ - // TALER_TESTING_cmd_refund ("refund-fail", - // MHD_HTTP_GONE, - // "EUR:4.99", - // "deposit-refund-2"), - // TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"), - // /** - // * Test refunded coins are never executed, even past - // * refund deadline - // */ - // CMD_TRANSFER_TO_EXCHANGE ("create-reserve-rb", - // "EUR:5.01"), - // TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb", - // "EUR:5.01", - // cred.user42_payto, - // cred.exchange_payto, - // "create-reserve-rb"), - // CMD_EXEC_WIREWATCH ("wirewatch-rb"), - // TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-rb", - // "create-reserve-rb", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // TALER_TESTING_cmd_deposit ("deposit-refund-1b", - // "withdraw-coin-rb", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":\"EUR:5\"}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:5", - // MHD_HTTP_OK), - // /** - // * Trigger refund (before aggregator had a chance to execute - // * deposit, even though refund deadline was zero). - // */ - // TALER_TESTING_cmd_refund ("refund-ok-fast", - // MHD_HTTP_OK, - // "EUR:5", - // "deposit-refund-1b"), - // /** - // * Run transfers. This will do the transfer as refund deadline - // * was 0, except of course because the refund succeeded, the - // * transfer should no longer be done. - // */ - // CMD_EXEC_AGGREGATOR ("run-aggregator-3b"), - // /* check that aggregator didn't do anything, as expected */ - // TALER_TESTING_cmd_check_bank_empty ("check-refund-fast-not-run"), - // TALER_TESTING_cmd_end () - // }; - - // struct TALER_TESTING_Command recoup[] = { - // /** - // * Fill reserve with EUR:5.01, as withdraw fee is 1 ct per - // * config. - // */ - // CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-1", - // "EUR:15.02"), - // TALER_TESTING_cmd_check_bank_admin_transfer ( - // "recoup-create-reserve-1-check", - // "EUR:15.02", - // cred.user42_payto, - // cred.exchange_payto, - // "recoup-create-reserve-1"), - // /** - // * Run wire-watch to trigger the reserve creation. - // */ - // CMD_EXEC_WIREWATCH ("wirewatch-4"), - // /* Withdraw a 5 EUR coin, at fee of 1 ct */ - // TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1", - // "recoup-create-reserve-1", - // "EUR:5", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // /* Withdraw a 10 EUR coin, at fee of 1 ct */ - // TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-1b", - // "recoup-create-reserve-1", - // "EUR:10", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // /* melt 10 EUR coin to get 5 EUR refreshed coin */ - // TALER_TESTING_cmd_melt ("recoup-melt-coin-1b", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:5", - // NULL), - // TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1b", - // "recoup-melt-coin-1b", - // MHD_HTTP_OK), - // /* Revoke both 5 EUR coins */ - // TALER_TESTING_cmd_revoke ("revoke-0-EUR:5", - // MHD_HTTP_OK, - // "recoup-withdraw-coin-1", - // config_file), - // /* Recoup coin to reserve */ - // TALER_TESTING_cmd_recoup ("recoup-1", - // MHD_HTTP_OK, - // "recoup-withdraw-coin-1", - // "EUR:5"), - // /* Check the money is back with the reserve */ - // TALER_TESTING_cmd_status ("recoup-reserve-status-1", - // "recoup-create-reserve-1", - // "EUR:5.0", - // MHD_HTTP_OK), - // /* Recoup-refresh coin to 10 EUR coin */ - // TALER_TESTING_cmd_recoup_refresh ("recoup-1b", - // MHD_HTTP_OK, - // "recoup-reveal-coin-1b", - // "recoup-melt-coin-1b", - // "EUR:5"), - // /* melt 10 EUR coin *again* to get 1 EUR refreshed coin */ - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1a", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1a", - // "recoup-remelt-coin-1a", - // MHD_HTTP_OK), - // /* Try melting for more than the residual value to provoke an error */ - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1c", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1d", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1e", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1f", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1g", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1h", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1i", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_OK, - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b-failing", - // "recoup-withdraw-coin-1b", - // MHD_HTTP_CONFLICT, - // "EUR:1", - // NULL), - // /* Re-withdraw from this reserve */ - // TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2", - // "recoup-create-reserve-1", - // "EUR:1", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // /** - // * This withdrawal will test the logic to create a "recoup" - // * element to insert into the reserve's history. - // */ - // TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2-over", - // "recoup-create-reserve-1", - // "EUR:10", - // 0, /* age restriction off */ - // MHD_HTTP_CONFLICT), - // TALER_TESTING_cmd_status ("recoup-reserve-status-2", - // "recoup-create-reserve-1", - // "EUR:3.99", - // MHD_HTTP_OK), - // /* These commands should close the reserve because - // * the aggregator is given a config file that overrides - // * the reserve expiration time (making it now-ish) */ - // CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve", - // "EUR:5.01"), - // TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve", - // "EUR:5.01", - // cred.user42_payto, - // cred.exchange_payto, - // "short-lived-reserve"), - // TALER_TESTING_cmd_exec_wirewatch2 ("short-lived-aggregation", - // config_file_expire_reserve_now, - // "exchange-account-2"), - // TALER_TESTING_cmd_exec_closer ("close-reserves", - // config_file_expire_reserve_now, - // "EUR:5", - // "EUR:0.01", - // "short-lived-reserve"), - // TALER_TESTING_cmd_exec_transfer ("close-reserves-transfer", - // config_file_expire_reserve_now), - - // TALER_TESTING_cmd_status ("short-lived-status", - // "short-lived-reserve", - // "EUR:0", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_withdraw_amount ("expired-withdraw", - // "short-lived-reserve", - // "EUR:1", - // 0, /* age restriction off */ - // MHD_HTTP_CONFLICT), - // TALER_TESTING_cmd_check_bank_transfer ("check_bank_short-lived_reimburse", - // cred.exchange_url, - // "EUR:5", - // cred.exchange_payto, - // cred.user42_payto), - // /* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per - // * config, then withdraw two coin, partially spend one, and - // * then have the rest paid back. Check deposit of other coin - // * fails. Do not use EUR:5 here as the EUR:5 coin was - // * revoked and we did not bother to create a new one... */ - // CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-2", - // "EUR:2.02"), - // TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2", - // "EUR:2.02", - // cred.user42_payto, - // cred.exchange_payto, - // "recoup-create-reserve-2"), - // /* Make previous command effective. */ - // CMD_EXEC_WIREWATCH ("wirewatch-5"), - // /* Withdraw a 1 EUR coin, at fee of 1 ct */ - // TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2a", - // "recoup-create-reserve-2", - // "EUR:1", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // /* Withdraw a 1 EUR coin, at fee of 1 ct */ - // TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2b", - // "recoup-create-reserve-2", - // "EUR:1", - // 0, /* age restriction off */ - // MHD_HTTP_OK), - // TALER_TESTING_cmd_deposit ("recoup-deposit-partial", - // "recoup-withdraw-coin-2a", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:0.5", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_revoke ("revoke-1-EUR:1", - // MHD_HTTP_OK, - // "recoup-withdraw-coin-2a", - // config_file), - // /* Check recoup is failing for the coin with the reused coin key - // (fails either because of denomination conflict (RSA) or - // double-spending (CS))*/ - // TALER_TESTING_cmd_recoup ("recoup-2x", - // MHD_HTTP_CONFLICT, - // "withdraw-coin-1x", - // "EUR:1"), - // TALER_TESTING_cmd_recoup ("recoup-2", - // MHD_HTTP_OK, - // "recoup-withdraw-coin-2a", - // "EUR:0.5"), - // /* Idempotency of recoup (withdrawal variant) */ - // TALER_TESTING_cmd_recoup ("recoup-2b", - // MHD_HTTP_OK, - // "recoup-withdraw-coin-2a", - // "EUR:0.5"), - // TALER_TESTING_cmd_deposit ("recoup-deposit-revoked", - // "recoup-withdraw-coin-2b", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:1", - // MHD_HTTP_GONE), - // /* Test deposit fails after recoup, with proof in recoup */ - - // /* Note that, the exchange will never return the coin's transaction - // * history with recoup data, as we get a 410 on the DK! */ - // TALER_TESTING_cmd_deposit ("recoup-deposit-partial-after-recoup", - // "recoup-withdraw-coin-2a", - // 0, - // cred.user42_payto, - // "{\"items\":[{\"name\":\"extra ice cream\",\"value\":1}]}", - // GNUNET_TIME_UNIT_ZERO, - // "EUR:0.5", - // MHD_HTTP_GONE), - // /* Test that revoked coins cannot be withdrawn */ - // CMD_TRANSFER_TO_EXCHANGE ("recoup-create-reserve-3", - // "EUR:1.01"), - // TALER_TESTING_cmd_check_bank_admin_transfer ( - // "check-recoup-create-reserve-3", - // "EUR:1.01", - // cred.user42_payto, - // cred.exchange_payto, - // "recoup-create-reserve-3"), - // CMD_EXEC_WIREWATCH ("wirewatch-6"), - // TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-3-revoked", - // "recoup-create-reserve-3", - // "EUR:1", - // 0, /* age restriction off */ - // MHD_HTTP_GONE), - // /* check that we are empty before the rejection test */ - // TALER_TESTING_cmd_check_bank_empty ("check-empty-again"), - - // TALER_TESTING_cmd_end () - // }; - - /** - * Test batch withdrawal plus spending. - */ - // struct TALER_TESTING_Command batch_withdraw[] = { - // /** - // * Move money to the exchange's bank account. - // */ - // CMD_TRANSFER_TO_EXCHANGE ("create-batch-reserve-1", - // "EUR:6.03"), - // TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1", - // "create-batch-reserve-1", - // "EUR:6.03", - // GNUNET_TIME_UNIT_MINUTES, - // MHD_HTTP_OK), - // TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-batch-reserve-1", - // "EUR:6.03", - // cred.user42_payto, - // cred.exchange_payto, - // "create-batch-reserve-1"), - // /* - // * Make a reserve exist, according to the previous - // * transfer. - // */ - // CMD_EXEC_WIREWATCH ("wirewatch-batch-1"), - // TALER_TESTING_cmd_reserve_poll_finish ("finish-poll-batch-reserve-1", - // GNUNET_TIME_UNIT_SECONDS, - // "poll-batch-reserve-1"), - // /** - // * Withdraw EUR:5 AND EUR:1. - // */ - // TALER_TESTING_cmd_batch_withdraw ("batch-withdraw-coin-1", - // "create-batch-reserve-1", - // 0, /* age restriction off */ - // MHD_HTTP_OK, - // "EUR:5", - // "EUR:1", - // NULL), - // /** - // * Check the reserve is (almost) depleted. - // */ - // TALER_TESTING_cmd_status ("status-batch-1", - // "create-batch-reserve-1", - // "EUR:0.01", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_reserve_history ("history-batch-1", - // "create-batch-reserve-1", - // "EUR:0.01", - // MHD_HTTP_OK), - // /** - // * Spend the coins. - // */ - // TALER_TESTING_cmd_batch_deposit ("batch-deposit-1", - // cred.user42_payto, - // "{\"items\":[{\"name\":\"ice cream\",\"value\":5}]}", - // GNUNET_TIME_UNIT_ZERO, - // MHD_HTTP_OK, - // "batch-withdraw-coin-1#0", - // "EUR:5", - // "batch-withdraw-coin-1#1", - // "EUR:1", - // NULL), - // TALER_TESTING_cmd_coin_history ("coin-history-batch-1", - // "batch-withdraw-coin-1#0", - // "EUR:0.0", - // MHD_HTTP_OK), - // TALER_TESTING_cmd_end () - // }; - - -#define RESERVE_OPEN_CLOSE_CHUNK 4 -#define RESERVE_OPEN_CLOSE_ITERATIONS 3 - - // struct TALER_TESTING_Command reserve_open_close[(RESERVE_OPEN_CLOSE_ITERATIONS - // * RESERVE_OPEN_CLOSE_CHUNK) - // + 1]; - - // (void) cls; - // for (unsigned int i = 0; - // i < RESERVE_OPEN_CLOSE_ITERATIONS; - // i++) - // { - // reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 0] - // = CMD_TRANSFER_TO_EXCHANGE ("reserve-open-close-key", - // "EUR:20"); - // reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 1] - // = TALER_TESTING_cmd_exec_wirewatch2 ("reserve-open-close-wirewatch", - // config_file_expire_reserve_now, - // "exchange-account-2"); - // reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 2] - // = TALER_TESTING_cmd_exec_closer ("reserve-open-close-aggregation", - // config_file_expire_reserve_now, - // "EUR:19.99", - // "EUR:0.01", - // "reserve-open-close-key"); - // reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 3] - // = TALER_TESTING_cmd_status ("reserve-open-close-status", - // "reserve-open-close-key", - // "EUR:0", - // MHD_HTTP_OK); - // } - // reserve_open_close[RESERVE_OPEN_CLOSE_ITERATIONS * RESERVE_OPEN_CLOSE_CHUNK] - // = TALER_TESTING_cmd_end (); - { struct TALER_TESTING_Command commands[] = { - TALER_TESTING_cmd_system_start ("start-taler-donau", + TALER_TESTING_cmd_system_start ("start-donau", config_file, "-D", NULL), @@ -1259,17 +102,14 @@ main (int argc, GNUNET_asprintf (&config_file, "test_donau_api-%s.conf", cipher); - //GNUNET_asprintf (&config_file_expireDreserve_now, - // "test_donau_api_expire_reserve_now-%s.conf", - // cipher); GNUNET_free (cipher); } - return DONAU_TESTING_main (char *const *argv, - const char *loglevel, - const char *cfg_file, - struct TALER_TESTING_Credentials *cred, - TALER_TESTING_Main main_cb, - void *main_cb_cls); + return DONAU_TESTING_main (argv, + "INFO", + config_file, + &cred, + &run, + NULL); } diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c @@ -0,0 +1,68 @@ +/* + This file is part of TALER + Copyright (C) 2018-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 testing/testing_api_loop.c + * @brief main interpreter loop for testcases + * @author Lukas Matyja + */ +#include "taler/platform.h" +#include "taler/taler_json_lib.h" +#include <gnunet/gnunet_curl_lib.h> +#include "taler/taler_signatures.h" +#include "taler/taler_testing_lib.h" +#include "donau_testing_lib.h" + + +int +DONAU_TESTING_main (char *const *argv, + const char *loglevel, + const char *cfg_file, + struct TALER_TESTING_Credentials *cred, + TALER_TESTING_Main main_cb, + void *main_cb_cls) +{ + enum GNUNET_GenericReturnValue ret; + + unsetenv ("XDG_DATA_HOME"); + unsetenv ("XDG_CONFIG_HOME"); + GNUNET_log_setup (argv[0], + loglevel, + NULL); + //if (GNUNET_OK != + // TALER_TESTING_get_credentials (cfg_file, + // exchange_account_section, + // bs, + // cred)) + //{ + // GNUNET_break (0); + // return 77; + //} + //if (GNUNET_OK != + // TALER_TESTING_cleanup_files_cfg (NULL, + // cred->cfg)) + { + GNUNET_break (0); + return 77; + } + ret = TALER_TESTING_loop (main_cb, + main_cb_cls); + /* TODO: should we free 'cred' resources here? */ + return (GNUNET_OK == ret) ? 0 : 1; +} diff --git a/src/util/donau_signatures.c b/src/util/donau_signatures.c @@ -52,7 +52,7 @@ struct DONAU_DonationStatementConfirmationPS /** * The corresponding year. */ - unsigned int year; + uint32_t year; }; @@ -62,7 +62,7 @@ GNUNET_NETWORK_STRUCT_END void DONAU_donation_statement_sign ( const struct TALER_Amount *amount_tot, - const unsigned int year, + const uint32_t year, const struct DONAU_HashDonorTaxId *i, const struct DONAU_PrivateKeyP *donau_priv, struct DONAU_DonauSignatureP *statement_sig) @@ -87,7 +87,7 @@ DONAU_donation_statement_sign ( enum GNUNET_GenericReturnValue DONAU_donation_statement_verify ( const struct TALER_Amount *amount_tot, - const unsigned int year, + const uint32_t year, const struct DONAU_HashDonorTaxId *i, const struct DONAU_DonauPublicKeyP *donau_pub, const struct DONAU_DonauSignatureP *statement_sig)