From a7379930d273b53429684603df92411cf39b9976 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 8 Jun 2016 11:35:28 +0200 Subject: turn libfakebank into libtalerfakebank so we can use it for testcases in the merchant --- src/include/Makefile.am | 5 ++- src/include/taler_fakebank_lib.h | 94 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 src/include/taler_fakebank_lib.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 310263f0b..d01852666 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -15,11 +15,12 @@ talerinclude_HEADERS = \ taler_amount_lib.h \ taler_bank_service.h \ taler_crypto_lib.h \ - taler_json_lib.h \ - taler_util.h \ taler_exchange_service.h \ taler_exchangedb_lib.h \ taler_exchangedb_plugin.h \ + taler_fakebank_lib.h \ + taler_json_lib.h \ + taler_util.h \ taler_pq_lib.h \ taler_signatures.h \ taler_wire_lib.h \ diff --git a/src/include/taler_fakebank_lib.h b/src/include/taler_fakebank_lib.h new file mode 100644 index 000000000..38b996f0e --- /dev/null +++ b/src/include/taler_fakebank_lib.h @@ -0,0 +1,94 @@ +/* + This file is part of TALER + (C) 2016 Inria and GNUnet e.V. + + 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, If not, see +*/ + +/** + * @file bank-lib/fakebank.h + * @brief API for a library that fakes being a Taler bank + * @author Christian Grothoff + */ +#ifndef TALER_FAKEBANK_H +#define TALER_FAKEBANK_H + +#include "taler_util.h" +#include +#include "taler_json_lib.h" +#include + +/** + * Handle for the fake bank. + */ +struct TALER_FAKEBANK_Handle; + + +/** + * Start the fake bank. The fake bank will, like the normal bank, + * listen for requests for /admin/add/incoming. However, instead of + * executing or storing those requests, it will simply allow querying + * whether such a request has been made via #TALER_FAKEBANK_check(). + * + * This is useful for writing testcases to check whether the exchange + * would have issued the correct wire transfer orders. + * + * @param port port to listen to + * @return NULL on error + */ +struct TALER_FAKEBANK_Handle * +TALER_FAKEBANK_start (uint16_t port); + + +/** + * Check that no wire transfers were ordered (or at least none + * that have not been taken care of via #TALER_FAKEBANK_check()). + * If any transactions are onrecord, return #GNUNET_SYSERR. + * + * @param h bank instance + * @return #GNUNET_OK on success + */ +int +TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h); + + +/** + * Check that the @a want_amount was transferred from the @a + * want_debit to the @a want_credit account. If so, set the @a wtid + * to the transfer identifier and remove the transaction from the + * list. If the transaction was not recorded, return #GNUNET_SYSERR. + * + * @param h bank instance + * @param want_amount transfer amount desired + * @param want_debit account that should have been debited + * @param want_debit account that should have been credited + * @param[out] wtid set to the wire transfer identifier + * @return #GNUNET_OK on success + */ +int +TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h, + const struct TALER_Amount *want_amount, + uint64_t want_debit, + uint64_t want_credit, + struct TALER_WireTransferIdentifierRawP *wtid); + + +/** + * Stop running the fake bank. + * + * @param h bank to stop + */ +void +TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h); + + +#endif -- cgit v1.2.3