summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-05-09 16:34:32 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-05-09 16:34:32 +0200
commit839c7497f1fb6dafc1147cb80131a16dd08dcec1 (patch)
tree6973b69c518dbd3c9d333084da85d0e5d30d2490 /src/backend
parentb223a3c55baba6d4d6c458bc8e091df5965557c6 (diff)
downloadmerchant-839c7497f1fb6dafc1147cb80131a16dd08dcec1.tar.gz
merchant-839c7497f1fb6dafc1147cb80131a16dd08dcec1.tar.bz2
merchant-839c7497f1fb6dafc1147cb80131a16dd08dcec1.zip
adding src/backend testcases, plus utility function that returns the
base32 encoding of a denomination key.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/Makefile.am30
-rw-r--r--src/backend/taler-merchant-httpd_exchanges.c4
-rw-r--r--src/backend/taler-merchant-httpd_pay.c19
-rw-r--r--src/backend/taler-merchant-httpd_pay.h8
-rw-r--r--src/backend/test-merchant.conf0
5 files changed, 59 insertions, 2 deletions
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 7436eaa2..4c6c0b0d 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -12,6 +12,35 @@ EXTRA_DIST = \
bin_PROGRAMS = \
taler-merchant-httpd
+check_PROGRAMS = \
+ test-merchant
+
+TESTS = \
+ test-merchant
+
+test_merchant_SOURCES = \
+ test_merchant.c taler-merchant-httpd.h \
+ taler-merchant-httpd_parsing.c taler-merchant-httpd_parsing.h \
+ taler-merchant-httpd_responses.c taler-merchant-httpd_responses.h \
+ taler-merchant-httpd_mhd.c taler-merchant-httpd_mhd.h \
+ taler-merchant-httpd_auditors.c taler-merchant-httpd_auditors.h \
+ taler-merchant-httpd_exchanges.c taler-merchant-httpd_exchanges.h \
+ taler-merchant-httpd_contract.c taler-merchant-httpd_contract.h \
+ taler-merchant-httpd_pay.c taler-merchant-httpd_pay.h \
+ taler-merchant-httpd_util.c taler-merchant-httpd_util.h
+
+test_merchant_LDFLAGS = \
+ $(top_srcdir)/src/backenddb/libtalermerchantdb.la \
+ -ltalerexchange \
+ -ltalerjson \
+ -ltalerutil \
+ -ltalerpq \
+ -lmicrohttpd \
+ -ljansson \
+ -lgnunetcurl \
+ -lgnunetjson \
+ -lgnunetutil
+
taler_merchant_httpd_SOURCES = \
taler-merchant-httpd.c taler-merchant-httpd.h \
taler-merchant-httpd_parsing.c taler-merchant-httpd_parsing.h \
@@ -34,3 +63,4 @@ taler_merchant_httpd_LDADD = \
-lgnunetcurl \
-lgnunetjson \
-lgnunetutil
+
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c
index 35cfeaac..9a292365 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -312,7 +312,7 @@ return_result (void *cls)
*/
struct TMH_EXCHANGES_FindOperation *
TMH_EXCHANGES_find_exchange (const char *chosen_exchange,
- TMH_EXCHANGES_FindContinuation fc,
+ TMH_EXCHANGES_FindContinuation fc, // process payment
void *fc_cls)
{
struct Exchange *exchange;
@@ -390,7 +390,7 @@ TMH_EXCHANGES_find_exchange (const char *chosen_exchange,
exchange->fo_tail,
fo);
- if (GNUNET_YES != exchange->pending)
+ if (GNUNET_YES != exchange->pending) // can post coins
{
/* We are not currently waiting for a reply, immediately
return result */
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index 1c5b66bf..6ab1a0f3 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -232,6 +232,24 @@ resume_pay_with_response (struct PayContext *pc,
TMH_trigger_daemon (); /* we resumed, kick MHD */
}
+/**
+ * Convert denomination key to its base32 representation
+ *
+ * @param dk denomination key to convert
+ * @return 0-terminated base32 encoding of @a dk, to be deallocated
+ */
+char *
+denomination_to_string_alloc (struct TALER_DenominationPublicKey *dk)
+{
+ char *buf;
+ char *buf2;
+ size_t buf_size;
+ buf_size = GNUNET_CRYPTO_rsa_public_key_encode (dk->rsa_public_key, &buf);
+ buf2 = GNUNET_STRINGS_data_to_string_alloc (buf, buf_size);
+ GNUNET_free (buf);
+ return buf2;
+}
+
/**
* Abort all pending /deposit operations.
@@ -445,6 +463,7 @@ process_pay_with_exchange (void *cls,
&dc->denom);
if (NULL == denom_details)
{
+
GNUNET_break_op (0);
resume_pay_with_response (pc,
MHD_HTTP_BAD_REQUEST,
diff --git a/src/backend/taler-merchant-httpd_pay.h b/src/backend/taler-merchant-httpd_pay.h
index 92767520..c72865a5 100644
--- a/src/backend/taler-merchant-httpd_pay.h
+++ b/src/backend/taler-merchant-httpd_pay.h
@@ -23,6 +23,14 @@
#include <microhttpd.h>
#include "taler-merchant-httpd.h"
+/**
+ * Convert denomination key to its base32 representation
+ *
+ * @param dk denomination key to convert
+ * @return 0-terminated base32 encoding of @a dk, to be deallocated
+ */
+char *
+denomination_to_string_alloc (struct TALER_DenominationPublicKey *dk);
/**
* Manage a payment
diff --git a/src/backend/test-merchant.conf b/src/backend/test-merchant.conf
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/backend/test-merchant.conf