diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/Makefile.am | 7 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_abort_order.c | 13 | ||||
-rw-r--r-- | src/testing/testing_api_trait_claim_nonce.c | 59 | ||||
-rw-r--r-- | src/testing/testing_api_trait_hash.c | 89 | ||||
-rw-r--r-- | src/testing/testing_api_trait_merchant_sig.c | 58 | ||||
-rw-r--r-- | src/testing/testing_api_trait_planchet.c | 58 | ||||
-rw-r--r-- | src/testing/testing_api_trait_refund_entry.c | 63 | ||||
-rw-r--r-- | src/testing/testing_api_trait_string.c | 87 | ||||
-rw-r--r-- | src/testing/testing_api_traits.c | 37 |
9 files changed, 43 insertions, 428 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 057c7f81..80359f3e 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am @@ -63,12 +63,7 @@ libtalermerchanttesting_la_SOURCES = \ testing_api_cmd_wallet_get_tip.c \ testing_api_cmd_wallet_post_orders_refund.c \ testing_api_helpers.c \ - testing_api_trait_claim_nonce.c \ - testing_api_trait_merchant_sig.c \ - testing_api_trait_string.c \ - testing_api_trait_hash.c \ - testing_api_trait_planchet.c \ - testing_api_trait_refund_entry.c + testing_api_traits.c libtalermerchanttesting_la_LIBADD = \ $(top_srcdir)/src/lib/libtalermerchant.la \ diff --git a/src/testing/testing_api_cmd_abort_order.c b/src/testing/testing_api_cmd_abort_order.c index d515a361..966d93ff 100644 --- a/src/testing/testing_api_cmd_abort_order.c +++ b/src/testing/testing_api_cmd_abort_order.c @@ -151,10 +151,10 @@ build_coins (struct TALER_MERCHANT_AbortCoin **ac, &icoin->exchange_url)); { const struct TALER_Amount *denom_value; - GNUNET_assert (GNUNET_OK - == TALER_TESTING_get_trait_amount_obj (coin_cmd, - 0, - &denom_value)); + + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_amount (coin_cmd, + &denom_value)); icoin->amount_with_fee = *denom_value; } @@ -235,7 +235,7 @@ abort_run (void *cls, const char *amount_with_fee; const struct TALER_TESTING_Command *proposal_cmd; const char *order_id; - const struct GNUNET_HashCode *h_proposal; + const struct TALER_PrivateContractHash *h_proposal; struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_Amount total_amount; const char *error_name; @@ -251,7 +251,6 @@ abort_run (void *cls, TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_proposal_reference (pay_cmd, - 0, &proposal_reference)) TALER_TESTING_FAIL (is); if (GNUNET_OK != @@ -275,7 +274,6 @@ abort_run (void *cls, if (GNUNET_OK != TALER_TESTING_get_trait_contract_terms (proposal_cmd, - 0, &contract_terms)) TALER_TESTING_FAIL (is); { @@ -332,7 +330,6 @@ abort_run (void *cls, if (GNUNET_OK != TALER_TESTING_get_trait_h_contract_terms (proposal_cmd, - 0, &h_proposal)) TALER_TESTING_FAIL (is); as->oah = TALER_MERCHANT_order_abort (is->ctx, diff --git a/src/testing/testing_api_trait_claim_nonce.c b/src/testing/testing_api_trait_claim_nonce.c deleted file mode 100644 index 7a878812..00000000 --- a/src/testing/testing_api_trait_claim_nonce.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2020 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - 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_api_trait_claim_nonce.c - * @brief offer a trait that is the nonce used to claim an order. - * @author Jonathan Buchanan - */ -#include "platform.h" -#include <taler/taler_signatures.h> -#include <taler/taler_exchange_service.h> -#include <taler/taler_testing_lib.h> - -#define TALER_TESTING_TRAIT_CLAIM_NONCE "nonce" - - -int -TALER_TESTING_get_trait_claim_nonce - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_CRYPTO_EddsaPublicKey **nonce) -{ - return cmd->traits (cmd->cls, - (const void **) nonce, - TALER_TESTING_TRAIT_CLAIM_NONCE, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_claim_nonce - (unsigned int index, - const struct GNUNET_CRYPTO_EddsaPublicKey *nonce) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_CLAIM_NONCE, - .ptr = (const void *) nonce - }; - return ret; -} - - -/* end of testing_api_trait_claim_nonce.c */ diff --git a/src/testing/testing_api_trait_hash.c b/src/testing/testing_api_trait_hash.c deleted file mode 100644 index 17360626..00000000 --- a/src/testing/testing_api_trait_hash.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - 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_api_trait_hash.c - * @brief offer any trait that is passed over as a hash code. - * @author Marcello Stanisci - */ -#include "platform.h" -#include <taler/taler_signatures.h> -#include <taler/taler_exchange_service.h> -#include <taler/taler_testing_lib.h> - -/** - * FIXME: have _one_ pair of getter/setter for hash-coded - * traits and define the getters/setters for tip id and hashed - * contract terms as _macros_. - */ - -#define TALER_TESTING_TRAIT_TIP_ID "tip-id" -#define TALER_TESTING_TRAIT_H_CONTRACT_TERMS "h-contract-terms" - -int -TALER_TESTING_get_trait_tip_id - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct GNUNET_HashCode **tip_id) -{ - return cmd->traits (cmd->cls, - (const void **) tip_id, - TALER_TESTING_TRAIT_TIP_ID, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_tip_id - (unsigned int index, - const struct GNUNET_HashCode *tip_id) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_TIP_ID, - .ptr = (const void *) tip_id - }; - return ret; -} - - -int -TALER_TESTING_get_trait_h_contract_terms - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_HashCode **h_contract_terms) -{ - return cmd->traits (cmd->cls, - (const void **) h_contract_terms, - TALER_TESTING_TRAIT_H_CONTRACT_TERMS, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_h_contract_terms - (unsigned int index, - const struct GNUNET_HashCode *h_contract_terms) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_H_CONTRACT_TERMS, - .ptr = (const void *) h_contract_terms - }; - return ret; -} diff --git a/src/testing/testing_api_trait_merchant_sig.c b/src/testing/testing_api_trait_merchant_sig.c deleted file mode 100644 index 2662a870..00000000 --- a/src/testing/testing_api_trait_merchant_sig.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - 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_api_trait_merchant_sig.c - * @brief offer merchant signature over contract - * @author Marcello Stanisci - */ -#include "platform.h" -#include <taler/taler_signatures.h> -#include <taler/taler_exchange_service.h> -#include <taler/taler_testing_lib.h> - -#define TALER_TESTING_TRAIT_MERCHANT_SIG "reserve-private-key" - -int -TALER_TESTING_get_trait_merchant_sig - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_MerchantSignatureP **merchant_sig) -{ - return cmd->traits (cmd->cls, - (const void **) merchant_sig, - TALER_TESTING_TRAIT_MERCHANT_SIG, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_merchant_sig - (unsigned int index, - const struct TALER_MerchantSignatureP *merchant_sig) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_MERCHANT_SIG, - .ptr = (const void *) merchant_sig - }; - return ret; -} - - -/* end of testing_api_trait_merchant_sig.c */ diff --git a/src/testing/testing_api_trait_planchet.c b/src/testing/testing_api_trait_planchet.c deleted file mode 100644 index 97ee8881..00000000 --- a/src/testing/testing_api_trait_planchet.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - 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_api_trait_planchet.c - * @brief offer planchet secrets as trait. - * @author Marcello Stanisci - */ -#include "platform.h" -#include <taler/taler_signatures.h> -#include <taler/taler_exchange_service.h> -#include <taler/taler_testing_lib.h> - -#define TALER_TESTING_TRAIT_PLANCHET_SECRETS "planchet-secrets" - -int -TALER_TESTING_get_trait_planchet_secrets - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - struct TALER_PlanchetSecretsP **planchet_secrets) -{ - return cmd->traits (cmd->cls, - (const void **) planchet_secrets, - TALER_TESTING_TRAIT_PLANCHET_SECRETS, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_planchet_secrets - (unsigned int index, - const struct TALER_PlanchetSecretsP *planchet_secrets) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_PLANCHET_SECRETS, - .ptr = (const void *) planchet_secrets - }; - return ret; -} - - -/* end of testing_api_trait_planchet.c */ diff --git a/src/testing/testing_api_trait_refund_entry.c b/src/testing/testing_api_trait_refund_entry.c deleted file mode 100644 index 5c99bac2..00000000 --- a/src/testing/testing_api_trait_refund_entry.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2018 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - 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_api_trait_refund_entry.c - * @brief command to offer refund entry trait. - * @author Marcello Stanisci - */ - -#include "platform.h" -#include <taler/taler_signatures.h> -#include <taler/taler_exchange_service.h> -#include <taler/taler_testing_lib.h> -#include "taler_merchant_service.h" - -// FIXME: rename: entry->detail! - -#define TALER_TESTING_TRAIT_REFUND_ENTRY "refund-entry" - -int -TALER_TESTING_get_trait_refund_entry ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct TALER_MERCHANT_RefundDetail **refund_entry) -{ - return cmd->traits (cmd->cls, - (const void **) refund_entry, - TALER_TESTING_TRAIT_REFUND_ENTRY, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_refund_entry ( - unsigned int index, - const struct TALER_MERCHANT_RefundDetail *refund_entry) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_REFUND_ENTRY, - .ptr = (const void *) refund_entry - }; - return ret; -} - - -/* end of testing_api_trait_refund_entry.c */ diff --git a/src/testing/testing_api_trait_string.c b/src/testing/testing_api_trait_string.c deleted file mode 100644 index eae2e077..00000000 --- a/src/testing/testing_api_trait_string.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2018 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - 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_api_trait_string.c - * @brief offer traits that come as strings. - * @author Marcello Stanisci - */ -#include "platform.h" -#include <taler/taler_signatures.h> -#include <taler/taler_exchange_service.h> -#include <taler/taler_testing_lib.h> - -#define TALER_TESTING_TRAIT_PROPOSAL_REFERENCE "proposal-reference" -#define TALER_TESTING_TRAIT_COIN_REFERENCE "coin-reference" - - -int -TALER_TESTING_get_trait_proposal_reference - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **proposal_reference) -{ - return cmd->traits (cmd->cls, - (const void **) proposal_reference, - TALER_TESTING_TRAIT_PROPOSAL_REFERENCE, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_proposal_reference - (unsigned int index, - const char *proposal_reference) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_PROPOSAL_REFERENCE, - .ptr = (const void *) proposal_reference - }; - return ret; -} - - -int -TALER_TESTING_get_trait_coin_reference - (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **coin_reference) -{ - return cmd->traits (cmd->cls, - (const void **) coin_reference, - TALER_TESTING_TRAIT_COIN_REFERENCE, - index); -} - - -struct TALER_TESTING_Trait -TALER_TESTING_make_trait_coin_reference - (unsigned int index, - const char *coin_reference) -{ - struct TALER_TESTING_Trait ret = { - .index = index, - .trait_name = TALER_TESTING_TRAIT_COIN_REFERENCE, - .ptr = (const void *) coin_reference - }; - return ret; -} - - -/* end of testing_api_trait_string.c */ diff --git a/src/testing/testing_api_traits.c b/src/testing/testing_api_traits.c new file mode 100644 index 00000000..a0eb0fc2 --- /dev/null +++ b/src/testing/testing_api_traits.c @@ -0,0 +1,37 @@ +/* + This file is part of TALER + Copyright (C) 2018, 2021 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_traits.c + * @brief loop for trait resolution + * @author Christian Grothoff + * @author Marcello Stanisci + */ +#include "platform.h" +#include "taler_json_lib.h" +#include <gnunet/gnunet_curl_lib.h> +#include "taler_signatures.h" +#include "taler_testing_lib.h" + + +TALER_MERCHANT_TESTING_SIMPLE_TRAITS (TALER_TESTING_MAKE_IMPL_SIMPLE_TRAIT) + +TALER_MERCHANT_TESTING_INDEXED_TRAITS (TALER_TESTING_MAKE_IMPL_INDEXED_TRAIT) + + +/* end of testing_api_traits.c */ |