summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 = \
check_PROGRAMS = \
test_hello \
- test_friend_hello
+ test_friend_hello \
+ test_hello-ng
if ENABLE_TEST_RUN
AM_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 = \
libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_hello_ng_SOURCES = \
+ test_hello-ng.c
+test_hello_ng_LDADD = \
+ libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+
test_friend_hello_SOURCES = \
test_friend_hello.c
test_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,
struct SignedAddress sa;
struct GNUNET_CRYPTO_EddsaSignature *sig;
- if ('\0' != raws[raw_size])
+ if ('\0' != raws[raw_size-1])
{
GNUNET_break_op (0);
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 @@
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_nt_lib.h"
+#include "gnunet_hello_lib.h"
+
+int
+main (int argc,
+ char *argv[])
+{
+ struct GNUNET_CRYPTO_EddsaPublicKey pubKey;
+ struct GNUNET_CRYPTO_EddsaPrivateKey privKey;
+ struct GNUNET_PeerIdentity pid;
+ struct GNUNET_TIME_Absolute t = GNUNET_TIME_absolute_get ();
+ char *res;
+ size_t res_len;
+ enum GNUNET_NetworkType nt;
+
+ GNUNET_CRYPTO_eddsa_key_create (&privKey);
+ GNUNET_CRYPTO_eddsa_key_get_public (&privKey,
+ &pubKey);
+ pid.public_key = pubKey;
+ GNUNET_HELLO_sign_address ("127.0.0.1:8080",
+ GNUNET_NT_LAN,
+ t,
+ &privKey,
+ (void**)&res,
+ &res_len);
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+ "%s", res);
+ GNUNET_assert (NULL !=
+ GNUNET_HELLO_extract_address ((void**)res,
+ res_len,
+ &pid,
+ &nt,
+ &t));
+ return 0;
+}