From 6d41df4ffbc0d921aecb265ecb49b15df5c7178e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 22 Mar 2024 14:05:42 +0100 Subject: add logic to preserve and possibly update minimum_age in contract terms --- src/testing/testing_api_cmd_merchant_get_order.c | 61 +++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'src/testing/testing_api_cmd_merchant_get_order.c') diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c index 1b235c93..6301c9f6 100644 --- a/src/testing/testing_api_cmd_merchant_get_order.c +++ b/src/testing/testing_api_cmd_merchant_get_order.c @@ -105,6 +105,11 @@ struct MerchantGetOrderState */ const char *repurchase_order_ref; + /** + * Expected minimum age. + */ + unsigned int expected_min_age; + /** * True if we should pass the 'allow_refunded_for_repurchase' flag. */ @@ -176,7 +181,9 @@ merchant_get_order_cb ( if (gos->osc != osr->details.ok.status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Order paid does not match\n"); + "Order paid does not match: %d vs %d\n", + gos->osc, + osr->details.ok.status); TALER_TESTING_interpreter_fail (gos->is); return; } @@ -187,6 +194,17 @@ merchant_get_order_cb ( const struct TALER_TESTING_Command *order_cmd; struct TALER_Amount refunded_total; + if ( (0 != gos->expected_min_age) && + (gos->expected_min_age != + json_integer_value ( + json_object_get ( + osr->details.ok.details.paid.contract_terms, + "minimum_age"))) ) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (gos->is); + return; + } order_cmd = TALER_TESTING_interpreter_lookup_command ( gos->is, gos->order_reference); @@ -422,6 +440,17 @@ merchant_get_order_cb ( break; case TALER_MERCHANT_OSC_CLAIMED: /* FIXME: Check contract terms... */ + if ( (0 != gos->expected_min_age) && + (gos->expected_min_age != + json_integer_value ( + json_object_get ( + osr->details.ok.details.claimed.contract_terms, + "minimum_age"))) ) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (gos->is); + return; + } break; case TALER_MERCHANT_OSC_UNPAID: { @@ -754,6 +783,36 @@ TALER_TESTING_cmd_merchant_get_order3 ( } +struct TALER_TESTING_Command +TALER_TESTING_cmd_merchant_get_order4 ( + const char *label, + const char *merchant_url, + const char *order_reference, + enum TALER_MERCHANT_OrderStatusCode osc, + uint32_t expected_min_age, + unsigned int expected_http_status) +{ + struct MerchantGetOrderState *gos; + + gos = GNUNET_new (struct MerchantGetOrderState); + gos->merchant_url = merchant_url; + gos->order_reference = order_reference; + gos->osc = osc; + gos->expected_min_age = expected_min_age; + gos->http_status = expected_http_status; + { + struct TALER_TESTING_Command cmd = { + .cls = gos, + .label = label, + .run = &merchant_get_order_run, + .cleanup = &merchant_get_order_cleanup + }; + + return cmd; + } +} + + struct MerchantPollOrderConcludeState { /** -- cgit v1.2.3