From 839c7497f1fb6dafc1147cb80131a16dd08dcec1 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Mon, 9 May 2016 16:34:32 +0200 Subject: adding src/backend testcases, plus utility function that returns the base32 encoding of a denomination key. --- src/backend/Makefile.am | 30 ++++++++++++++++++++++++++++ src/backend/taler-merchant-httpd_exchanges.c | 4 ++-- src/backend/taler-merchant-httpd_pay.c | 19 ++++++++++++++++++ src/backend/taler-merchant-httpd_pay.h | 8 ++++++++ src/backend/test-merchant.conf | 0 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/backend/test-merchant.conf (limited to 'src/backend') 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 #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 -- cgit v1.2.3