From 16ed21afe071277d797b575a0d15fa29bd969c0b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 20 Sep 2015 14:02:10 +0200 Subject: expanding test to cover multi-wire format scenarios (#3972) --- contrib/mint-template/config/mint-common.conf | 3 ++- src/mint-lib/mint_api_wire.c | 3 ++- .../test-mint-home/config/mint-common.conf | 8 +++---- src/mint-lib/test_mint_api.c | 27 ++++++++++++++-------- src/mint/taler-mint-httpd_wire.c | 5 ---- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/contrib/mint-template/config/mint-common.conf b/contrib/mint-template/config/mint-common.conf index 958763b2b..78a3310a1 100644 --- a/contrib/mint-template/config/mint-common.conf +++ b/contrib/mint-template/config/mint-common.conf @@ -2,7 +2,8 @@ # Currency supported by the mint (can only be one) CURRENCY = EUR -# Wire format supported by the mint (currently only SEPA is implemented) +# Wire format supported by the mint, case-insensitive. +# Examples for formats include 'test' for testing and 'sepa' (for EU IBAN). WIREFORMAT = SEPA # HTTP port the mint listens to diff --git a/src/mint-lib/mint_api_wire.c b/src/mint-lib/mint_api_wire.c index f1bbb0997..81506961b 100644 --- a/src/mint-lib/mint_api_wire.c +++ b/src/mint-lib/mint_api_wire.c @@ -289,7 +289,8 @@ handle_wire_method_finished (void *cls, /* pass on successful reply */ wh->cb (wh->cb_cls, response_code, - NULL, + json_string_value (json_array_get (wh->methods, + wh->methods_off-1)), json); /* trigger request for the next /wire/method */ request_wire_method (wh); diff --git a/src/mint-lib/test-mint-home/config/mint-common.conf b/src/mint-lib/test-mint-home/config/mint-common.conf index eb2f7e90b..f4bc21622 100644 --- a/src/mint-lib/test-mint-home/config/mint-common.conf +++ b/src/mint-lib/test-mint-home/config/mint-common.conf @@ -3,11 +3,9 @@ CURRENCY = EUR # Wire format supported by the mint -# We use 'test' for testing, in principle we should -# run tests for all supported wire formats... -# (we should first implement support for a mint running -# with multiple formats at the same time). -WIREFORMAT = test +# We use 'test' for testing of the actual +# coin operations, and 'sepa' to test SEPA-specific routines. +WIREFORMAT = test sepa # HTTP port the mint listens to PORT = 8081 diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index 6fb099095..7b96f657c 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -33,9 +33,8 @@ /** * Is the configuration file is set to include wire format 'sepa'? - * Needs #3972 to be solved first. */ -#define WIRE_SEPA 0 +#define WIRE_SEPA 1 /** * Main execution context for the main loop. @@ -464,6 +463,11 @@ struct Command */ struct TALER_MINT_WireHandle *wh; + /** + * Format we expect to see, others will be *ignored*. + */ + const char *format; + } wire; } details; @@ -1038,10 +1042,6 @@ link_cb (void *cls, return; } /* check that the coins match */ - fprintf (stderr, - "Got %u coins\n", - num_coins); - for (i=0;idetails.wire.wh = NULL; } + else if ( (NULL != method) && + (0 != strcasecmp (method, + cmd->details.wire.format)) ) + { + /* not the method we care about, skip */ + return; + } if (cmd->expected_response_code != http_status) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1994,13 +2001,15 @@ run (void *cls, { .oc = OC_WIRE, .label = "wire-test", /* /wire/test replies with a 302 redirect */ - .expected_response_code = MHD_HTTP_FOUND }, + .expected_response_code = MHD_HTTP_FOUND, + .details.wire.format = "test" }, #endif #if WIRE_SEPA - { .oc = OC_WIRE, + { .oc = OC_WIRE, .label = "wire-sepa", /* /wire/sepa replies with a 200 redirect */ - .expected_response_code = MHD_HTTP_OK }, + .expected_response_code = MHD_HTTP_OK, + .details.wire.format = "sepa" }, #endif /* *************** end of /wire testing ************** */ diff --git a/src/mint/taler-mint-httpd_wire.c b/src/mint/taler-mint-httpd_wire.c index 68dc1419f..143d7c48d 100644 --- a/src/mint/taler-mint-httpd_wire.c +++ b/src/mint/taler-mint-httpd_wire.c @@ -66,11 +66,6 @@ TMH_WIRE_handler_wire (struct TMH_RequestHandler *rh, TMH_KS_sign (&wsm.purpose, &pub, &sig); - /* NOTE: for now, we only support *ONE* wire format per - mint instance; if we supply multiple, we need to - add the strings for each type separately here -- and - hash the 0-terminated strings above differently as well... - See #3972. */ return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o, s:o}", -- cgit v1.2.3