aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-08-06 16:12:32 +0200
committerjospaeth <spaethj@in.tum.de>2020-08-06 16:12:32 +0200
commit90e87e4a0fc1a4673341e948a5eedd0d9a1d60ea (patch)
treeb356c688618a5893f996dc0abe77246ca37d490c /src
parent7359d93752bfe39d1154ea0e67f556dab0020cff (diff)
downloadgnunet-90e87e4a0fc1a4673341e948a5eedd0d9a1d60ea.tar.gz
gnunet-90e87e4a0fc1a4673341e948a5eedd0d9a1d60ea.zip
add tests for plaintext and gns escrow
Diffstat (limited to 'src')
-rw-r--r--src/escrow/Makefile.am4
-rw-r--r--src/escrow/escrow_plugin_helper.c1
-rw-r--r--src/escrow/gnunet-escrow.c6
-rw-r--r--src/escrow/plugin_escrow_anastasis.c1
-rw-r--r--src/escrow/plugin_escrow_gns.c1
-rw-r--r--src/escrow/plugin_escrow_plaintext.c1
-rwxr-xr-xsrc/escrow/test_gns_escrow.sh47
-rwxr-xr-xsrc/escrow/test_plaintext_escrow.sh (renamed from src/escrow/test_escrow.sh)24
8 files changed, 83 insertions, 2 deletions
diff --git a/src/escrow/Makefile.am b/src/escrow/Makefile.am
index 2f3ada944..fa4fcdfe1 100644
--- a/src/escrow/Makefile.am
+++ b/src/escrow/Makefile.am
@@ -89,7 +89,9 @@ gnunet_escrow_LDADD = \
89 $(GN_LIBINTL) 89 $(GN_LIBINTL)
90 90
91check_SCRIPTS = \ 91check_SCRIPTS = \
92 test_escrow.sh 92 test_plaintext_escrow.sh \
93 test_gns_escrow.sh
94 # test_anastasis_escrow.sh
93 95
94if ENABLE_TEST_RUN 96if ENABLE_TEST_RUN
95 AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; 97 AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/escrow/escrow_plugin_helper.c b/src/escrow/escrow_plugin_helper.c
index 07cb5e139..7a69d4a0d 100644
--- a/src/escrow/escrow_plugin_helper.c
+++ b/src/escrow/escrow_plugin_helper.c
@@ -75,6 +75,7 @@ ESCROW_list_ego (void *cls,
75 struct EgoEntry *ego_entry; 75 struct EgoEntry *ego_entry;
76 struct GNUNET_CRYPTO_EcdsaPublicKey pk; 76 struct GNUNET_CRYPTO_EcdsaPublicKey pk;
77 77
78 // TODO: error when this method is called at cleanup if init is not yet finished
78 if ((NULL == ego) && (ESCROW_PLUGIN_STATE_INIT == ph->state)) 79 if ((NULL == ego) && (ESCROW_PLUGIN_STATE_INIT == ph->state))
79 { 80 {
80 ph->state = ESCROW_PLUGIN_STATE_POST_INIT; 81 ph->state = ESCROW_PLUGIN_STATE_POST_INIT;
diff --git a/src/escrow/gnunet-escrow.c b/src/escrow/gnunet-escrow.c
index 32510587b..91ad4fbbe 100644
--- a/src/escrow/gnunet-escrow.c
+++ b/src/escrow/gnunet-escrow.c
@@ -217,9 +217,11 @@ verify_cb (void *cls,
217 fprintf (stdout, "Escrow is valid!\n"); 217 fprintf (stdout, "Escrow is valid!\n");
218 break; 218 break;
219 case GNUNET_ESCROW_INVALID: 219 case GNUNET_ESCROW_INVALID:
220 ret = 2;
220 fprintf (stdout, "Escrow is INvalid! Please perform a new escrow.\n"); 221 fprintf (stdout, "Escrow is INvalid! Please perform a new escrow.\n");
221 break; 222 break;
222 default: 223 default:
224 ret = 1;
223 fprintf (stderr, "invalid verificationResult!\n"); 225 fprintf (stderr, "invalid verificationResult!\n");
224 } 226 }
225 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 227 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
@@ -251,6 +253,7 @@ start_process ()
251 { 253 {
252 if (NULL == ego) 254 if (NULL == ego)
253 { 255 {
256 ret = 1;
254 fprintf (stderr, "Ego %s not found\n", put_ego); 257 fprintf (stderr, "Ego %s not found\n", put_ego);
255 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 258 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
256 return; 259 return;
@@ -267,6 +270,7 @@ start_process ()
267 { 270 {
268 if (NULL == ego) 271 if (NULL == ego)
269 { 272 {
273 ret = 1;
270 fprintf (stderr, "Ego %s not found\n", verify_ego); 274 fprintf (stderr, "Ego %s not found\n", verify_ego);
271 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 275 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
272 return; 276 return;
@@ -284,6 +288,7 @@ start_process ()
284 { 288 {
285 if (NULL != ego) 289 if (NULL != ego)
286 { 290 {
291 ret = 1;
287 fprintf (stderr, "The name %s is already in use for an ego\n", get_ego); 292 fprintf (stderr, "The name %s is already in use for an ego\n", get_ego);
288 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 293 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
289 return; 294 return;
@@ -301,6 +306,7 @@ start_process ()
301 { 306 {
302 if (NULL == ego) 307 if (NULL == ego)
303 { 308 {
309 ret = 1;
304 fprintf (stderr, "Ego %s not found\n", status_ego); 310 fprintf (stderr, "Ego %s not found\n", status_ego);
305 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 311 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
306 return; 312 return;
diff --git a/src/escrow/plugin_escrow_anastasis.c b/src/escrow/plugin_escrow_anastasis.c
index 3d3abdf29..64c0c66a3 100644
--- a/src/escrow/plugin_escrow_anastasis.c
+++ b/src/escrow/plugin_escrow_anastasis.c
@@ -245,6 +245,7 @@ libgnunet_plugin_escrow_anastasis_init (void *cls)
245 api->anchor_string_to_data = &anastasis_anchor_string_to_data; 245 api->anchor_string_to_data = &anastasis_anchor_string_to_data;
246 api->cancel_plugin_operation = &cancel_anastasis_operation; 246 api->cancel_plugin_operation = &cancel_anastasis_operation;
247 247
248 ph.state = ESCROW_PLUGIN_STATE_INIT;
248 ph.id_init_cont = &anastasis_cont_init; 249 ph.id_init_cont = &anastasis_cont_init;
249 250
250 identity_handle = GNUNET_IDENTITY_connect (cfg, 251 identity_handle = GNUNET_IDENTITY_connect (cfg,
diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c
index e55019ad9..b296f081a 100644
--- a/src/escrow/plugin_escrow_gns.c
+++ b/src/escrow/plugin_escrow_gns.c
@@ -344,6 +344,7 @@ libgnunet_plugin_escrow_gns_init (void *cls)
344 api->anchor_string_to_data = &gns_anchor_string_to_data; 344 api->anchor_string_to_data = &gns_anchor_string_to_data;
345 api->cancel_plugin_operation = &cancel_gns_operation; 345 api->cancel_plugin_operation = &cancel_gns_operation;
346 346
347 ph.state = ESCROW_PLUGIN_STATE_INIT;
347 ph.id_init_cont = &gns_cont_init; 348 ph.id_init_cont = &gns_cont_init;
348 349
349 identity_handle = GNUNET_IDENTITY_connect (cfg, 350 identity_handle = GNUNET_IDENTITY_connect (cfg,
diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c
index 83b2345c6..f4bd26f19 100644
--- a/src/escrow/plugin_escrow_plaintext.c
+++ b/src/escrow/plugin_escrow_plaintext.c
@@ -550,6 +550,7 @@ libgnunet_plugin_escrow_plaintext_init (void *cls)
550 api->anchor_data_to_string = &plaintext_anchor_data_to_string; 550 api->anchor_data_to_string = &plaintext_anchor_data_to_string;
551 api->cancel_plugin_operation = &cancel_plaintext_operation; 551 api->cancel_plugin_operation = &cancel_plaintext_operation;
552 552
553 ph.state = ESCROW_PLUGIN_STATE_INIT;
553 ph.id_init_cont = &plaintext_cont_init; 554 ph.id_init_cont = &plaintext_cont_init;
554 555
555 // set ego_create_cont here so it is called every time an ego is created 556 // set ego_create_cont here so it is called every time an ego is created
diff --git a/src/escrow/test_gns_escrow.sh b/src/escrow/test_gns_escrow.sh
new file mode 100755
index 000000000..00f8f3a49
--- /dev/null
+++ b/src/escrow/test_gns_escrow.sh
@@ -0,0 +1,47 @@
1#!/bin/sh
2
3LOCATION=$(which gnunet-config)
4if [ -z $LOCATION ]
5then
6 LOCATION="gnunet-config"
7fi
8$LOCATION --version 1> /dev/null
9if test $? != 0
10then
11 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
12 exit 77
13fi
14
15rm -rf `gnunet-config -c test_escrow.conf -s PATHS -o GNUNET_HOME -f`
16
17which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
18
19gnunet-arm -s -c test_escrow.conf
20gnunet-identity -C testego -c test_escrow.conf
21ANCHOR=$(gnunet-escrow -m gns -P testego -c test_escrow.conf)
22if test $? != 0
23then
24 echo "GNS escrow failed!"
25 gnunet-arm -e -c test_escrow.conf
26 exit 1
27else
28 ANCHOR=$(echo $ANCHOR | awk 'NF>1{print $NF}')
29fi
30gnunet-escrow -m gns -V testego -a $ANCHOR -c test_escrow.conf
31if test $? != 0
32then
33 echo "GNS verification failed!"
34 gnunet-arm -e -c test_escrow.conf
35 exit 1
36fi
37gnunet-identity -D testego -c test_escrow.conf
38gnunet-escrow -m gns -G testego -a $ANCHOR -c test_escrow.conf
39if test $? != 0
40then
41 echo "GNS restore failed!"
42 gnunet-arm -e -c test_escrow.conf
43 exit 1
44fi
45gnunet-arm -e -c test_escrow.conf
46
47exit 0
diff --git a/src/escrow/test_escrow.sh b/src/escrow/test_plaintext_escrow.sh
index 92a1f1492..8113110e2 100755
--- a/src/escrow/test_escrow.sh
+++ b/src/escrow/test_plaintext_escrow.sh
@@ -18,8 +18,30 @@ which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30"
18 18
19gnunet-arm -s -c test_escrow.conf 19gnunet-arm -s -c test_escrow.conf
20gnunet-identity -C testego -c test_escrow.conf 20gnunet-identity -C testego -c test_escrow.conf
21ANCHOR=$(gnunet-escrow -m plaintext -P testego -c test_escrow.conf | tail -1) 21ANCHOR=$(gnunet-escrow -m plaintext -P testego -c test_escrow.conf)
22if test $? != 0
23then
24 echo "Plaintext escrow failed!"
25 gnunet-arm -e -c test_escrow.conf
26 exit 1
27else
28 ANCHOR=$(echo $ANCHOR | awk 'NF>1{print $NF}')
29fi
22gnunet-escrow -m plaintext -V testego -a $ANCHOR -c test_escrow.conf 30gnunet-escrow -m plaintext -V testego -a $ANCHOR -c test_escrow.conf
31if test $? != 0
32then
33 echo "Plaintext verification failed!"
34 gnunet-arm -e -c test_escrow.conf
35 exit 1
36fi
23gnunet-identity -D testego -c test_escrow.conf 37gnunet-identity -D testego -c test_escrow.conf
24gnunet-escrow -m plaintext -G testego -a $ANCHOR -c test_escrow.conf 38gnunet-escrow -m plaintext -G testego -a $ANCHOR -c test_escrow.conf
39if test $? != 0
40then
41 echo "Plaintext restore failed!"
42 gnunet-arm -e -c test_escrow.conf
43 exit 1
44fi
25gnunet-arm -e -c test_escrow.conf 45gnunet-arm -e -c test_escrow.conf
46
47exit 0