From 061eaac70f9548f23a895b3cf8dec4d51ca4fe8f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 12 Jan 2020 19:45:45 +0100 Subject: split of check_empty logic --- src/lib/testing_api_cmd_bank_check_empty.c | 103 +++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/lib/testing_api_cmd_bank_check_empty.c (limited to 'src/lib/testing_api_cmd_bank_check_empty.c') diff --git a/src/lib/testing_api_cmd_bank_check_empty.c b/src/lib/testing_api_cmd_bank_check_empty.c new file mode 100644 index 000000000..fddbba527 --- /dev/null +++ b/src/lib/testing_api_cmd_bank_check_empty.c @@ -0,0 +1,103 @@ +/* + This file is part of TALER + Copyright (C) 2018-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 + +*/ +/** + * @file exchange-lib/testing_api_cmd_bank_check_empty.c + * @brief command to check if a particular wire transfer took + * place. + * @author Marcello Stanisci + */ +#include "platform.h" +#include "taler_json_lib.h" +#include +#include "exchange_api_handle.h" +#include "taler_testing_lib.h" +#include "taler_fakebank_lib.h" + + +/** + * Cleanup the state, only defined to respect the API. + * + * @param cls closure. + * @param cmd the command which is being cleaned up. + */ +static void +check_bank_empty_cleanup + (void *cls, + const struct TALER_TESTING_Command *cmd) +{ + return; +} + + +/** + * Run the command. + * + * @param cls closure. + * @param cmd the command to execute. + * @param is the interpreter state. + */ +static void +check_bank_empty_run (void *cls, + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) +{ + if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank)) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + TALER_TESTING_interpreter_next (is); +} + + +/** + * Some commands (notably "bank history") could randomly + * look for traits; this way makes sure we don't segfault. + */ +static int +check_bank_empty_traits (void *cls, + const void **ret, + const char *trait, + unsigned int index) +{ + return GNUNET_SYSERR; +} + + +/** + * Checks wheter all the wire transfers got "checked" + * by the "bank check" CMD. + * + * @param label command label. + * + * @return the command + */ +struct TALER_TESTING_Command +TALER_TESTING_cmd_check_bank_empty (const char *label) +{ + struct TALER_TESTING_Command cmd = { + .label = label, + .run = &check_bank_empty_run, + .cleanup = &check_bank_empty_cleanup, + .traits = &check_bank_empty_traits + }; + + return cmd; +} -- cgit v1.2.3