aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_anastasis.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/test_anastasis.c')
-rw-r--r--src/testing/test_anastasis.c129
1 files changed, 34 insertions, 95 deletions
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 @@
1/* 1/*
2 This file is part of Anastasis 2 This file is part of Anastasis
3 Copyright (C) 2020, 2021 Anastasis SARL 3 Copyright (C) 2020-2023 Anastasis SARL
4 4
5 Anastasis is free software; you can redistribute it and/or modify it under the 5 Anastasis is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software 6 terms of the GNU General Public License as published by the Free Software
@@ -52,34 +52,29 @@
52#define MERCHANT_ACCOUNT_NAME "3" 52#define MERCHANT_ACCOUNT_NAME "3"
53 53
54/** 54/**
55 * Configuration of the bank. 55 * Credentials for the test.
56 */ 56 */
57static struct TALER_TESTING_BankConfiguration bc; 57static struct TALER_TESTING_Credentials cred;
58
59/**
60 * Configuration of the exchange.
61 */
62static struct TALER_TESTING_ExchangeConfiguration ec;
63 58
64/** 59/**
65 * Payto URI of the customer (payer). 60 * Payto URI of the customer (payer).
66 */ 61 */
67static char *payer_payto; 62static const char *payer_payto;
68 63
69/** 64/**
70 * Payto URI of the exchange (escrow account). 65 * Payto URI of the exchange (escrow account).
71 */ 66 */
72static char *exchange_payto; 67static const char *exchange_payto;
73 68
74/** 69/**
75 * Payto URI of the merchant (receiver). 70 * Payto URI of the merchant (receiver).
76 */ 71 */
77static char *merchant_payto; 72static const char *merchant_payto;
78 73
79/** 74/**
80 * Merchant base URL. 75 * Merchant base URL.
81 */ 76 */
82static char *merchant_url; 77static const char *merchant_url;
83 78
84/** 79/**
85 * Anastasis base URL. 80 * Anastasis base URL.
@@ -92,11 +87,6 @@ static char *anastasis_url;
92static char *file_secret; 87static char *file_secret;
93 88
94/** 89/**
95 * Merchant process.
96 */
97static struct GNUNET_OS_Process *merchantd;
98
99/**
100 * Anastasis process. 90 * Anastasis process.
101 */ 91 */
102static struct GNUNET_OS_Process *anastasisd; 92static struct GNUNET_OS_Process *anastasisd;
@@ -135,7 +125,7 @@ cmd_transfer_to_exchange (const char *label,
135{ 125{
136 return TALER_TESTING_cmd_admin_add_incoming (label, 126 return TALER_TESTING_cmd_admin_add_incoming (label,
137 amount, 127 amount,
138 &bc.exchange_auth, 128 &cred.ba,
139 payer_payto); 129 payer_payto);
140} 130}
141 131
@@ -341,8 +331,7 @@ run (void *cls,
341 CONFIG_FILE, 331 CONFIG_FILE,
342 "EUR:0.01", 332 "EUR:0.01",
343 "EUR:0.01"), 333 "EUR:0.01"),
344 TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", 334 TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys"),
345 1),
346 TALER_TESTING_cmd_merchant_post_instances ("instance-create-default", 335 TALER_TESTING_cmd_merchant_post_instances ("instance-create-default",
347 merchant_url, 336 merchant_url,
348 "default", 337 "default",
@@ -356,9 +345,8 @@ run (void *cls,
356 TALER_TESTING_cmd_end () 345 TALER_TESTING_cmd_end ()
357 }; 346 };
358 347
359 TALER_TESTING_run_with_fakebank (is, 348 TALER_TESTING_run (is,
360 commands, 349 commands);
361 bc.exchange_auth.wire_gateway_url);
362} 350}
363 351
364 352
@@ -366,19 +354,7 @@ int
366main (int argc, 354main (int argc,
367 char *const *argv) 355 char *const *argv)
368{ 356{
369 unsigned int ret; 357 int ret;
370 /* These environment variables get in the way... */
371 unsetenv ("XDG_DATA_HOME");
372 unsetenv ("XDG_CONFIG_HOME");
373
374 GNUNET_log_setup ("test-anastasis",
375 "DEBUG",
376 NULL);
377 if (GNUNET_OK !=
378 TALER_TESTING_prepare_fakebank (CONFIG_FILE,
379 "exchange-account-exchange",
380 &bc))
381 return 77;
382 { 358 {
383 char dir[] = "/tmp/test-anastasis-file-XXXXXX"; 359 char dir[] = "/tmp/test-anastasis-file-XXXXXX";
384 360
@@ -393,73 +369,36 @@ main (int argc,
393 "%s/.secret", 369 "%s/.secret",
394 dir); 370 dir);
395 } 371 }
396 id_data = ANASTASIS_TESTING_make_id_data_example ( 372 id_data = ANASTASIS_TESTING_make_id_data_example ("MaxMuster123456789");
397 "MaxMuster123456789"); 373 payer_payto = "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME;
398 payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME); 374 exchange_payto = "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME;
399 exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME); 375 merchant_payto = "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME;
400 merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME); 376 merchant_url = "http://localhost:8080/";
401 if (NULL ==
402 (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
403 return 77;
404 TALER_TESTING_cleanup_files (CONFIG_FILE);
405 377
406 if (NULL == 378 if (NULL ==
407 (anastasis_url = ANASTASIS_TESTING_prepare_anastasis (CONFIG_FILE))) 379 (anastasis_url = ANASTASIS_TESTING_prepare_anastasis (CONFIG_FILE)))
408 return 77; 380 return 77;
409 TALER_TESTING_cleanup_files (CONFIG_FILE); 381 if (NULL == (anastasisd =
410 382 ANASTASIS_TESTING_run_anastasis (CONFIG_FILE,
411 switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, 383 anastasis_url)))
412 GNUNET_YES,
413 &ec))
414 { 384 {
415 case GNUNET_SYSERR:
416 GNUNET_break (0);
417 return 1;
418 case GNUNET_NO:
419 return 77;
420 case GNUNET_OK:
421 if (NULL == (merchantd =
422 TALER_TESTING_run_merchant (CONFIG_FILE,
423 merchant_url)))
424 {
425 GNUNET_break (0);
426 return 1;
427 }
428 if (NULL == (anastasisd =
429 ANASTASIS_TESTING_run_anastasis (CONFIG_FILE,
430 anastasis_url)))
431 {
432 GNUNET_break (0);
433 GNUNET_OS_process_kill (merchantd,
434 SIGTERM);
435 GNUNET_OS_process_wait (merchantd);
436 GNUNET_OS_process_destroy (merchantd);
437
438 return 1;
439 }
440 ret = TALER_TESTING_setup_with_exchange (&run,
441 NULL,
442 CONFIG_FILE);
443
444 GNUNET_OS_process_kill (merchantd,
445 SIGTERM);
446 GNUNET_OS_process_kill (anastasisd,
447 SIGTERM);
448 GNUNET_OS_process_wait (merchantd);
449 GNUNET_OS_process_wait (anastasisd);
450 GNUNET_OS_process_destroy (merchantd);
451 GNUNET_OS_process_destroy (anastasisd);
452 GNUNET_free (merchant_url);
453 GNUNET_free (anastasis_url);
454
455 if (GNUNET_OK != ret)
456 return 1;
457 break;
458 default:
459 GNUNET_break (0); 385 GNUNET_break (0);
460 return 1; 386 return 1;
461 } 387 }
462 return 0; 388 ret = TALER_TESTING_main (argv,
389 "INFO",
390 CONFIG_FILE,
391 "exchange-account-2",
392 TALER_TESTING_BS_FAKEBANK,
393 &cred,
394 &run,
395 NULL);
396 GNUNET_OS_process_kill (anastasisd,
397 SIGTERM);
398 GNUNET_OS_process_wait (anastasisd);
399 GNUNET_OS_process_destroy (anastasisd);
400 GNUNET_free (anastasis_url);
401 return ret;
463} 402}
464 403
465 404