From e491838fc6143011634a0148bf03a0b7a3bca5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Bl=C3=A4ttler?= Date: Fri, 26 Apr 2024 11:47:34 +0200 Subject: extend testing lib to support paying for orders with choices --- src/testing/testing_api_cmd_pay_order.c | 54 +++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'src/testing') diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c index 0b84c8a6..f748a06a 100644 --- a/src/testing/testing_api_cmd_pay_order.c +++ b/src/testing/testing_api_cmd_pay_order.c @@ -23,6 +23,7 @@ * @author Christian Grothoff */ #include "platform.h" +#include #include #include #include @@ -107,6 +108,11 @@ struct PayState */ enum TALER_MerchantConfirmationAlgorithm pos_alg; + /** + * Wallet data json object. Used in the pay request if not NULL. + */ + const json_t *wallet_data; + }; @@ -438,7 +444,7 @@ pay_run (void *cls, ps->merchant_url, ps->session_id, h_proposal, - NULL, + ps->wallet_data, &ps->total_amount, &max_fee, &merchant_pub, @@ -560,14 +566,16 @@ pay_traits (void *cls, struct TALER_TESTING_Command -TALER_TESTING_cmd_merchant_pay_order (const char *label, - const char *merchant_url, - unsigned int http_status, - const char *proposal_reference, - const char *coin_reference, - const char *amount_with_fee, - const char *amount_without_fee, - const char *session_id) +TALER_TESTING_cmd_merchant_pay_order_choices (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *proposal_reference, + const char *coin_reference, + const char *amount_with_fee, + const char *amount_without_fee, + const char *session_id, + int choice_index, + const char *input_reference) { struct PayState *ps; @@ -579,6 +587,12 @@ TALER_TESTING_cmd_merchant_pay_order (const char *label, ps->amount_with_fee = amount_with_fee; ps->amount_without_fee = amount_without_fee; ps->session_id = session_id; + if (0 <= choice_index) + { + ps->wallet_data = json_pack ("{s:i}", + "choice_index", + choice_index); + } { struct TALER_TESTING_Command cmd = { .cls = ps, @@ -593,4 +607,26 @@ TALER_TESTING_cmd_merchant_pay_order (const char *label, } +struct TALER_TESTING_Command +TALER_TESTING_cmd_merchant_pay_order (const char *label, + const char *merchant_url, + unsigned int http_status, + const char *proposal_reference, + const char *coin_reference, + const char *amount_with_fee, + const char *amount_without_fee, + const char *session_id) +{ + return TALER_TESTING_cmd_merchant_pay_order_choices (label, + merchant_url, + http_status, + proposal_reference, + coin_reference, + amount_with_fee, + amount_without_fee, + session_id, + -1); +} + + /* end of testing_api_cmd_pay_order.c */ -- cgit v1.2.3