merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit c4dc3bf39183559ddcfeafba65ef3d8635bc13fe
parent 1610f3a16efe10c456f86af65134e1d3765863fd
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  3 Jul 2020 20:59:37 +0200

use improved rewind API

Diffstat:
Msrc/include/taler_merchant_testing_lib.h | 23-----------------------
Msrc/merchant-tools/taler-merchant-benchmark.c | 23++++++++---------------
Msrc/testing/Makefile.am | 1-
Dsrc/testing/testing_api_cmd_rewind.c | 120-------------------------------------------------------------------------------
4 files changed, 8 insertions(+), 159 deletions(-)

diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h @@ -1515,27 +1515,4 @@ TALER_TESTING_get_trait_refund_entry ( // FIXME: rename: entry->detail const struct TALER_MERCHANT_RefundDetail **refund_entry); -/** - * Make the instruction pointer point to @a new_ip - * only if @a counter is greater than zero. - * - * FIXME: this seems to be a BAD API! Proposal: replace "new_ip" - * with a 'const char *' that is the _label_ of the target - * command (not an offset, and not -1!). Also, this command - * should probably be moved to the *exchange* codebase. - * - * @param label command label - * @param new_ip new instruction pointer's value. Note that, - * when the next instruction will be called, the interpreter - * will increment the ip _anyway_ so this value must be - * set to the index of the instruction we want to execute next - * MINUS one. - * @param counter counts how many times the rewinding has - * to happen. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_rewind_ip (const char *label, - int new_ip, - unsigned int *counter); - #endif diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c @@ -65,13 +65,6 @@ enum PaymentGeneratorError }; -/* Arguments for #TALER_TESTING_cmd_rewind_ip(). FIXME: should probably be - replaced with labels? Bad style! */ -#define FIRST_INSTRUCTION -1 -#define TRACKS_INSTRUCTION 9 -#define TWOCOINS_INSTRUCTION 5 - - /** * What API key should we send in the HTTP 'Authorization' header? */ @@ -280,8 +273,8 @@ run (void *cls, CURRENCY_5, CURRENCY_4_99), TALER_TESTING_cmd_rewind_ip ("rewind-payments", - FIRST_INSTRUCTION, - &payments_number), + "create-reserve", + payments_number), /* Next proposal-pay cycle will be used by /track CMDs * and so it will not have to be looped over, only /track * CMDs will have to. */ @@ -316,8 +309,8 @@ run (void *cls, "post-transaction-1", NULL), TALER_TESTING_cmd_rewind_ip ("rewind-tracks", - TRACKS_INSTRUCTION, - &tracks_number), + "track-transfer-1", + tracks_number), TALER_TESTING_cmd_end () }; @@ -351,8 +344,8 @@ run (void *cls, CURRENCY_5, CURRENCY_4_99), TALER_TESTING_cmd_rewind_ip ("rewind-unaggregated", - FIRST_INSTRUCTION, - &unaggregated_number), + "create-reserve-1", + unaggregated_number), TALER_TESTING_cmd_admin_add_incoming ("create-reserve-2", CURRENCY_10_02, &bc.exchange_auth, @@ -381,8 +374,8 @@ run (void *cls, TALER_TESTING_cmd_exec_aggregator ("aggregate-twocoins", cfg_filename), TALER_TESTING_cmd_rewind_ip ("rewind-twocoins", - TWOCOINS_INSTRUCTION, - &twocoins_number), + "create-reserve-2", + twocoins_number), TALER_TESTING_cmd_end () }; diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am @@ -43,7 +43,6 @@ libtalermerchanttesting_la_SOURCES = \ testing_api_cmd_patch_product.c \ testing_api_cmd_refund_order.c \ \ - testing_api_cmd_rewind.c \ testing_api_cmd_tip_authorize.c \ testing_api_cmd_tip_pickup.c \ testing_api_cmd_wallet_get_order.c \ diff --git a/src/testing/testing_api_cmd_rewind.c b/src/testing/testing_api_cmd_rewind.c @@ -1,120 +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 lib/testing_api_cmd_rewind.c - * @brief command to rewind the instruction pointer. - * @author Marcello Stanisci - */ - -#include "platform.h" -#include <taler/taler_exchange_service.h> -#include <taler/taler_testing_lib.h> -#include "taler_merchant_service.h" -#include "taler_merchant_testing_lib.h" - - -/** - * State for a "rewind" CMD. - */ -struct RewindIpState -{ - /** - * Instruction pointer to set into the interpreter. - */ - unsigned int new_ip; - - /** - * How many times this set should take place. - * However, this value lives at the calling process, - * and this CMD is only in charge of checking and - * decremeting it. - */ - unsigned int *counter; -}; - - -/** - * Only defined to respect the API. - */ -static void -rewind_ip_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) -{ -} - - -/** - * Run the "rewind" CMD. - * - * @param cls closure. - * @param cmd command being executed now. - * @param is the interpreter state. - */ -static void -rewind_ip_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) -{ - struct RewindIpState *ris = cls; - - if (1 < *ris->counter) - { - is->ip = ris->new_ip; - *ris->counter -= 1; - } - - TALER_TESTING_interpreter_next (is); -} - - -/** - * Make the instruction pointer point to @a new_ip - * only if @a counter is greater than zero. - * - * @param label command label - * @param new_ip new instruction pointer's value. Note that, - * when the next instruction will be called, the interpreter - * will increment the ip _anyway_ so this value must be - * set to the index of the instruction we want to execute next - * MINUS one. - * @param counter counts how many times the rewinding has - * to happen. - */ -struct TALER_TESTING_Command -TALER_TESTING_cmd_rewind_ip - (const char *label, - int new_ip, - unsigned int *counter) -{ - struct RewindIpState *ris; - - ris = GNUNET_new (struct RewindIpState); - ris->new_ip = new_ip; - ris->counter = counter; - - struct TALER_TESTING_Command cmd = { - .cls = ris, - .label = label, - .run = &rewind_ip_run, - .cleanup = &rewind_ip_cleanup - }; - - return cmd; -}