diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-03-18 21:12:43 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-03-18 21:12:43 +0100 |
commit | 5bc607b1fe266598ad5b25202ec98e57e532b4d7 (patch) | |
tree | 70c2be1aa71f5c0d28539ddc8f5a655cef9c1d6b | |
parent | 42cca4fd3d262fb372d510824fa9396db8bba256 (diff) | |
download | merchant-5bc607b1fe266598ad5b25202ec98e57e532b4d7.tar.gz merchant-5bc607b1fe266598ad5b25202ec98e57e532b4d7.tar.bz2 merchant-5bc607b1fe266598ad5b25202ec98e57e532b4d7.zip |
simplify kyc logic in payment logic as we now have taler-merchant-depositcheck doing it better
-rw-r--r-- | src/backend/taler-merchant-depositcheck.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_post-orders-ID-pay.c | 333 | ||||
-rw-r--r-- | src/backend/taler-merchant-wirewatch.c | 5 | ||||
-rw-r--r-- | src/backenddb/pg_insert_deposit_confirmation.c | 8 | ||||
-rw-r--r-- | src/backenddb/pg_lookup_pending_deposits.c | 6 | ||||
-rw-r--r-- | src/testing/test_kyc_api.c | 497 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_post_orders.c | 27 |
7 files changed, 301 insertions, 577 deletions
diff --git a/src/backend/taler-merchant-depositcheck.c b/src/backend/taler-merchant-depositcheck.c index 6bb3b05b..af2fa267 100644 --- a/src/backend/taler-merchant-depositcheck.c +++ b/src/backend/taler-merchant-depositcheck.c @@ -513,7 +513,7 @@ deposit_get_cb (void *cls, qs = db_plugin->update_deposit_confirmation_status ( db_plugin->cls, w->deposit_serial, - true, /* FIXME: should we set this to 'false' as we are awaiting KYC? */ + true, GNUNET_TIME_absolute_to_timestamp (future_retry), w->retry_backoff, "Exchange reported 202 Accepted due to KYC/AML block"); diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c index a1fdabec..cbd4aa74 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -477,69 +477,6 @@ struct PayContext /** - * Active KYC operation with an exchange. - */ -struct KycContext -{ - /** - * Kept in a DLL. - */ - struct KycContext *next; - - /** - * Kept in a DLL. - */ - struct KycContext *prev; - - /** - * Looking for the exchange. - */ - struct TMH_EXCHANGES_KeysOperation *fo; - - /** - * Exchange this is about. - */ - char *exchange_url; - - /** - * Merchant instance this is for. - */ - struct TMH_MerchantInstance *mi; - - /** - * Wire method we are checking the status of. - */ - struct TMH_WireMethod *wm; - - /** - * Handle for the GET /deposits operation. - */ - struct TALER_EXCHANGE_DepositGetHandle *dg; - - /** - * Contract we are looking up. - */ - struct TALER_PrivateContractHashP h_contract_terms; - - /** - * Coin we are looking up. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; - - /** - * Initial DB timestamp. - */ - struct GNUNET_TIME_Timestamp kyc_timestamp; - - /** - * Initial KYC status. - */ - bool kyc_ok; - -}; - - -/** * Head of active pay context DLL. */ static struct PayContext *pc_head; @@ -549,57 +486,10 @@ static struct PayContext *pc_head; */ static struct PayContext *pc_tail; -/** - * Head of active KYC context DLL. - */ -static struct KycContext *kc_head; - -/** - * Tail of active KYC context DLL. - */ -static struct KycContext *kc_tail; - - -/** - * Free resources used by @a kc. - * - * @param[in] kc object to free - */ -static void -destroy_kc (struct KycContext *kc) -{ - if (NULL != kc->fo) - { - TMH_EXCHANGES_keys4exchange_cancel (kc->fo); - kc->fo = NULL; - } - if (NULL != kc->dg) - { - TALER_EXCHANGE_deposits_get_cancel (kc->dg); - kc->dg = NULL; - } - TMH_instance_decref (kc->mi); - kc->mi = NULL; - GNUNET_free (kc->exchange_url); - GNUNET_CONTAINER_DLL_remove (kc_head, - kc_tail, - kc); - GNUNET_free (kc); -} - void TMH_force_pc_resume () { - struct KycContext *kc; - - while (NULL != (kc = kc_head)) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Aborting KYC check at %s\n", - kc->exchange_url); - destroy_kc (kc); - } for (struct PayContext *pc = pc_head; NULL != pc; pc = pc->next) @@ -744,221 +634,6 @@ phase_return_response (struct PayContext *pc) /** - * Function called with detailed wire transfer data. - * - * @param cls a `struct KycContext *` - * @param dr HTTP response data - */ -static void -deposit_get_callback ( - void *cls, - const struct TALER_EXCHANGE_GetDepositResponse *dr) -{ - struct KycContext *kc = cls; - enum GNUNET_DB_QueryStatus qs; - struct GNUNET_TIME_Timestamp now; - - kc->dg = NULL; - now = GNUNET_TIME_timestamp_get (); - switch (dr->hr.http_status) - { - case MHD_HTTP_OK: - qs = TMH_db->account_kyc_set_status ( - TMH_db->cls, - kc->mi->settings.id, - &kc->wm->h_wire, - kc->exchange_url, - 0LL, - NULL, /* no signature */ - NULL, /* no signature */ - now, - true, - TALER_AML_NORMAL); - GNUNET_break (qs > 0); - break; - case MHD_HTTP_ACCEPTED: - qs = TMH_db->account_kyc_set_status ( - TMH_db->cls, - kc->mi->settings.id, - &kc->wm->h_wire, - kc->exchange_url, - dr->details.accepted.requirement_row, - NULL, /* no signature */ - NULL, /* no signature */ - now, - dr->details.accepted.kyc_ok, - dr->details.accepted.aml_decision); - GNUNET_break (qs > 0); - break; - default: - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "KYC check failed at %s with unexpected status %u\n", - kc->exchange_url, - dr->hr.http_status); - } - destroy_kc (kc); -} - - -/** - * Function called with the result of our exchange lookup. - * - * @param cls the `struct KycContext` - * @param keys NULL if exchange was not found to be acceptable - * @param exchange representation of the exchange - */ -static void -process_kyc_with_exchange ( - void *cls, - struct TALER_EXCHANGE_Keys *keys, - struct TMH_Exchange *exchange) -{ - struct KycContext *kc = cls; - - (void) exchange; - kc->fo = NULL; - if (NULL == keys) - { - destroy_kc (kc); - return; - } - kc->dg = TALER_EXCHANGE_deposits_get ( - TMH_curl_ctx, - kc->exchange_url, - keys, - &kc->mi->merchant_priv, - &kc->wm->h_wire, - &kc->h_contract_terms, - &kc->coin_pub, - GNUNET_TIME_UNIT_ZERO, - &deposit_get_callback, - kc); - if (NULL == kc->dg) - { - GNUNET_break (0); - destroy_kc (kc); - } -} - - -/** - * Function called from ``account_kyc_get_status`` - * with KYC status information for this merchant. - * - * @param cls a `struct KycContext *` - * @param h_wire hash of the wire account - * @param exchange_kyc_serial serial number for the KYC process at the exchange, 0 if unknown - * @param payto_uri payto:// URI of the merchant's bank account - * @param exchange_url base URL of the exchange for which this is a status - * @param last_check when did we last get an update on our KYC status from the exchange - * @param kyc_ok true if we satisfied the KYC requirements - * @param aml_decision latest AML decision by the exchange - */ -static void -kyc_cb ( - void *cls, - const struct TALER_MerchantWireHashP *h_wire, - uint64_t exchange_kyc_serial, - const char *payto_uri, - const char *exchange_url, - struct GNUNET_TIME_Timestamp last_check, - bool kyc_ok, - enum TALER_AmlDecisionState aml_decision) -{ - struct KycContext *kc = cls; - - (void) h_wire; - (void) exchange_kyc_serial; - (void) payto_uri; - (void) exchange_url; - kc->kyc_timestamp = last_check; - kc->kyc_ok = kyc_ok; - /* FIXME: act on aml_decision? */ -} - - -/** - * Check for our KYC status at @a exchange_url for the - * payment of @a pc. First checks if we already have a - * positive result from the exchange, and if not checks - * with the exchange. - * - * @param pc payment context to use as starting point - * @param eg exchange group of the exchange we are triggering on - */ -static void -check_kyc (struct PayContext *pc, - const struct ExchangeGroup *eg) -{ - enum GNUNET_DB_QueryStatus qs; - struct KycContext *kc; - - kc = GNUNET_new (struct KycContext); - qs = TMH_db->account_kyc_get_status (TMH_db->cls, - pc->hc->instance->settings.id, - &pc->wm->h_wire, - eg->exchange_url, - &kyc_cb, - kc); - if (qs < 0) - { - GNUNET_break (0); - GNUNET_free (kc); - return; - } - if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) - { - if (kc->kyc_ok) - { - GNUNET_free (kc); - return; /* we are done */ - } - if (GNUNET_TIME_relative_cmp ( - GNUNET_TIME_absolute_get_duration ( - kc->kyc_timestamp.abs_time), - <, - KYC_RETRY_FREQUENCY)) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not re-checking KYC status at `%s', as we already recently asked\n", - eg->exchange_url); - GNUNET_free (kc); - return; - } - } - kc->mi = pc->hc->instance; - kc->mi->rc++; - kc->wm = pc->wm; - kc->exchange_url = GNUNET_strdup (eg->exchange_url); - kc->h_contract_terms = pc->h_contract_terms; - /* find one of the coins of the batch */ - for (unsigned int i = 0; i<pc->coins_cnt; i++) - { - struct DepositConfirmation *dc = &pc->dc[i]; - - if (0 != strcmp (eg->exchange_url, - pc->dc[i].exchange_url)) - continue; - kc->coin_pub = dc->cdd.coin_pub; - break; - } - GNUNET_CONTAINER_DLL_insert (kc_head, - kc_tail, - kc); - kc->fo = TMH_EXCHANGES_keys4exchange ( - kc->exchange_url, - false, - &process_kyc_with_exchange, - kc); - if (NULL == kc->fo) - { - GNUNET_break (0); - destroy_kc (kc); - } -} - - -/** * Do database transaction for a completed batch deposit. * * @param eg group that completed @@ -1133,8 +808,6 @@ handle_batch_deposit_ok (struct ExchangeGroup *eg, dc->found_in_db = true; /* well, at least NOW it'd be true ;-) */ pc->pending--; } - check_kyc (pc, - eg); } @@ -1577,9 +1250,9 @@ get_pay_timeout (unsigned int num_coins) { struct GNUNET_TIME_Relative t; - /* FIXME: Do some benchmarking to come up with a better timeout. - * We've increased this value so the wallet integration test passes again - * on my (Florian) machine. + /* FIXME-Performance-Optimization: Do some benchmarking to come up with a + * better timeout. We've increased this value so the wallet integration + * test passes again on my (Florian) machine. */ t = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15 * (1 + (num_coins / 5))); diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c index 6242ddbc..17eb7a0a 100644 --- a/src/backend/taler-merchant-wirewatch.c +++ b/src/backend/taler-merchant-wirewatch.c @@ -370,9 +370,8 @@ credit_cb ( w->start_row = serial_id; return GNUNET_OK; } - /* FIXME: consider grouping multiple inserts - into one bigger transaction with just one - notify! */ + /* FIXME-Performance-Optimization: consider grouping multiple inserts + into one bigger transaction with just one notify. */ credit_payto = TALER_payto_normalize (details->credit_account_uri); qs = db_plugin->insert_transfer (db_plugin->cls, w->instance_id, diff --git a/src/backenddb/pg_insert_deposit_confirmation.c b/src/backenddb/pg_insert_deposit_confirmation.c index 6ad0f5fb..f23bf252 100644 --- a/src/backenddb/pg_insert_deposit_confirmation.c +++ b/src/backenddb/pg_insert_deposit_confirmation.c @@ -70,10 +70,14 @@ TMH_PG_insert_deposit_confirmation ( /* no preflight check here, run in transaction by caller! */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Storing deposit confirmation for instance `%s' h_contract_terms `%s', total_without_fees: %s\n", + "Storing deposit confirmation for instance `%s' h_contract_terms `%s', total_without_fees: %s and wire transfer deadline in %s\n", instance_id, GNUNET_h2s (&h_contract_terms->hash), - TALER_amount2s (total_without_fees)); + TALER_amount2s (total_without_fees), + GNUNET_TIME_relative2s ( + GNUNET_TIME_absolute_get_remaining ( + wire_transfer_deadline.abs_time), + true)); check_connection (pg); PREPARE (pg, "insert_deposit_confirmation", diff --git a/src/backenddb/pg_lookup_pending_deposits.c b/src/backenddb/pg_lookup_pending_deposits.c index c48fc24d..ab8981a5 100644 --- a/src/backenddb/pg_lookup_pending_deposits.c +++ b/src/backenddb/pg_lookup_pending_deposits.c @@ -175,7 +175,7 @@ TMH_PG_lookup_pending_deposits ( " USING (order_serial)" " JOIN merchant_accounts ma" " USING (account_serial)" - " JOIN merchant_kyc kyc" + " LEFT JOIN merchant_kyc kyc" " ON (ma.account_serial=kyc.account_serial)" " JOIN merchant_instances mi" " ON (mct.merchant_serial=mi.merchant_serial)" @@ -186,8 +186,8 @@ TMH_PG_lookup_pending_deposits ( " WHERE mdc.wire_pending" " AND (mdc.exchange_url=$1)" " AND ($4 OR (mdc.wire_transfer_deadline < $2))" - " AND kyc.kyc_ok" - " AND (0=kyc.aml_decision)" + " AND ( (kyc.kyc_ok IS NULL) OR kyc.kyc_ok)" + " AND ( (kyc.aml_decision IS NULL) OR (0=kyc.aml_decision) )" " ORDER BY mdc.wire_transfer_deadline ASC" " LIMIT $3"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c index 1bb9f472..6ef40b45 100644 --- a/src/testing/test_kyc_api.c +++ b/src/testing/test_kyc_api.c @@ -138,211 +138,250 @@ run (void *cls, /** * Move money to the exchange's bank account. */ - cmd_transfer_to_exchange ("create-reserve-1", - "EUR:10.02"), + cmd_transfer_to_exchange ( + "create-reserve-1", + "EUR:10.02"), /** * Make a reserve exist, according to the previous transfer. */ - TALER_TESTING_cmd_exec_wirewatch ("wirewatch-1", - CONFIG_FILE), - TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-2", - "EUR:10.02", - payer_payto, - exchange_payto, - "create-reserve-1"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1", - "create-reserve-1", - "EUR:5", - 0, - MHD_HTTP_OK), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2", - "create-reserve-1", - "EUR:5", - 0, - MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_get_orders ("get-orders-empty", - merchant_url, - MHD_HTTP_OK, - NULL), + TALER_TESTING_cmd_exec_wirewatch ( + "wirewatch-1", + CONFIG_FILE), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check_bank_transfer-2", + "EUR:10.02", + payer_payto, + exchange_payto, + "create-reserve-1"), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-1", + "create-reserve-1", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-2", + "create-reserve-1", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_get_orders ( + "get-orders-empty", + merchant_url, + MHD_HTTP_OK, + NULL), /** * Check the reserve is depleted. */ - TALER_TESTING_cmd_status ("withdraw-status-1", - "create-reserve-1", - "EUR:0", - MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-1", - cred.cfg, - merchant_url, - MHD_HTTP_OK, - "1", /* order ID */ - GNUNET_TIME_UNIT_ZERO_TS, - GNUNET_TIME_UNIT_FOREVER_TS, - true, - "EUR:5.0", - "x-taler-bank", - "", - "", - NULL), - TALER_TESTING_cmd_merchant_claim_order ("reclaim-1", - merchant_url, - MHD_HTTP_OK, - "create-proposal-1", - NULL), - TALER_TESTING_cmd_merchant_pay_order ("deposit-simple", - merchant_url, - MHD_HTTP_OK, - "create-proposal-1", - "withdraw-coin-1", - "EUR:5", - "EUR:4.99", - "session-0"), - TALER_TESTING_cmd_merchant_post_orders_paid ("verify-order-1-paid", - merchant_url, - "deposit-simple", - "session-1", - MHD_HTTP_OK), - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-1"), - CMD_EXEC_AGGREGATOR ("run-aggregator"), + TALER_TESTING_cmd_status ( + "withdraw-status-1", + "create-reserve-1", + "EUR:0", + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_post_orders2 ( + "create-proposal-1", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "1", /* order ID */ + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + true, + "EUR:5.0", + "x-taler-bank", + "", + "", + NULL), + TALER_TESTING_cmd_merchant_claim_order ( + "reclaim-1", + merchant_url, + MHD_HTTP_OK, + "create-proposal-1", + NULL), + TALER_TESTING_cmd_merchant_pay_order ( + "deposit-simple", + merchant_url, + MHD_HTTP_OK, + "create-proposal-1", + "withdraw-coin-1", + "EUR:5", + "EUR:4.99", + "session-0"), + TALER_TESTING_cmd_merchant_post_orders_paid ( + "verify-order-1-paid", + merchant_url, + "deposit-simple", + "session-1", + MHD_HTTP_OK), + TALER_TESTING_cmd_check_bank_empty ( + "check_bank_empty-1"), + CMD_EXEC_AGGREGATOR ( + "run-aggregator"), /* KYC: hence nothing happened at the bank yet: */ - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-2"), + TALER_TESTING_cmd_check_bank_empty ( + "check_bank_empty-2"), /* KYC: we don't even know the legitimization UUID yet */ - TALER_TESTING_cmd_merchant_kyc_get ("kyc-pending-early", - merchant_url, - NULL, - NULL, - EXCHANGE_URL, - MHD_HTTP_NO_CONTENT, - TALER_AML_NORMAL), + TALER_TESTING_cmd_merchant_kyc_get ( + "kyc-pending-early", + merchant_url, + NULL, + NULL, + EXCHANGE_URL, + MHD_HTTP_NO_CONTENT, + TALER_AML_NORMAL), /* now we get the legi UUID by running taler-merchant-depositcheck */ - TALER_TESTING_cmd_depositcheck ("deposit-check", - CONFIG_FILE), + TALER_TESTING_cmd_depositcheck ( + "deposit-check", + CONFIG_FILE), /* Now we should get a status of pending */ - TALER_TESTING_cmd_merchant_kyc_get ("kyc-pending", - merchant_url, - NULL, - NULL, - EXCHANGE_URL, - MHD_HTTP_ACCEPTED, - TALER_AML_NORMAL), - TALER_TESTING_cmd_proof_kyc_oauth2 ("kyc-do", - "kyc-pending", - "kyc-provider-test-oauth2", - "pass", - MHD_HTTP_SEE_OTHER), + TALER_TESTING_cmd_merchant_kyc_get ( + "kyc-pending", + merchant_url, + NULL, + NULL, + EXCHANGE_URL, + MHD_HTTP_ACCEPTED, + TALER_AML_NORMAL), + TALER_TESTING_cmd_proof_kyc_oauth2 ( + "kyc-do", + "kyc-pending", + "kyc-provider-test-oauth2", + "pass", + MHD_HTTP_SEE_OTHER), CMD_EXEC_AGGREGATOR ("run-aggregator"), - TALER_TESTING_cmd_check_bank_transfer ("check_bank_transfer-498c", - EXCHANGE_URL, - "EUR:4.98", - exchange_payto, - merchant_payto), - TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1", - &cred.ba, - merchant_payto, - merchant_url, - "EUR:4.98", - MHD_HTTP_NO_CONTENT, - "deposit-simple", - NULL), - TALER_TESTING_cmd_run_tme ("run taler-merchant-exchange-1", - CONFIG_FILE), - TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1", - merchant_url, - merchant_payto, - MHD_HTTP_OK, - "post-transfer-1", - NULL), - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-3"), + TALER_TESTING_cmd_check_bank_transfer ( + "check_bank_transfer-498c", + EXCHANGE_URL, + "EUR:4.98", + exchange_payto, + merchant_payto), + TALER_TESTING_cmd_merchant_post_transfer ( + "post-transfer-1", + &cred.ba, + merchant_payto, + merchant_url, + "EUR:4.98", + MHD_HTTP_NO_CONTENT, + "deposit-simple", + NULL), + TALER_TESTING_cmd_run_tme ( + "run taler-merchant-exchange-1", + CONFIG_FILE), + TALER_TESTING_cmd_merchant_get_transfers ( + "get-transfers-1", + merchant_url, + merchant_payto, + MHD_HTTP_OK, + "post-transfer-1", + NULL), + TALER_TESTING_cmd_check_bank_empty ( + "check_bank_empty-3"), TALER_TESTING_cmd_end () }; struct TALER_TESTING_Command aml[] = { - TALER_TESTING_cmd_set_officer ("aml-officer", - NULL, - "Ernest&Young", - true, - false), - cmd_transfer_to_exchange ("create-reserve-big", - "EUR:100.02"), - TALER_TESTING_cmd_exec_wirewatch ("wirewatch-big", - CONFIG_FILE), - TALER_TESTING_cmd_take_aml_decision ("freeze", - "aml-officer", - "post-transfer-1", - "EUR:1", - "suspicious", - TALER_AML_FROZEN, - NULL, - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_check_bank_admin_transfer ("check_bank_transfer-big", - "EUR:100.02", - payer_payto, - exchange_payto, - "create-reserve-big"), - TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-aml", - "create-reserve-big", - "EUR:5", - 0, - MHD_HTTP_OK), - TALER_TESTING_cmd_merchant_post_orders2 ("create-proposal-aml", - cred.cfg, - merchant_url, - MHD_HTTP_OK, - "10-aml", /* order ID */ - GNUNET_TIME_UNIT_ZERO_TS, - GNUNET_TIME_UNIT_FOREVER_TS, - true, - "EUR:5.0", - "x-taler-bank", - "", - "", - NULL), - TALER_TESTING_cmd_merchant_claim_order ("reclaim-aml", - merchant_url, - MHD_HTTP_OK, - "create-proposal-aml", - NULL), - TALER_TESTING_cmd_merchant_pay_order ("deposit-simple", - merchant_url, - MHD_HTTP_OK, - "create-proposal-aml", - "withdraw-coin-aml", - "EUR:5", - "EUR:4.99", - "session-aml"), - TALER_TESTING_cmd_merchant_post_orders_paid ("verify-order-aml-paid", - merchant_url, - "deposit-simple", - "session-aml", - MHD_HTTP_OK), - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-aml-1"), + TALER_TESTING_cmd_set_officer ( + "aml-officer", + NULL, + "Ernest&Young", + true, + false), + cmd_transfer_to_exchange ( + "create-reserve-big", + "EUR:100.02"), + TALER_TESTING_cmd_exec_wirewatch ( + "wirewatch-big", + CONFIG_FILE), + TALER_TESTING_cmd_take_aml_decision ( + "freeze", + "aml-officer", + "post-transfer-1", + "EUR:1", + "suspicious", + TALER_AML_FROZEN, + NULL, + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_check_bank_admin_transfer ( + "check_bank_transfer-big", + "EUR:100.02", + payer_payto, + exchange_payto, + "create-reserve-big"), + TALER_TESTING_cmd_withdraw_amount ( + "withdraw-coin-aml", + "create-reserve-big", + "EUR:5", + 0, + MHD_HTTP_OK), + TALER_TESTING_cmd_merchant_post_orders2 ( + "create-proposal-aml", + cred.cfg, + merchant_url, + MHD_HTTP_OK, + "10-aml", /* order ID */ + GNUNET_TIME_UNIT_ZERO_TS, + GNUNET_TIME_UNIT_FOREVER_TS, + true, + "EUR:5.0", + "x-taler-bank", + "", + "", + NULL), + TALER_TESTING_cmd_merchant_claim_order ( + "reclaim-aml", + merchant_url, + MHD_HTTP_OK, + "create-proposal-aml", + NULL), + TALER_TESTING_cmd_merchant_pay_order ( + "deposit-simple", + merchant_url, + MHD_HTTP_OK, + "create-proposal-aml", + "withdraw-coin-aml", + "EUR:5", + "EUR:4.99", + "session-aml"), + TALER_TESTING_cmd_merchant_post_orders_paid ( + "verify-order-aml-paid", + merchant_url, + "deposit-simple", + "session-aml", + MHD_HTTP_OK), + TALER_TESTING_cmd_check_bank_empty ( + "check_bank_empty-aml-1"), CMD_EXEC_AGGREGATOR ("run-aggregator-aml-frozen"), /* AML-frozen: hence nothing happened at the bank yet: */ - TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-aml-2"), + TALER_TESTING_cmd_check_bank_empty ( + "check_bank_empty-aml-2"), /* Now we should get a status of frozen */ - TALER_TESTING_cmd_merchant_kyc_get ("aml-frozen", - merchant_url, - NULL, /* no instance ID */ - NULL, /* no wire ref */ - EXCHANGE_URL, - MHD_HTTP_ACCEPTED, - TALER_AML_FROZEN), - TALER_TESTING_cmd_sleep ("sleep to de-collide AML timestamps", - 1), - TALER_TESTING_cmd_take_aml_decision ("unfreeze", - "aml-officer", - "post-transfer-1", - "EUR:100", - "fine", - TALER_AML_NORMAL, - NULL, - MHD_HTTP_NO_CONTENT), - TALER_TESTING_cmd_merchant_kyc_get ("aml-unfrozen", - merchant_url, - NULL, /* no instance ID */ - NULL, /* no wire ref */ - EXCHANGE_URL, - MHD_HTTP_NO_CONTENT, - TALER_AML_NORMAL), + TALER_TESTING_cmd_merchant_kyc_get ( + "aml-frozen", + merchant_url, + NULL, /* no instance ID */ + NULL, /* no wire ref */ + EXCHANGE_URL, + MHD_HTTP_ACCEPTED, + TALER_AML_FROZEN), + TALER_TESTING_cmd_sleep ( + "sleep to de-collide AML timestamps", + 1), + TALER_TESTING_cmd_take_aml_decision ( + "unfreeze", + "aml-officer", + "post-transfer-1", + "EUR:100", + "fine", + TALER_AML_NORMAL, + NULL, + MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_merchant_kyc_get ( + "aml-unfrozen", + merchant_url, + NULL, /* no instance ID */ + NULL, /* no wire ref */ + EXCHANGE_URL, + MHD_HTTP_NO_CONTENT, + TALER_AML_NORMAL), CMD_EXEC_AGGREGATOR ("run-aggregator-aml-normal"), TALER_TESTING_cmd_check_bank_transfer ( "check_bank_transfer-498c-post-unfreeze", @@ -350,47 +389,55 @@ run (void *cls, "EUR:4.98", exchange_payto, merchant_payto), - TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-aml", - &cred.ba, - merchant_payto, - merchant_url, - "EUR:4.98", - MHD_HTTP_NO_CONTENT, - "deposit-simple", - NULL), - TALER_TESTING_cmd_run_tme ("run taler-merchant-exchange-2-aml", - CONFIG_FILE), - TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-aml", - merchant_url, - merchant_payto, - MHD_HTTP_OK, - "post-transfer-1", - "post-transfer-aml", - NULL), + TALER_TESTING_cmd_merchant_post_transfer ( + "post-transfer-aml", + &cred.ba, + merchant_payto, + merchant_url, + "EUR:4.98", + MHD_HTTP_NO_CONTENT, + "deposit-simple", + NULL), + TALER_TESTING_cmd_run_tme ( + "run taler-merchant-exchange-2-aml", + CONFIG_FILE), + TALER_TESTING_cmd_merchant_get_transfers ( + "get-transfers-aml", + merchant_url, + merchant_payto, + MHD_HTTP_OK, + "post-transfer-1", + "post-transfer-aml", + NULL), TALER_TESTING_cmd_end () }; /* end of aml batch */ struct TALER_TESTING_Command commands[] = { /* general setup */ - TALER_TESTING_cmd_run_fakebank ("run-fakebank", - cred.cfg, - "exchange-account-exchange"), - TALER_TESTING_cmd_system_start ("start-taler", - CONFIG_FILE, - "-ema", - "-u", "exchange-account-exchange", - NULL), - TALER_TESTING_cmd_get_exchange ("get-exchange", - cred.cfg, - NULL, - true, - true), - TALER_TESTING_cmd_oauth ("start-oauth-service", - 6666), - TALER_TESTING_cmd_merchant_post_instances ("instance-create-default-setup", - merchant_url, - "default", - MHD_HTTP_NO_CONTENT), + TALER_TESTING_cmd_run_fakebank ( + "run-fakebank", + cred.cfg, + "exchange-account-exchange"), + TALER_TESTING_cmd_system_start ( + "start-taler", + CONFIG_FILE, + "-ema", + "-u", "exchange-account-exchange", + NULL), + TALER_TESTING_cmd_get_exchange ( + "get-exchange", + cred.cfg, + NULL, + true, + true), + TALER_TESTING_cmd_oauth ( + "start-oauth-service", + 6666), + TALER_TESTING_cmd_merchant_post_instances ( + "instance-create-default-setup", + merchant_url, + "default", + MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account", merchant_url, @@ -437,4 +484,4 @@ main (int argc, } -/* end of test_merchant_api.c */ +/* end of test_kyc_api.c */ diff --git a/src/testing/testing_api_cmd_post_orders.c b/src/testing/testing_api_cmd_post_orders.c index 5688d174..d5cfdddc 100644 --- a/src/testing/testing_api_cmd_post_orders.c +++ b/src/testing/testing_api_cmd_post_orders.c @@ -536,19 +536,20 @@ orders_run2 (void *cls, locks_length, uuid); } - ps->po = TALER_MERCHANT_orders_post2 (TALER_TESTING_interpreter_get_context ( - is), - ps->merchant_url, - order, - GNUNET_TIME_UNIT_ZERO, - ps->payment_target, - products_length, - products, - locks_length, - locks, - ps->make_claim_token, - &order_cb, - ps); + ps->po = TALER_MERCHANT_orders_post2 ( + TALER_TESTING_interpreter_get_context ( + is), + ps->merchant_url, + order, + GNUNET_TIME_UNIT_ZERO, + ps->payment_target, + products_length, + products, + locks_length, + locks, + ps->make_claim_token, + &order_cb, + ps); GNUNET_free (products_string); GNUNET_free (locks_string); GNUNET_array_grow (products, |