aboutsummaryrefslogtreecommitdiff
path: root/src/merchant/test_merchant.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/merchant/test_merchant.c')
-rw-r--r--src/merchant/test_merchant.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/merchant/test_merchant.c b/src/merchant/test_merchant.c
new file mode 100644
index 00000000..bcec09ae
--- /dev/null
+++ b/src/merchant/test_merchant.c
@@ -0,0 +1,96 @@
1/*
2 This file is part of TALER
3 (C) 2014 Christian Grothoff (and other contributing authors)
4
5 TALER 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
7 Foundation; either version 3, or (at your option) any later version.
8
9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/
16
17/**
18 * @file merchant/test_merchant.c
19 * @brief File to test merchant-internal helper functions.
20 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
21 */
22
23#include "platform.h"
24#include <gnunet/gnunet_util_lib.h>
25#include "merchant.h"
26
27/**
28 * Array of parsed mints
29 */
30struct MERCHANT_MintInfo *mints;
31
32/**
33 * Number of mints in the above array
34 */
35int n_mints;
36
37/**
38 * Test result
39 */
40static int result;
41
42static void
43do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
44{
45 unsigned int cnt;
46
47 for (cnt=0; cnt < n_mints; cnt++)
48 GNUNET_free (mints[cnt].hostname);
49 GNUNET_free_non_null (mints);
50 mints = 0;
51}
52
53
54/**
55 * Main function that will be run by the scheduler.
56 *
57 * @param cls closure
58 * @param args remaining command-line arguments
59 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
60 * @param config configuration
61 */
62static void
63run (void *cls, char *const *args, const char *cfgfile,
64 const struct GNUNET_CONFIGURATION_Handle *config)
65{
66
67 mints = NULL;
68 n_mints = GNUNET_SYSERR;
69 n_mints = TALER_MERCHANT_parse_mints (config, &mints);
70 GNUNET_assert (GNUNET_SYSERR != n_mints);
71 GNUNET_assert (NULL != mints);
72 result = GNUNET_OK;
73 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
74}
75
76int
77main (int argc, char *const argv[])
78{
79 char *argv2[] = {
80 "test-merchant",
81 "-c", "test_merchant.conf",
82 NULL
83 };
84 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
85 GNUNET_GETOPT_OPTION_END
86 };
87
88 result = GNUNET_SYSERR;
89 if (GNUNET_OK !=
90 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1,
91 argv2, "test-merchant",
92 "File to test merchant-internal helper functions.",
93 options, &run, NULL))
94 return 3;
95 return (GNUNET_OK == result) ? 0 : 1;
96}