summaryrefslogtreecommitdiff
path: root/src/bank-lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/bank-lib')
-rw-r--r--src/bank-lib/Makefile.am21
-rw-r--r--src/bank-lib/fakebank.c40
-rw-r--r--src/bank-lib/fakebank.h94
-rw-r--r--src/bank-lib/test_bank_interpreter.c12
4 files changed, 38 insertions, 129 deletions
diff --git a/src/bank-lib/Makefile.am b/src/bank-lib/Makefile.am
index 7e4dd51f..28913502 100644
--- a/src/bank-lib/Makefile.am
+++ b/src/bank-lib/Makefile.am
@@ -7,10 +7,8 @@ if USE_COVERAGE
endif
lib_LTLIBRARIES = \
- libtalerbank.la
-
-noinst_LTLIBRARIES = \
- libfakebank.la
+ libtalerbank.la \
+ libtalerfakebank.la
libtalerbank_la_LDFLAGS = \
-version-info 0:0:0 \
@@ -27,10 +25,15 @@ libtalerbank_la_LIBADD = \
-ljansson \
$(XLIB)
-libfakebank_la_SOURCES = \
- fakebank.c fakebank.h
-libfakebank_la_LIBADD = \
+libtalerfakebank_la_LDFLAGS = \
+ -version-info 0:0:0 \
+ -no-undefined
+
+libtalerfakebank_la_SOURCES = \
+ fakebank.c
+
+libtalerfakebank_la_LIBADD = \
$(top_builddir)/src/json/libtalerjson.la \
-lgnunetjson \
-lgnunetutil \
@@ -58,7 +61,7 @@ test_bank_api_SOURCES = \
test_bank_api.c
test_bank_api_LDADD = \
libtalerbank.la \
- libfakebank.la \
+ libtalerfakebank.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetcurl \
-lgnunetutil \
@@ -70,7 +73,7 @@ test_bank_api_with_fakebank_SOURCES = \
test_bank_api_with_fakebank.c
test_bank_api_with_fakebank_LDADD = \
libtalerbank.la \
- libfakebank.la \
+ libtalerfakebank.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetcurl \
-lgnunetutil \
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 8598e007..13bfa1cb 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -21,7 +21,7 @@
*/
#include "platform.h"
-#include "fakebank.h"
+#include "taler_fakebank_lib.h"
/**
* Maximum POST request size (for /admin/add/incoming)
@@ -71,7 +71,7 @@ struct Transaction
/**
* Handle for the fake bank.
*/
-struct FAKEBANK_Handle
+struct TALER_FAKEBANK_Handle
{
/**
* We store transactions in a DLL.
@@ -109,11 +109,11 @@ struct FAKEBANK_Handle
* @return #GNUNET_OK on success
*/
int
-FAKEBANK_check (struct FAKEBANK_Handle *h,
- const struct TALER_Amount *want_amount,
- uint64_t want_debit,
- uint64_t want_credit,
- struct TALER_WireTransferIdentifierRawP *wtid)
+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)
{
struct Transaction *t;
@@ -152,14 +152,14 @@ FAKEBANK_check (struct FAKEBANK_Handle *h,
/**
* Check that no wire transfers were ordered (or at least none
- * that have not been taken care of via #FAKEBANK_check()).
+ * 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
-FAKEBANK_check_empty (struct FAKEBANK_Handle *h)
+TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h)
{
struct Transaction *t;
@@ -190,7 +190,7 @@ FAKEBANK_check_empty (struct FAKEBANK_Handle *h)
* @param h bank to stop
*/
void
-FAKEBANK_stop (struct FAKEBANK_Handle *h)
+TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
{
if (NULL != h->mhd_task)
{
@@ -226,7 +226,7 @@ handle_mhd_completion_callback (void *cls,
void **con_cls,
enum MHD_RequestTerminationCode toe)
{
- /* struct FAKEBANK_Handle *h = cls; */
+ /* struct TALER_FAKEBANK_Handle *h = cls; */
GNUNET_JSON_post_parser_cleanup (*con_cls);
*con_cls = NULL;
@@ -256,7 +256,7 @@ handle_mhd_request (void *cls,
size_t *upload_data_size,
void **con_cls)
{
- struct FAKEBANK_Handle *h = cls;
+ struct TALER_FAKEBANK_Handle *h = cls;
enum GNUNET_JSON_PostResult pr;
json_t *json;
struct Transaction *t;
@@ -331,7 +331,7 @@ handle_mhd_request (void *cls,
/**
* Task run whenever HTTP server operations are pending.
*
- * @param cls the `struct FAKEBANK_Handle`
+ * @param cls the `struct TALER_FAKEBANK_Handle`
*/
static void
run_mhd (void *cls);
@@ -343,7 +343,7 @@ run_mhd (void *cls);
* always be called later whenever there is work to be done.
*/
static void
-schedule_httpd (struct FAKEBANK_Handle *h)
+schedule_httpd (struct TALER_FAKEBANK_Handle *h)
{
fd_set rs;
fd_set ws;
@@ -399,12 +399,12 @@ schedule_httpd (struct FAKEBANK_Handle *h)
/**
* Task run whenever HTTP server operations are pending.
*
- * @param cls the `struct FAKEBANK_Handle`
+ * @param cls the `struct TALER_FAKEBANK_Handle`
*/
static void
run_mhd (void *cls)
{
- struct FAKEBANK_Handle *h = cls;
+ struct TALER_FAKEBANK_Handle *h = cls;
h->mhd_task = NULL;
MHD_run (h->mhd_bank);
@@ -418,12 +418,12 @@ run_mhd (void *cls)
* @param port port to listen to
* @return NULL on error
*/
-struct FAKEBANK_Handle *
-FAKEBANK_start (uint16_t port)
+struct TALER_FAKEBANK_Handle *
+TALER_FAKEBANK_start (uint16_t port)
{
- struct FAKEBANK_Handle *h;
+ struct TALER_FAKEBANK_Handle *h;
- h = GNUNET_new (struct FAKEBANK_Handle);
+ h = GNUNET_new (struct TALER_FAKEBANK_Handle);
h->mhd_bank = MHD_start_daemon (MHD_USE_DEBUG,
port,
NULL, NULL,
diff --git a/src/bank-lib/fakebank.h b/src/bank-lib/fakebank.h
deleted file mode 100644
index 5a4c13cd..00000000
--- a/src/bank-lib/fakebank.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- 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 <http://www.gnu.org/licenses/>
-*/
-
-/**
- * @file bank-lib/fakebank.h
- * @brief API for a library that fakes being a Taler bank
- * @author Christian Grothoff <christian@grothoff.org>
- */
-#ifndef FAKEBANK_H
-#define FAKEBANK_H
-
-#include "taler_util.h"
-#include <gnunet/gnunet_json_lib.h>
-#include "taler_json_lib.h"
-#include <microhttpd.h>
-
-/**
- * Handle for the fake bank.
- */
-struct 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 #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 FAKEBANK_Handle *
-FAKEBANK_start (uint16_t port);
-
-
-/**
- * Check that no wire transfers were ordered (or at least none
- * that have not been taken care of via #FAKEBANK_check()).
- * If any transactions are onrecord, return #GNUNET_SYSERR.
- *
- * @param h bank instance
- * @return #GNUNET_OK on success
- */
-int
-FAKEBANK_check_empty (struct 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
-FAKEBANK_check (struct 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
-FAKEBANK_stop (struct FAKEBANK_Handle *h);
-
-
-#endif
diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c
index 840f9942..a77af8dd 100644
--- a/src/bank-lib/test_bank_interpreter.c
+++ b/src/bank-lib/test_bank_interpreter.c
@@ -26,7 +26,7 @@
#include <gnunet/gnunet_curl_lib.h>
#include <microhttpd.h>
#include "test_bank_interpreter.h"
-#include "fakebank.h"
+#include "taler_fakebank_lib.h"
/**
@@ -72,7 +72,7 @@ struct InterpreterState
/**
* Fakebank, or NULL if we are not using the fakebank.
*/
- struct FAKEBANK_Handle *fakebank;
+ struct TALER_FAKEBANK_Handle *fakebank;
/**
* Instruction pointer. Tells #interpreter_run() which
@@ -242,7 +242,7 @@ interpreter_run (void *cls)
TALER_string_to_amount (ref->details.admin_add_incoming.amount,
&amount));
if (GNUNET_OK !=
- FAKEBANK_check (is->fakebank,
+ TALER_FAKEBANK_check (is->fakebank,
&amount,
ref->details.admin_add_incoming.debit_account_no,
ref->details.admin_add_incoming.credit_account_no,
@@ -265,7 +265,7 @@ interpreter_run (void *cls)
is);
return;
case TBI_OC_EXPECT_TRANSFERS_EMPTY:
- if (GNUNET_OK != FAKEBANK_check_empty (is->fakebank))
+ if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank))
{
GNUNET_break (0);
fail (is);
@@ -355,7 +355,7 @@ do_shutdown (void *cls)
}
if (NULL != is->fakebank)
{
- FAKEBANK_stop (is->fakebank);
+ TALER_FAKEBANK_stop (is->fakebank);
is->fakebank = NULL;
}
GNUNET_CURL_fini (is->ctx);
@@ -381,7 +381,7 @@ TBI_run_interpreter (int *resultp,
is = GNUNET_new (struct InterpreterState);
if (GNUNET_YES == run_bank)
- is->fakebank = FAKEBANK_start (8081);
+ is->fakebank = TALER_FAKEBANK_start (8081);
is->resultp = resultp;
is->commands = commands;
is->ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,