exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 7b0bfd7ee64e1fa40610ea956f7959280bbbbe8e
parent c5f6bd047c6594c8e00ab16cf1d715113112500a
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Fri,  5 Jul 2024 10:00:10 +0200

-fix leak

Diffstat:
Msrc/include/taler_testing_lib.h | 370++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 186 insertions(+), 184 deletions(-)

diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h @@ -45,12 +45,12 @@ * quite any time after the command "run" method has been called. */ #define TALER_TESTING_FAIL(is) \ - do \ - { \ - GNUNET_break (0); \ - TALER_TESTING_interpreter_fail (is); \ - return; \ - } while (0) + do \ + { \ + GNUNET_break (0); \ + TALER_TESTING_interpreter_fail (is); \ + return; \ + } while (0) /** @@ -62,16 +62,16 @@ * @param expected expected HTTP status code */ #define TALER_TESTING_unexpected_status(is,status,expected) \ - do { \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - "Unexpected response code %u (expected: %u) to command %s in %s:%u\n", \ - status, \ - expected, \ - TALER_TESTING_interpreter_get_current_label (is), \ - __FILE__, \ - __LINE__); \ - TALER_TESTING_interpreter_fail (is); \ - } while (0) + do { \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Unexpected response code %u (expected: %u) to command %s in %s:%u\n", \ + status, \ + expected, \ + TALER_TESTING_interpreter_get_current_label (is), \ + __FILE__, \ + __LINE__); \ + TALER_TESTING_interpreter_fail (is); \ + } while (0) /** * Log an error message about us receiving an unexpected HTTP @@ -84,18 +84,20 @@ * @param body received JSON-reply */ #define TALER_TESTING_unexpected_status_with_body(is,status,expected,body) \ - do { \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - "Unexpected response code %u (expected: %u) to " \ - "command %s in %s:%u\nwith body:\n>>%s<<\n", \ - status, \ - expected, \ - TALER_TESTING_interpreter_get_current_label (is), \ - __FILE__, \ - __LINE__, \ - json_dumps (body, JSON_INDENT (2))); \ - TALER_TESTING_interpreter_fail (is); \ - } while (0) + do { \ + char *tmp = json_dumps (body, JSON_INDENT (2)); \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Unexpected response code %u (expected: %u) to " \ + "command %s in %s:%u\nwith body:\n>>%s<<\n", \ + status, \ + expected, \ + TALER_TESTING_interpreter_get_current_label (is), \ + __FILE__, \ + __LINE__, \ + tmp); \ + GNUNET_free (tmp); \ + TALER_TESTING_interpreter_fail (is); \ + } while (0) /** @@ -106,14 +108,14 @@ * @param label command label of the incomplete command */ #define TALER_TESTING_command_incomplete(is,label) \ - do { \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - "Command %s (%s:%u) did not complete (at %s)\n", \ - label, \ - __FILE__, \ - __LINE__, \ - TALER_TESTING_interpreter_get_current_label (is)); \ - } while (0) + do { \ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ + "Command %s (%s:%u) did not complete (at %s)\n", \ + label, \ + __FILE__, \ + __LINE__, \ + TALER_TESTING_interpreter_get_current_label (is)); \ + } while (0) /** @@ -313,10 +315,10 @@ struct TALER_TESTING_Command * @return #GNUNET_OK on success */ enum GNUNET_GenericReturnValue - (*traits)(void *cls, - const void **ret, - const char *trait, - unsigned int index); + (*traits)(void *cls, + const void **ret, + const char *trait, + unsigned int index); /** * When did the execution of this command start? @@ -1094,14 +1096,14 @@ TALER_TESTING_cmd_batch_withdraw_with_conflict ( expected_response_code, \ amount, \ ...) \ - TALER_TESTING_cmd_batch_withdraw_with_conflict ( \ - (label), \ - (reserve_reference), \ - false, \ - (age), \ - (expected_response_code), \ - (amount), \ - __VA_ARGS__) + TALER_TESTING_cmd_batch_withdraw_with_conflict ( \ + (label), \ + (reserve_reference), \ + false, \ + (age), \ + (expected_response_code), \ + (amount), \ + __VA_ARGS__) /** * Create an age-withdraw command, letting the caller specify @@ -2231,7 +2233,7 @@ TALER_TESTING_cmd_oauth_with_birthdate (const char *label, * @param port the TCP port to listen on */ #define TALER_TESTING_cmd_oauth(label, port) \ - TALER_TESTING_cmd_oauth_with_birthdate ((label), NULL, (port)) + TALER_TESTING_cmd_oauth_with_birthdate ((label), NULL, (port)) /* ****************** P2P payment commands ****************** */ @@ -2560,13 +2562,13 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, * statically allocated data of type @a type. */ #define TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - TALER_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - type **ret); \ - struct TALER_TESTING_Trait \ - TALER_TESTING_make_trait_ ## name ( \ - type * value); + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type **ret); \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + type * value); /** @@ -2574,27 +2576,27 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, * allocated data of type @a type. */ #define TALER_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - TALER_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - type **ret) \ - { \ - if (NULL == cmd->traits) return GNUNET_SYSERR; \ - return cmd->traits (cmd->cls, \ - (const void **) ret, \ - TALER_S (name), \ - 0); \ - } \ - struct TALER_TESTING_Trait \ - TALER_TESTING_make_trait_ ## name ( \ - type * value) \ - { \ - struct TALER_TESTING_Trait ret = { \ - .trait_name = TALER_S (name), \ - .ptr = (const void *) value \ - }; \ - return ret; \ - } + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type * *ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + 0); \ + } \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } /** @@ -2602,15 +2604,15 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, * statically allocated data of type @a type. */ #define TALER_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - TALER_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - unsigned int index, \ - type **ret); \ - struct TALER_TESTING_Trait \ - TALER_TESTING_make_trait_ ## name ( \ - unsigned int index, \ - type * value); + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type **ret); \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type *value); /** @@ -2618,116 +2620,116 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits, * allocated data of type @a type. */ #define TALER_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - TALER_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - unsigned int index, \ - type **ret) \ - { \ - if (NULL == cmd->traits) return GNUNET_SYSERR; \ - return cmd->traits (cmd->cls, \ - (const void **) ret, \ - TALER_S (name), \ - index); \ - } \ - struct TALER_TESTING_Trait \ - TALER_TESTING_make_trait_ ## name ( \ - unsigned int index, \ - type * value) \ - { \ - struct TALER_TESTING_Trait ret = { \ - .index = index, \ - .trait_name = TALER_S (name), \ - .ptr = (const void *) value \ - }; \ - return ret; \ - } + enum GNUNET_GenericReturnValue \ + TALER_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type * *ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + index); \ + } \ + struct TALER_TESTING_Trait \ + TALER_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .index = index, \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } /** * Call #op on all simple traits. */ #define TALER_TESTING_SIMPLE_TRAITS(op) \ - op (bank_row, const uint64_t) \ - op (officer_pub, const struct TALER_AmlOfficerPublicKeyP) \ - op (officer_priv, const struct TALER_AmlOfficerPrivateKeyP) \ - op (officer_name, const char) \ - op (aml_decision, enum TALER_AmlDecisionState) \ - op (aml_justification, const char) \ - op (auditor_priv, const struct TALER_AuditorPrivateKeyP) \ - op (auditor_pub, const struct TALER_AuditorPublicKeyP) \ - op (master_priv, const struct TALER_MasterPrivateKeyP) \ - op (master_pub, const struct TALER_MasterPublicKeyP) \ - op (purse_priv, const struct TALER_PurseContractPrivateKeyP) \ - op (purse_pub, const struct TALER_PurseContractPublicKeyP) \ - op (merge_priv, const struct TALER_PurseMergePrivateKeyP) \ - op (merge_pub, const struct TALER_PurseMergePublicKeyP) \ - op (contract_priv, const struct TALER_ContractDiffiePrivateP) \ - op (reserve_priv, const struct TALER_ReservePrivateKeyP) \ - op (reserve_sig, const struct TALER_ReserveSignatureP) \ - op (h_payto, const struct TALER_PaytoHashP) \ - op (planchet_secret, const struct TALER_PlanchetMasterSecretP) \ - op (refresh_secret, const struct TALER_RefreshMasterSecretP) \ - op (reserve_pub, const struct TALER_ReservePublicKeyP) \ - op (merchant_priv, const struct TALER_MerchantPrivateKeyP) \ - op (merchant_pub, const struct TALER_MerchantPublicKeyP) \ - op (merchant_sig, const struct TALER_MerchantSignatureP) \ - op (wtid, const struct TALER_WireTransferIdentifierRawP) \ - op (bank_auth_data, const struct TALER_BANK_AuthenticationData) \ - op (contract_terms, const json_t) \ - op (wire_details, const json_t) \ - op (exchange_url, const char) \ - op (auditor_url, const char) \ - op (exchange_bank_account_url, const char) \ - op (taler_uri, const char) \ - op (payto_uri, const char) \ - op (kyc_url, const char) \ - op (web_url, const char) \ - op (row, const uint64_t) \ - op (legi_requirement_row, const uint64_t) \ - op (array_length, const unsigned int) \ - op (credit_payto_uri, const char) \ - op (debit_payto_uri, const char) \ - op (order_id, const char) \ - op (amount, const struct TALER_Amount) \ - op (amount_with_fee, const struct TALER_Amount) \ - op (batch_cmds, struct TALER_TESTING_Command) \ - op (uuid, const struct GNUNET_Uuid) \ - op (fresh_coins, const struct TALER_TESTING_FreshCoinData *) \ - op (claim_token, const struct TALER_ClaimTokenP) \ - op (relative_time, const struct GNUNET_TIME_Relative) \ - op (fakebank, struct TALER_FAKEBANK_Handle) \ - op (keys, struct TALER_EXCHANGE_Keys) \ - op (process, struct GNUNET_OS_Process *) + op (bank_row, const uint64_t) \ + op (officer_pub, const struct TALER_AmlOfficerPublicKeyP) \ + op (officer_priv, const struct TALER_AmlOfficerPrivateKeyP) \ + op (officer_name, const char) \ + op (aml_decision, enum TALER_AmlDecisionState) \ + op (aml_justification, const char) \ + op (auditor_priv, const struct TALER_AuditorPrivateKeyP) \ + op (auditor_pub, const struct TALER_AuditorPublicKeyP) \ + op (master_priv, const struct TALER_MasterPrivateKeyP) \ + op (master_pub, const struct TALER_MasterPublicKeyP) \ + op (purse_priv, const struct TALER_PurseContractPrivateKeyP) \ + op (purse_pub, const struct TALER_PurseContractPublicKeyP) \ + op (merge_priv, const struct TALER_PurseMergePrivateKeyP) \ + op (merge_pub, const struct TALER_PurseMergePublicKeyP) \ + op (contract_priv, const struct TALER_ContractDiffiePrivateP) \ + op (reserve_priv, const struct TALER_ReservePrivateKeyP) \ + op (reserve_sig, const struct TALER_ReserveSignatureP) \ + op (h_payto, const struct TALER_PaytoHashP) \ + op (planchet_secret, const struct TALER_PlanchetMasterSecretP) \ + op (refresh_secret, const struct TALER_RefreshMasterSecretP) \ + op (reserve_pub, const struct TALER_ReservePublicKeyP) \ + op (merchant_priv, const struct TALER_MerchantPrivateKeyP) \ + op (merchant_pub, const struct TALER_MerchantPublicKeyP) \ + op (merchant_sig, const struct TALER_MerchantSignatureP) \ + op (wtid, const struct TALER_WireTransferIdentifierRawP) \ + op (bank_auth_data, const struct TALER_BANK_AuthenticationData) \ + op (contract_terms, const json_t) \ + op (wire_details, const json_t) \ + op (exchange_url, const char) \ + op (auditor_url, const char) \ + op (exchange_bank_account_url, const char) \ + op (taler_uri, const char) \ + op (payto_uri, const char) \ + op (kyc_url, const char) \ + op (web_url, const char) \ + op (row, const uint64_t) \ + op (legi_requirement_row, const uint64_t) \ + op (array_length, const unsigned int) \ + op (credit_payto_uri, const char) \ + op (debit_payto_uri, const char) \ + op (order_id, const char) \ + op (amount, const struct TALER_Amount) \ + op (amount_with_fee, const struct TALER_Amount) \ + op (batch_cmds, struct TALER_TESTING_Command) \ + op (uuid, const struct GNUNET_Uuid) \ + op (fresh_coins, const struct TALER_TESTING_FreshCoinData *) \ + op (claim_token, const struct TALER_ClaimTokenP) \ + op (relative_time, const struct GNUNET_TIME_Relative) \ + op (fakebank, struct TALER_FAKEBANK_Handle) \ + op (keys, struct TALER_EXCHANGE_Keys) \ + op (process, struct GNUNET_OS_Process *) /** * Call #op on all indexed traits. */ #define TALER_TESTING_INDEXED_TRAITS(op) \ - op (denom_pub, const struct TALER_EXCHANGE_DenomPublicKey) \ - op (denom_sig, const struct TALER_DenominationSignature) \ - op (amounts, const struct TALER_Amount) \ - op (deposit_amount, const struct TALER_Amount) \ - op (deposit_fee_amount, const struct TALER_Amount) \ - op (age_commitment, const struct TALER_AgeCommitment) \ - op (age_commitment_proof, const struct TALER_AgeCommitmentProof) \ - op (h_age_commitment, const struct TALER_AgeCommitmentHash) \ - op (reserve_history, const struct TALER_EXCHANGE_ReserveHistoryEntry) \ - op (coin_history, const struct TALER_EXCHANGE_CoinHistoryEntry) \ - op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \ - op (exchange_wd_value, const struct TALER_ExchangeWithdrawValues) \ - op (coin_priv, const struct TALER_CoinSpendPrivateKeyP) \ - op (coin_pub, const struct TALER_CoinSpendPublicKeyP) \ - op (coin_sig, const struct TALER_CoinSpendSignatureP) \ - op (absolute_time, const struct GNUNET_TIME_Absolute) \ - op (timestamp, const struct GNUNET_TIME_Timestamp) \ - op (wire_deadline, const struct GNUNET_TIME_Timestamp) \ - op (refund_deadline, const struct GNUNET_TIME_Timestamp) \ - op (exchange_pub, const struct TALER_ExchangePublicKeyP) \ - op (exchange_sig, const struct TALER_ExchangeSignatureP) \ - op (blinding_key, const union GNUNET_CRYPTO_BlindingSecretP) \ - op (h_blinded_coin, const struct TALER_BlindedCoinHashP) + op (denom_pub, const struct TALER_EXCHANGE_DenomPublicKey) \ + op (denom_sig, const struct TALER_DenominationSignature) \ + op (amounts, const struct TALER_Amount) \ + op (deposit_amount, const struct TALER_Amount) \ + op (deposit_fee_amount, const struct TALER_Amount) \ + op (age_commitment, const struct TALER_AgeCommitment) \ + op (age_commitment_proof, const struct TALER_AgeCommitmentProof) \ + op (h_age_commitment, const struct TALER_AgeCommitmentHash) \ + op (reserve_history, const struct TALER_EXCHANGE_ReserveHistoryEntry) \ + op (coin_history, const struct TALER_EXCHANGE_CoinHistoryEntry) \ + op (planchet_secrets, const struct TALER_PlanchetMasterSecretP) \ + op (exchange_wd_value, const struct TALER_ExchangeWithdrawValues) \ + op (coin_priv, const struct TALER_CoinSpendPrivateKeyP) \ + op (coin_pub, const struct TALER_CoinSpendPublicKeyP) \ + op (coin_sig, const struct TALER_CoinSpendSignatureP) \ + op (absolute_time, const struct GNUNET_TIME_Absolute) \ + op (timestamp, const struct GNUNET_TIME_Timestamp) \ + op (wire_deadline, const struct GNUNET_TIME_Timestamp) \ + op (refund_deadline, const struct GNUNET_TIME_Timestamp) \ + op (exchange_pub, const struct TALER_ExchangePublicKeyP) \ + op (exchange_sig, const struct TALER_ExchangeSignatureP) \ + op (blinding_key, const union GNUNET_CRYPTO_BlindingSecretP) \ + op (h_blinded_coin, const struct TALER_BlindedCoinHashP) TALER_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_DECL_SIMPLE_TRAIT)