From ae2bfdbeaaa2ef289e79c0b57c428672a8157ff0 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Fri, 12 Jun 2020 18:52:20 -0400 Subject: fixed authorize tip and tests for GET /private/tips --- .../taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c | 1 + src/backend/taler-merchant-httpd_private-post-reserves.c | 5 +++++ src/backenddb/plugin_merchantdb_postgres.c | 6 +++++- src/testing/test_merchant_api.c | 5 ++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c index 0b363cfb..61e2b38a 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c @@ -149,6 +149,7 @@ authorize_tip (const struct TMH_RequestHandler *rh, (NULL == uri_path) ? "" : "/", hc->instance->settings.id, hash_enc.encoding)); + GNUNET_TIME_round_abs (&expiration); res = TALER_MHD_reply_json_pack (connection, MHD_HTTP_OK, "{s:s, s:s, s:o}", diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c b/src/backend/taler-merchant-httpd_private-post-reserves.c index 9da41057..77854a19 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves.c @@ -301,6 +301,11 @@ TMH_private_post_reserves (const struct TMH_RequestHandler *rh, &rc->initial_balance, rc->reserve_expiration); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); + // Do this temporarily for testing + qs = TMH_db->activate_reserve (TMH_db->cls, + mi->settings.id, + &reserve_pub, + &rc->initial_balance); if (qs < 0) return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index ac180443..0f338ff1 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -7561,7 +7561,11 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) ",tips_committed_val" ",tips_committed_frac" " FROM merchant_tip_reserves" - " WHERE exchange_initial_balance_val - tips_committed_val >= $2" + " WHERE" + " exchange_initial_balance_val - tips_committed_val > $2" + " OR" + " (exchange_initial_balance_val - tips_committed_val = $2" + " AND exchange_initial_balance_frac - tips_committed_frac >= $3)" " AND merchant_serial =" " (SELECT merchant_serial" " FROM merchant_instances" diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 324dd402..5ca5ec6f 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -643,11 +643,14 @@ run (void *cls, "x-taler-bank", MHD_HTTP_OK), TALER_TESTING_cmd_tip_authorize ("authorize-tip-1", - merchant_url_internal ("tip"), + merchant_url, EXCHANGE_URL, MHD_HTTP_OK, "tip 1", "EUR:5.01"), + TALER_TESTING_cmd_get_tips ("get-tips-1", + merchant_url, + MHD_HTTP_OK), #if 0 /* Test tipping. */ TALER_TESTING_cmd_admin_add_incoming_with_instance ("create-reserve-tip-1", -- cgit v1.2.3