From 1701d4f86a39edc390f172da6f8e72c94b6a8e97 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 7 Jun 2023 23:11:35 +0200 Subject: major libtalertesting API refactoring, including no longer having taler-specific logic in the test engine core --- src/testing/test_anastasis.c | 129 ++++++++++++------------------------------- 1 file changed, 34 insertions(+), 95 deletions(-) (limited to 'src/testing/test_anastasis.c') diff --git a/src/testing/test_anastasis.c b/src/testing/test_anastasis.c index 7b127ac..bf3662d 100644 --- a/src/testing/test_anastasis.c +++ b/src/testing/test_anastasis.c @@ -1,6 +1,6 @@ /* This file is part of Anastasis - Copyright (C) 2020, 2021 Anastasis SARL + Copyright (C) 2020-2023 Anastasis SARL Anastasis is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -52,34 +52,29 @@ #define MERCHANT_ACCOUNT_NAME "3" /** - * Configuration of the bank. + * Credentials for the test. */ -static struct TALER_TESTING_BankConfiguration bc; - -/** - * Configuration of the exchange. - */ -static struct TALER_TESTING_ExchangeConfiguration ec; +static struct TALER_TESTING_Credentials cred; /** * Payto URI of the customer (payer). */ -static char *payer_payto; +static const char *payer_payto; /** * Payto URI of the exchange (escrow account). */ -static char *exchange_payto; +static const char *exchange_payto; /** * Payto URI of the merchant (receiver). */ -static char *merchant_payto; +static const char *merchant_payto; /** * Merchant base URL. */ -static char *merchant_url; +static const char *merchant_url; /** * Anastasis base URL. @@ -91,11 +86,6 @@ static char *anastasis_url; */ static char *file_secret; -/** - * Merchant process. - */ -static struct GNUNET_OS_Process *merchantd; - /** * Anastasis process. */ @@ -135,7 +125,7 @@ cmd_transfer_to_exchange (const char *label, { return TALER_TESTING_cmd_admin_add_incoming (label, amount, - &bc.exchange_auth, + &cred.ba, payer_payto); } @@ -341,8 +331,7 @@ run (void *cls, CONFIG_FILE, "EUR:0.01", "EUR:0.01"), - TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", - 1), + TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"), TALER_TESTING_cmd_merchant_post_instances ("instance-create-default", merchant_url, "default", @@ -356,9 +345,8 @@ run (void *cls, TALER_TESTING_cmd_end () }; - TALER_TESTING_run_with_fakebank (is, - commands, - bc.exchange_auth.wire_gateway_url); + TALER_TESTING_run (is, + commands); } @@ -366,19 +354,7 @@ int main (int argc, char *const *argv) { - unsigned int ret; - /* These environment variables get in the way... */ - unsetenv ("XDG_DATA_HOME"); - unsetenv ("XDG_CONFIG_HOME"); - - GNUNET_log_setup ("test-anastasis", - "DEBUG", - NULL); - if (GNUNET_OK != - TALER_TESTING_prepare_fakebank (CONFIG_FILE, - "exchange-account-exchange", - &bc)) - return 77; + int ret; { char dir[] = "/tmp/test-anastasis-file-XXXXXX"; @@ -393,73 +369,36 @@ main (int argc, "%s/.secret", dir); } - id_data = ANASTASIS_TESTING_make_id_data_example ( - "MaxMuster123456789"); - payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME); - exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME); - merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME); - if (NULL == - (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE))) - return 77; - TALER_TESTING_cleanup_files (CONFIG_FILE); + id_data = ANASTASIS_TESTING_make_id_data_example ("MaxMuster123456789"); + payer_payto = "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME; + exchange_payto = "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME; + merchant_payto = "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME; + merchant_url = "http://localhost:8080/"; if (NULL == (anastasis_url = ANASTASIS_TESTING_prepare_anastasis (CONFIG_FILE))) return 77; - TALER_TESTING_cleanup_files (CONFIG_FILE); - - switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, - GNUNET_YES, - &ec)) + if (NULL == (anastasisd = + ANASTASIS_TESTING_run_anastasis (CONFIG_FILE, + anastasis_url))) { - case GNUNET_SYSERR: - GNUNET_break (0); - return 1; - case GNUNET_NO: - return 77; - case GNUNET_OK: - if (NULL == (merchantd = - TALER_TESTING_run_merchant (CONFIG_FILE, - merchant_url))) - { - GNUNET_break (0); - return 1; - } - if (NULL == (anastasisd = - ANASTASIS_TESTING_run_anastasis (CONFIG_FILE, - anastasis_url))) - { - GNUNET_break (0); - GNUNET_OS_process_kill (merchantd, - SIGTERM); - GNUNET_OS_process_wait (merchantd); - GNUNET_OS_process_destroy (merchantd); - - return 1; - } - ret = TALER_TESTING_setup_with_exchange (&run, - NULL, - CONFIG_FILE); - - GNUNET_OS_process_kill (merchantd, - SIGTERM); - GNUNET_OS_process_kill (anastasisd, - SIGTERM); - GNUNET_OS_process_wait (merchantd); - GNUNET_OS_process_wait (anastasisd); - GNUNET_OS_process_destroy (merchantd); - GNUNET_OS_process_destroy (anastasisd); - GNUNET_free (merchant_url); - GNUNET_free (anastasis_url); - - if (GNUNET_OK != ret) - return 1; - break; - default: GNUNET_break (0); return 1; } - return 0; + ret = TALER_TESTING_main (argv, + "INFO", + CONFIG_FILE, + "exchange-account-2", + TALER_TESTING_BS_FAKEBANK, + &cred, + &run, + NULL); + GNUNET_OS_process_kill (anastasisd, + SIGTERM); + GNUNET_OS_process_wait (anastasisd); + GNUNET_OS_process_destroy (anastasisd); + GNUNET_free (anastasis_url); + return ret; } -- cgit v1.2.3