aboutsummaryrefslogtreecommitdiff
path: root/test_brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-08-16 20:58:20 +0200
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-08-16 20:58:20 +0200
commitfe7b13889217f4268d87d3712cb9ffe265e6a4e2 (patch)
tree59a17a13bdd9f22281bb0a59d8056675814a0cfd /test_brandt.c
parent01c2b8d710ff5a526d1ae2ed2a7fafdec0b1f973 (diff)
downloadlibbrandt-fe7b13889217f4268d87d3712cb9ffe265e6a4e2.tar.gz
libbrandt-fe7b13889217f4268d87d3712cb9ffe265e6a4e2.zip
some stuff
- finish BRANDT_destroy() - fix include mess related to platform.h and brandt_config.h - add first brandt.c testcase
Diffstat (limited to 'test_brandt.c')
-rw-r--r--test_brandt.c124
1 files changed, 124 insertions, 0 deletions
diff --git a/test_brandt.c b/test_brandt.c
new file mode 100644
index 0000000..d61700b
--- /dev/null
+++ b/test_brandt.c
@@ -0,0 +1,124 @@
1/* This file is part of libbrandt.
2 * Copyright (C) 2016 GNUnet e.V.
3 *
4 * libbrandt is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation, either version 3 of the License, or (at your option) any later
7 * version.
8 *
9 * libbrandt 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 * libbrandt. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/**
18 * @file test_brandt.c
19 * @brief testing API functions.
20 * @author Markus Teich
21 */
22
23#include "platform.h"
24
25#include <gnunet/gnunet_util_lib.h>
26
27#include "brandt.h"
28#include "crypto.h"
29#include "test.h"
30#include "util.h"
31
32
33static void
34run_new_join (void *arg)
35{
36 int *ret = arg;
37 const char description[] = "test description for test_new_join";
38 struct BRANDT_Auction *ad_seller;
39 struct BRANDT_Auction *ad_bidder;
40 void *desc;
41 size_t desc_len;
42
43 ad_seller = BRANDT_new (NULL,
44 NULL,
45 NULL,
46 &desc,
47 &desc_len,
48 description,
49 sizeof (description),
50 GNUNET_TIME_absolute_get (),
51 GNUNET_TIME_UNIT_MINUTES,
52 8,
53 0,
54 1);
55 if (!ad_seller)
56 {
57 weprintf ("BRANDT_new() failed.");
58 *ret = 0;
59 return;
60 }
61
62
63 ad_bidder = BRANDT_join (NULL,
64 NULL,
65 NULL,
66 NULL,
67 desc,
68 desc_len,
69 description,
70 sizeof (description));
71 if (!ad_bidder)
72 {
73 weprintf ("BRANDT_join() failed.");
74 *ret = 0;
75 return;
76 }
77
78 BRANDT_destroy (ad_seller);
79 BRANDT_destroy (ad_bidder);
80
81 *ret = 1;
82}
83
84
85static int
86test_new_join ()
87{
88 int ret = 0;
89
90 GNUNET_SCHEDULER_run (&run_new_join, &ret);
91 return ret;
92}
93
94
95/*
96 static void
97 cleanup_auction_data ()
98 {
99 for (uint16_t i = 0; i < bidders; i++)
100 {
101 }
102 free (ad);
103 }
104 */
105
106
107int
108main (int argc, char *argv[])
109{
110 int repeat = 1;
111 struct GNUNET_CRYPTO_EccDlogContext *edc;
112
113 edc = GNUNET_CRYPTO_ecc_dlog_prepare (1024, 16);
114 BRANDT_init (edc);
115
116 RUN (test_new_join);
117
118 for (tests_run = 0; tests_run < repeat; tests_run++)
119 {
120 }
121
122 GNUNET_CRYPTO_ecc_dlog_release (edc);
123 return ret;
124}