diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-09-20 14:02:10 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-09-20 14:02:10 +0200 |
commit | 16ed21afe071277d797b575a0d15fa29bd969c0b (patch) | |
tree | 9fc4eea7f2753145fe55517f5458fb96be2abe5e | |
parent | a6f8fa98b0253091cae0f2e38fb5fcec47e115fa (diff) |
expanding test to cover multi-wire format scenarios (#3972)
-rw-r--r-- | contrib/mint-template/config/mint-common.conf | 3 | ||||
-rw-r--r-- | src/mint-lib/mint_api_wire.c | 3 | ||||
-rw-r--r-- | src/mint-lib/test-mint-home/config/mint-common.conf | 8 | ||||
-rw-r--r-- | src/mint-lib/test_mint_api.c | 27 | ||||
-rw-r--r-- | 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;i<num_coins;i++) for (j=i+1;j<num_coins;j++) if (0 == memcmp (&coin_privs[i], @@ -1186,6 +1186,13 @@ wire_cb (void *cls, /* 0 always signals the end of the iteration */ cmd->details.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}", |