diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-01-29 21:52:07 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-01-29 21:52:07 +0100 |
commit | a1c0c2fafde7f516223eabac8002f443dbef86ea (patch) | |
tree | 387a9f077d5438ff86b9c35d77737d0c46d66101 /src/testing/testing_api_cmd_reserve_close.c | |
parent | e8c8aa9efe8f407268e6f6e35d996f35756bc055 (diff) | |
download | exchange-a1c0c2fafde7f516223eabac8002f443dbef86ea.tar.xz |
add test for KYC required on reserve close
Diffstat (limited to 'src/testing/testing_api_cmd_reserve_close.c')
-rw-r--r-- | src/testing/testing_api_cmd_reserve_close.c | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/src/testing/testing_api_cmd_reserve_close.c b/src/testing/testing_api_cmd_reserve_close.c index 4c243c740..63d511603 100644 --- a/src/testing/testing_api_cmd_reserve_close.c +++ b/src/testing/testing_api_cmd_reserve_close.c @@ -67,6 +67,18 @@ struct CloseState * Interpreter state. */ struct TALER_TESTING_Interpreter *is; + + /** + * Set to the KYC requirement payto hash *if* the exchange replied with a + * request for KYC. + */ + struct TALER_PaytoHashP h_payto; + + /** + * Set to the KYC requirement row *if* the exchange replied with + * a request for KYC. + */ + uint64_t requirement_row; }; @@ -98,10 +110,19 @@ reserve_close_cb (void *cls, TALER_TESTING_interpreter_fail (ss->is); return; } - if (MHD_HTTP_OK != rs->hr.http_status) + switch (rs->hr.http_status) { - TALER_TESTING_interpreter_next (is); - return; + case MHD_HTTP_OK: + break; + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + /* nothing to check */ + ss->requirement_row + = rs->details.unavailable_for_legal_reasons.requirement_row; + ss->h_payto + = rs->details.unavailable_for_legal_reasons.h_payto; + break; + default: + break; } TALER_TESTING_interpreter_next (is); } @@ -178,6 +199,40 @@ close_cleanup (void *cls, } +/** + * Offer internal data to a "close" CMD state to other + * commands. + * + * @param cls closure + * @param[out] ret result (could be anything) + * @param trait name of the trait + * @param index index number of the object to offer. + * @return #GNUNET_OK on success + */ +static enum GNUNET_GenericReturnValue +close_traits (void *cls, + const void **ret, + const char *trait, + unsigned int index) +{ + struct CloseState *cs = cls; + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_legi_requirement_row ( + &cs->requirement_row), + TALER_TESTING_make_trait_h_payto ( + &cs->h_payto), + TALER_TESTING_trait_end () + }; + + if (cs->expected_response_code != MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS) + return GNUNET_NO; + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); +} + + struct TALER_TESTING_Command TALER_TESTING_cmd_reserve_close (const char *label, const char *reserve_reference, @@ -196,7 +251,8 @@ TALER_TESTING_cmd_reserve_close (const char *label, .cls = ss, .label = label, .run = &close_run, - .cleanup = &close_cleanup + .cleanup = &close_cleanup, + .traits = &close_traits }; return cmd; |