aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 20:56:47 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 20:56:47 +0100
commit05040a491361a25bfed43a0b978b092da008129f (patch)
tree5c1936f8bb3426902d6b27615a178c68bc04cb2e /src
parent9e1f3ef55b86baa796b8bc650dbecdb8d17be9cf (diff)
downloadgnunet-05040a491361a25bfed43a0b978b092da008129f.tar.gz
gnunet-05040a491361a25bfed43a0b978b092da008129f.zip
HELLO: Add test for NG API; fix extraction more
Diffstat (limited to 'src')
-rw-r--r--src/hello/Makefile.am10
-rw-r--r--src/hello/hello-ng.c2
-rw-r--r--src/hello/test_hello-ng.c37
3 files changed, 47 insertions, 2 deletions
diff --git a/src/hello/Makefile.am b/src/hello/Makefile.am
index 40a45320f..6a250e42f 100644
--- a/src/hello/Makefile.am
+++ b/src/hello/Makefile.am
@@ -24,7 +24,8 @@ noinst_PROGRAMS = \
24 24
25check_PROGRAMS = \ 25check_PROGRAMS = \
26 test_hello \ 26 test_hello \
27 test_friend_hello 27 test_friend_hello \
28 test_hello-ng
28 29
29if ENABLE_TEST_RUN 30if ENABLE_TEST_RUN
30AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; 31AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
@@ -37,6 +38,13 @@ test_hello_LDADD = \
37 libgnunethello.la \ 38 libgnunethello.la \
38 $(top_builddir)/src/util/libgnunetutil.la 39 $(top_builddir)/src/util/libgnunetutil.la
39 40
41test_hello_ng_SOURCES = \
42 test_hello-ng.c
43test_hello_ng_LDADD = \
44 libgnunethello.la \
45 $(top_builddir)/src/util/libgnunetutil.la
46
47
40test_friend_hello_SOURCES = \ 48test_friend_hello_SOURCES = \
41 test_friend_hello.c 49 test_friend_hello.c
42test_friend_hello_LDADD = \ 50test_friend_hello_LDADD = \
diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c
index 27fd50763..85b304e18 100644
--- a/src/hello/hello-ng.c
+++ b/src/hello/hello-ng.c
@@ -123,7 +123,7 @@ GNUNET_HELLO_extract_address (const void *raw,
123 struct SignedAddress sa; 123 struct SignedAddress sa;
124 struct GNUNET_CRYPTO_EddsaSignature *sig; 124 struct GNUNET_CRYPTO_EddsaSignature *sig;
125 125
126 if ('\0' != raws[raw_size]) 126 if ('\0' != raws[raw_size-1])
127 { 127 {
128 GNUNET_break_op (0); 128 GNUNET_break_op (0);
129 return NULL; 129 return NULL;
diff --git a/src/hello/test_hello-ng.c b/src/hello/test_hello-ng.c
new file mode 100644
index 000000000..82b1ab6c6
--- /dev/null
+++ b/src/hello/test_hello-ng.c
@@ -0,0 +1,37 @@
1#include "platform.h"
2#include "gnunet_util_lib.h"
3#include "gnunet_nt_lib.h"
4#include "gnunet_hello_lib.h"
5
6int
7main (int argc,
8 char *argv[])
9{
10 struct GNUNET_CRYPTO_EddsaPublicKey pubKey;
11 struct GNUNET_CRYPTO_EddsaPrivateKey privKey;
12 struct GNUNET_PeerIdentity pid;
13 struct GNUNET_TIME_Absolute t = GNUNET_TIME_absolute_get ();
14 char *res;
15 size_t res_len;
16 enum GNUNET_NetworkType nt;
17
18 GNUNET_CRYPTO_eddsa_key_create (&privKey);
19 GNUNET_CRYPTO_eddsa_key_get_public (&privKey,
20 &pubKey);
21 pid.public_key = pubKey;
22 GNUNET_HELLO_sign_address ("127.0.0.1:8080",
23 GNUNET_NT_LAN,
24 t,
25 &privKey,
26 (void**)&res,
27 &res_len);
28 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
29 "%s", res);
30 GNUNET_assert (NULL !=
31 GNUNET_HELLO_extract_address ((void**)res,
32 res_len,
33 &pid,
34 &nt,
35 &t));
36 return 0;
37}