diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-02-01 13:09:06 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-02-01 13:09:13 +0100 |
commit | db448ff4ecf78e4568cd9f37d20ba8e691efe9b8 (patch) | |
tree | 4518bb3924b3b6c47fe367a8f9233b1d81efd768 | |
parent | ad966ab422bba81956d89f1918624b23df7deb52 (diff) |
add next_url to GET tip response (#7655)
-rw-r--r-- | src/backend/taler-merchant-httpd_get-tips-ID.c | 7 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_post-tips-ID-pickup.c | 7 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 17 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 97 | ||||
-rw-r--r-- | src/include/taler_merchant_service.h | 57 | ||||
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 7 | ||||
-rw-r--r-- | src/lib/merchant_api_wallet_get_tip.c | 43 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_wallet_get_tip.c | 28 |
8 files changed, 164 insertions, 99 deletions
diff --git a/src/backend/taler-merchant-httpd_get-tips-ID.c b/src/backend/taler-merchant-httpd_get-tips-ID.c index b20de7e1..f9e6c8cd 100644 --- a/src/backend/taler-merchant-httpd_get-tips-ID.c +++ b/src/backend/taler-merchant-httpd_get-tips-ID.c @@ -162,6 +162,7 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, struct TALER_Amount total_picked_up; struct GNUNET_TIME_Timestamp expiration; char *exchange_url; + char *next_url; struct TALER_ReservePrivateKeyP reserve_priv; (void) rh; @@ -185,6 +186,7 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, &total_picked_up, &expiration, &exchange_url, + &next_url, &reserve_priv); if (0 > qs) { @@ -249,6 +251,8 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, &remaining), GNUNET_JSON_pack_string ("taler_tip_uri", uri), + GNUNET_JSON_pack_string ("next_url", + next_url), GNUNET_JSON_pack_string ("taler_tip_qrcode_svg", qr)); ret = TALER_TEMPLATING_reply (connection, @@ -278,12 +282,15 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, : MHD_HTTP_OK, GNUNET_JSON_pack_string ("exchange_url", exchange_url), + GNUNET_JSON_pack_string ("next_url", + next_url), TALER_JSON_pack_amount ("tip_amount", &remaining), GNUNET_JSON_pack_timestamp ("expiration", expiration)); } GNUNET_free (exchange_url); + GNUNET_free (next_url); return ret; } } diff --git a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c index 32d78eca..5ef3cb40 100644 --- a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c +++ b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c @@ -619,6 +619,7 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh, { struct PickupContext *pc = hc->ctx; char *exchange_url; + char *next_url; struct TALER_Amount total_authorized; struct TALER_Amount total_picked_up; struct TALER_Amount total_remaining; @@ -740,6 +741,8 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh, if (! pc->tr_initialized) { + char *next_url; + qs = TMH_db->lookup_tip (TMH_db->cls, hc->instance->settings.id, &pc->tip_id, @@ -747,10 +750,12 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh, &total_picked_up, &expiration, &exchange_url, + &next_url, &pc->reserve_priv); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) return reply_lookup_tip_failed (connection, qs); + GNUNET_free (next_url); MHD_suspend_connection (connection); pc->connection = connection; pc->tt = GNUNET_SCHEDULER_add_delayed (EXCHANGE_TIMEOUT, @@ -900,6 +905,7 @@ RETRY: &total_picked_up, &expiration, &exchange_url, + &next_url, &pc->reserve_priv); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { @@ -912,6 +918,7 @@ RETRY: return reply_lookup_tip_failed (connection, qs); } + GNUNET_free (next_url); if (GNUNET_TIME_absolute_is_past (expiration.abs_time)) { GNUNET_free (exchange_url); diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 373ffa97..52ff3cd0 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -6324,6 +6324,7 @@ postgres_lookup_pickup (void *cls, * @param[out] total_picked_up how much of the tip was so far picked up (with fees) * @param[out] expiration set to when the tip expires * @param[out] exchange_url set to the exchange URL where the reserve is + * @param[out] next_url set to the URL where the wallet should navigate after getting the tip * @param[out] reserve_priv set to private key of reserve to be debited * @return transaction status */ @@ -6335,6 +6336,7 @@ postgres_lookup_tip (void *cls, struct TALER_Amount *total_picked_up, struct GNUNET_TIME_Timestamp *expiration, char **exchange_url, + char **next_url, struct TALER_ReservePrivateKeyP *reserve_priv) { struct PostgresClosure *pg = cls; @@ -6352,6 +6354,8 @@ postgres_lookup_tip (void *cls, expiration), GNUNET_PQ_result_spec_string ("exchange_url", exchange_url), + GNUNET_PQ_result_spec_string ("next_url", + next_url), GNUNET_PQ_result_spec_auto_from_type ("reserve_priv", reserve_priv), GNUNET_PQ_result_spec_end @@ -7654,13 +7658,13 @@ lookup_pending_webhooks_cb (void *cls, GNUNET_PQ_result_spec_string ("http_method", &http_method), GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("header", - &header), - NULL), + GNUNET_PQ_result_spec_string ("header", + &header), + NULL), GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("body", - &body), - NULL), + GNUNET_PQ_result_spec_string ("body", + &body), + NULL), GNUNET_PQ_result_spec_end }; @@ -10147,6 +10151,7 @@ postgres_connect (void *cls) ",picked_up_frac" ",merchant_tips.expiration" ",exchange_url" + ",next_url" ",reserve_priv" " FROM merchant_tips" " JOIN merchant_tip_reserves USING (reserve_serial)" diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 8d0e1071..e986d8f7 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -819,7 +819,7 @@ check_products_equal (const struct TALER_MERCHANTDB_ProductDetails *a, !=, b->next_restock))) - return 1; + return 1; return 0; } @@ -4924,6 +4924,7 @@ test_lookup_tip (const struct InstanceData *instance, struct TALER_Amount total_picked_up; struct GNUNET_TIME_Timestamp expiration; char *exchange_url = NULL; + char *next_url = NULL; struct TALER_ReservePrivateKeyP reserve_priv; if (1 != plugin->lookup_tip (plugin->cls, @@ -4933,6 +4934,7 @@ test_lookup_tip (const struct InstanceData *instance, &total_picked_up, &expiration, &exchange_url, + &next_url, &reserve_priv)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -4961,9 +4963,11 @@ test_lookup_tip (const struct InstanceData *instance, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup tip failed: mismatched data\n"); GNUNET_free (exchange_url); + GNUNET_free (next_url); return 1; } GNUNET_free (exchange_url); + GNUNET_free (next_url); return 0; } @@ -6970,7 +6974,7 @@ test_lookup_template (const struct InstanceData *instance, instance->instance.id, template->id, &lookup_result)) - { + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup template failed\n"); TALER_MERCHANTDB_template_details_free (&lookup_result); @@ -7036,7 +7040,7 @@ lookup_templates_cb (void *cls, for (unsigned int i = 0; cmp->templates_to_cmp_length > i; ++i) { if ((0 == strcmp (cmp->templates_to_cmp[i].id, - template_id)) && + template_id)) && (0 == strcmp (cmp->templates_to_cmp[i].template.template_description, template_description)) ) cmp->results_matching[i] += 1; @@ -7514,6 +7518,7 @@ test_lookup_webhooks (const struct InstanceData *instance, return 0; } + /** * Function called after calling @e test_lookup_webhooks * @@ -7538,16 +7543,17 @@ lookup_webhook_by_event_cb (void *cls, if ((0 == strcmp (cmp->webhooks_to_cmp[i].webhook.event_type, event_type)) && (0 == strcmp (cmp->webhooks_to_cmp[i].webhook.url, - url)) && + url)) && (0 == strcmp (cmp->webhooks_to_cmp[i].webhook.http_method, - http_method)) && + http_method)) && (0 == strcmp (cmp->webhooks_to_cmp[i].webhook.header_template, - header_template)) && + header_template)) && (0 == strcmp (cmp->webhooks_to_cmp[i].webhook.body_template, body_template)) ) cmp->results_matching[i] += 1; } - } +} + /** * Tests looking up webhooks by event for an instance. @@ -7600,7 +7606,6 @@ test_lookup_webhook_by_event (const struct InstanceData *instance, } - /** * Tests deleting a webhook. * @@ -7794,7 +7799,6 @@ test_webhooks (void) } - /* *********** Pending Webhooks ********** */ /** @@ -7805,7 +7809,7 @@ struct PendingWebhookData /** * Reference to the configured webhook template. */ - uint64_t webhook_serial; + uint64_t webhook_serial; /** * The details of the pending webhook. @@ -7814,8 +7818,6 @@ struct PendingWebhookData }; - - /** * Creates a pending webhook for testing with. * @@ -7828,13 +7830,14 @@ make_pending_webhook (uint64_t webhook_serial, { pwebhook->webhook_serial = webhook_serial; pwebhook->pwebhook.next_attempt = GNUNET_TIME_UNIT_ZERO_ABS; - pwebhook->pwebhook.retries= 0; + pwebhook->pwebhook.retries = 0; pwebhook->pwebhook.url = "https://exampletest.com"; pwebhook->pwebhook.http_method = "POST"; pwebhook->pwebhook.header = "Authorization:XYJAORKJEO"; pwebhook->pwebhook.body = "$Amount"; } + /** * Compare two pending webhooks for equality. * @@ -7843,8 +7846,10 @@ make_pending_webhook (uint64_t webhook_serial, * @return 0 on equality, 1 otherwise. */ static int -check_pending_webhooks_equal (const struct TALER_MERCHANTDB_PendingWebhookDetails *a, - const struct TALER_MERCHANTDB_PendingWebhookDetails *b) +check_pending_webhooks_equal (const struct + TALER_MERCHANTDB_PendingWebhookDetails *a, + const struct + TALER_MERCHANTDB_PendingWebhookDetails *b) { if (GNUNET_TIME_absolute_cmp (a->next_attempt, !=, @@ -7858,10 +7863,10 @@ check_pending_webhooks_equal (const struct TALER_MERCHANTDB_PendingWebhookDetail b->header)) || (0 != strcmp (a->body, b->body))) - { - fprintf(stdout, " retries %d vs %d", a->retries, b->retries); - return 1; - } + { + fprintf (stdout, " retries %d vs %d", a->retries, b->retries); + return 1; + } return 0; } @@ -7883,10 +7888,13 @@ test_insert_pending_webhook (const struct InstanceData *instance, TEST_COND_RET_ON_FAIL (expected_result == plugin->insert_pending_webhook (plugin->cls, instance->instance.id, - pwebhook->webhook_serial, + pwebhook-> + webhook_serial, pwebhook->pwebhook.url, - pwebhook->pwebhook.http_method, - pwebhook->pwebhook.header, + pwebhook->pwebhook. + http_method, + pwebhook->pwebhook. + header, pwebhook->pwebhook.body), "Insert pending webhook failed\n"); return 0; @@ -7908,8 +7916,10 @@ test_update_pending_webhook (const struct InstanceData *instance, { TEST_COND_RET_ON_FAIL (expected_result == plugin->update_pending_webhook (plugin->cls, - pwebhook->webhook_serial, - pwebhook->pwebhook.next_attempt), + pwebhook-> + webhook_serial, + pwebhook->pwebhook. + next_attempt), "Update pending webhook failed\n"); return 0; } @@ -7937,10 +7947,11 @@ test_lookup_pending_webhook (const struct InstanceData *instance, TALER_MERCHANTDB_pending_webhook_details_free (&lookup_result); return 1; } - const struct TALER_MERCHANTDB_PendingWebhookDetails *to_cmp = &pwebhook->pwebhook; + const struct TALER_MERCHANTDB_PendingWebhookDetails *to_cmp = + &pwebhook->pwebhook; if (0 != check_pending_webhooks_equal (&lookup_result, to_cmp)) - { + { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup pending webhook failed: incorrect pending webhook returned\n"); @@ -7951,6 +7962,7 @@ test_lookup_pending_webhook (const struct InstanceData *instance, return 0; } + /** * Closure for testing pending webhook lookup */ @@ -8001,9 +8013,10 @@ lookup_pending_webhooks_cb (void *cls, for (unsigned int i = 0; cmp->webhooks_to_cmp_length > i; ++i) { if ((cmp->webhooks_to_cmp[i].webhook_serial != webhook_serial) && - (GNUNET_TIME_absolute_cmp (cmp->webhooks_to_cmp[i].pwebhook.next_attempt, - !=, - next_attempt))) + (GNUNET_TIME_absolute_cmp ( + cmp->webhooks_to_cmp[i].pwebhook.next_attempt, + !=, + next_attempt))) cmp->results_matching[i] += 1; } } @@ -8019,8 +8032,8 @@ lookup_pending_webhooks_cb (void *cls, */ static int test_lookup_pending_webhooks (const struct InstanceData *instance, - unsigned int pwebhooks_length, - const struct PendingWebhookData *pwebhooks) + unsigned int pwebhooks_length, + const struct PendingWebhookData *pwebhooks) { unsigned int results_matching[pwebhooks_length]; struct TestLookupPendingWebhooks_Closure cls = { @@ -8031,8 +8044,8 @@ test_lookup_pending_webhooks (const struct InstanceData *instance, }; memset (results_matching, 0, sizeof (unsigned int) * pwebhooks_length); if (0 > plugin->lookup_pending_webhooks (plugin->cls, - &lookup_pending_webhooks_cb, - &cls)) + &lookup_pending_webhooks_cb, + &cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup pending webhook failed\n"); @@ -8054,7 +8067,8 @@ test_lookup_pending_webhooks (const struct InstanceData *instance, } } return 0; - } +} + /** * Tests looking up the future webhook to send for an instance. @@ -8066,8 +8080,8 @@ test_lookup_pending_webhooks (const struct InstanceData *instance, */ static int test_lookup_future_webhook (const struct InstanceData *instance, - unsigned int pwebhooks_length, - const struct PendingWebhookData *pwebhooks) + unsigned int pwebhooks_length, + const struct PendingWebhookData *pwebhooks) { unsigned int results_matching[pwebhooks_length]; struct TestLookupPendingWebhooks_Closure cls = { @@ -8103,6 +8117,7 @@ test_lookup_future_webhook (const struct InstanceData *instance, return 0; } + /** * Tests looking up all the pending webhook for an instance. * @@ -8116,8 +8131,8 @@ test_lookup_all_webhooks (const struct InstanceData *instance, unsigned int pwebhooks_length, const struct PendingWebhookData *pwebhooks) { - uint64_t max_results=2; - uint64_t min_row=0; + uint64_t max_results = 2; + uint64_t min_row = 0; unsigned int results_matching[pwebhooks_length]; struct TestLookupPendingWebhooks_Closure cls = { .webhooks_to_cmp_length = pwebhooks_length, @@ -8270,8 +8285,8 @@ run_test_pending_webhooks (struct TestPendingWebhooks_Closure *cls) &cls->pwebhooks[1], GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); TEST_RET_ON_FAIL (test_lookup_future_webhook (&cls->instance, - 1, - cls->pwebhooks)); + 1, + cls->pwebhooks)); TEST_RET_ON_FAIL (test_lookup_pending_webhooks (&cls->instance, 2, cls->pwebhooks)); @@ -8329,7 +8344,7 @@ run_tests (void) TEST_RET_ON_FAIL (test_kyc ()); TEST_RET_ON_FAIL (test_templates ()); TEST_RET_ON_FAIL (test_webhooks ()); - //TEST_RET_ON_FAIL (test_pending_webhooks ()); + // TEST_RET_ON_FAIL (test_pending_webhooks ()); return 0; } diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index e413a7c6..8237b47a 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -3442,24 +3442,63 @@ TALER_MERCHANT_reserve_delete_cancel ( */ struct TALER_MERCHANT_TipWalletGetHandle; +/** + * Response to a wallet's GET /tips/$TIP_ID request. + */ +struct TALER_MERCHANT_TipWalletGetResponse +{ + /** + * HTTP response details + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Details depending on the HTTP status code. + */ + union + { + + /** + * Details for #MHD_HTTP_OK status. + */ + struct + { + + /** + * when the tip will expire + */ + struct GNUNET_TIME_Timestamp expiration; + + /** + * exchange from which the coins should be withdrawn + */ + const char *exchange_url; + + /** + * URL where the wallet should navigate after withdrawing the tip. + */ + const char *next_url; + + /** + * total amount still available for the tip + */ + struct TALER_Amount amount_remaining; + } success; + + } details; +}; + /** * Callback to process a GET /tips/$TIP_ID request * * @param cls closure - * @param hr HTTP response details - * @param expiration when the tip will expire - * @param exchange_url exchange from which the coins should be withdrawn - * @param amount_remaining total amount still available for the tip + * @param wgr response details */ typedef void (*TALER_MERCHANT_TipWalletGetCallback) ( void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - struct GNUNET_TIME_Timestamp expiration, - const char *exchange_url, - const struct TALER_Amount *amount_remaining); - + const struct TALER_MERCHANT_TipWalletGetResponse *wgr); /** * Issue a GET /tips/$TIP_ID (public variant) request to the backend. Returns diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index fe974ba4..9b9d1505 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -420,7 +420,8 @@ typedef void typedef void (*TALER_MERCHANTDB_PendingWebhooksCallback)(void *cls, uint64_t webhook_pending_serial, - struct GNUNET_TIME_Absolute next_attempt, + struct GNUNET_TIME_Absolute + next_attempt, uint32_t retries, const char *url, const char *http_method, @@ -2437,6 +2438,7 @@ struct TALER_MERCHANTDB_Plugin * @param[out] total_picked_up how much of the tip was so far picked up (with fees) * @param[out] expiration set to when the tip expires * @param[out] exchange_url set to the exchange URL where the reserve is + * @param[out] next_url set to the URL where the wallet should navigate to after getting the tip * @param[out] reserve_priv set to private key of reserve to be debited * @return transaction status */ @@ -2448,6 +2450,7 @@ struct TALER_MERCHANTDB_Plugin struct TALER_Amount *total_picked_up, struct GNUNET_TIME_Timestamp *expiration, char **exchange_url, + char **next_url, struct TALER_ReservePrivateKeyP *reserve_priv); @@ -2826,7 +2829,7 @@ struct TALER_MERCHANTDB_Plugin (*update_pending_webhook)(void *cls, uint64_t webhook_pending_serial, struct GNUNET_TIME_Absolute next_attempt); - // maybe add: http status of failure? + // maybe add: http status of failure? /** diff --git a/src/lib/merchant_api_wallet_get_tip.c b/src/lib/merchant_api_wallet_get_tip.c index 49e507d0..82fc990f 100644 --- a/src/lib/merchant_api_wallet_get_tip.c +++ b/src/lib/merchant_api_wallet_get_tip.c @@ -80,9 +80,9 @@ handle_wallet_tip_get_finished (void *cls, { struct TALER_MERCHANT_TipWalletGetHandle *tgh = cls; const json_t *json = response; - struct TALER_MERCHANT_HttpResponse hr = { - .http_status = (unsigned int) response_code, - .reply = json + struct TALER_MERCHANT_TipWalletGetResponse wgr = { + .hr.http_status = (unsigned int) response_code, + .hr.reply = json }; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -94,16 +94,15 @@ handle_wallet_tip_get_finished (void *cls, { case MHD_HTTP_OK: { - const char *exchange_url; - struct TALER_Amount amount_remaining; - struct GNUNET_TIME_Timestamp expiration; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_timestamp ("expiration", - &expiration), + &wgr.details.success.expiration), GNUNET_JSON_spec_string ("exchange_url", - &exchange_url), + &wgr.details.success.exchange_url), + GNUNET_JSON_spec_string ("next_url", + &wgr.details.success.next_url), TALER_JSON_spec_amount_any ("tip_amount", - &amount_remaining), + &wgr.details.success.amount_remaining), GNUNET_JSON_spec_end () }; @@ -113,46 +112,40 @@ handle_wallet_tip_get_finished (void *cls, NULL, NULL)) { GNUNET_break_op (0); - hr.http_status = 0; - hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + wgr.hr.http_status = 0; + wgr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } tgh->cb (tgh->cb_cls, - &hr, - expiration, - exchange_url, - &amount_remaining); + &wgr); TALER_MERCHANT_wallet_tip_get_cancel (tgh); return; } case MHD_HTTP_INTERNAL_SERVER_ERROR: /* Server had an internal issue; we should retry, but this API leaves this to the application */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + wgr.hr.ec = TALER_JSON_get_error_code (json); + wgr.hr.hint = TALER_JSON_get_error_hint (json); break; case MHD_HTTP_NOT_FOUND: /* legal, can happen if instance or tip reserve is unknown */ - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); + wgr.hr.ec = TALER_JSON_get_error_code (json); + wgr.hr.hint = TALER_JSON_get_error_hint (json); break; default: /* unexpected response code */ GNUNET_break_op (0); TALER_MERCHANT_parse_error_details_ (json, response_code, - &hr); + &wgr.hr); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u/%d\n", (unsigned int) response_code, - (int) hr.ec); + (int) wgr.hr.ec); break; } tgh->cb (tgh->cb_cls, - &hr, - GNUNET_TIME_UNIT_ZERO_TS, - NULL, - NULL); + &wgr); TALER_MERCHANT_wallet_tip_get_cancel (tgh); } diff --git a/src/testing/testing_api_cmd_wallet_get_tip.c b/src/testing/testing_api_cmd_wallet_get_tip.c index 0c19a5b9..f10b8663 100644 --- a/src/testing/testing_api_cmd_wallet_get_tip.c +++ b/src/testing/testing_api_cmd_wallet_get_tip.c @@ -77,17 +77,11 @@ struct WalletTipGetState * expectations. * * @param cls closure - * @param hr HTTP response - * @param reserve_expiration when the tip reserve will expire - * @param exchange_url from where to pick up the tip - * @param amount_remaining how much is remaining + * @param whr response */ static void wallet_tip_get_cb (void *cls, - const struct TALER_MERCHANT_HttpResponse *hr, - struct GNUNET_TIME_Timestamp reserve_expiration, - const char *exchange_url, - const struct TALER_Amount *amount_remaining) + const struct TALER_MERCHANT_TipWalletGetResponse *wgr) { struct WalletTipGetState *gts = cls; const struct TALER_TESTING_Command *tip_cmd; @@ -97,25 +91,27 @@ wallet_tip_get_cb (void *cls, gts->tip_reference); gts->tgh = NULL; - if (gts->http_status != hr->http_status) + if (gts->http_status != wgr->hr.http_status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u (%d) to command %s\n", - hr->http_status, - (int) hr->ec, + wgr->hr.http_status, + (int) wgr->hr.ec, TALER_TESTING_interpreter_get_current_label (gts->is)); TALER_TESTING_interpreter_fail (gts->is); return; } - switch (hr->http_status) + switch (wgr->hr.http_status) { case MHD_HTTP_OK: if (gts->cmp_amounts) { - if ((GNUNET_OK != TALER_amount_cmp_currency (>s->amount_remaining, - amount_remaining)) || + if ((GNUNET_OK != + TALER_amount_cmp_currency (>s->amount_remaining, + &wgr->details.success.amount_remaining)) + || (0 != TALER_amount_cmp (>s->amount_remaining, - amount_remaining))) + &wgr->details.success.amount_remaining))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Amount remaining on tip does not match\n"); @@ -133,7 +129,7 @@ wallet_tip_get_cb (void *cls, TALER_TESTING_interpreter_fail (gts->is); if (GNUNET_TIME_timestamp_cmp (*expiration, !=, - reserve_expiration)) + wgr->details.success.expiration)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Tip expiration does not match\n"); |