gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: HELLO: Add test for NG API; fix extracti


From: gnunet
Subject: [gnunet] branch master updated: HELLO: Add test for NG API; fix extraction more
Date: Sun, 21 Feb 2021 20:58:06 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 05040a491 HELLO: Add test for NG API; fix extraction more
05040a491 is described below

commit 05040a491361a25bfed43a0b978b092da008129f
Author: Martin Schanzenbach <mschanzenbach@posteo.de>
AuthorDate: Sun Feb 21 20:56:47 2021 +0100

    HELLO: Add test for NG API; fix extraction more
---
 src/hello/Makefile.am     | 10 +++++++++-
 src/hello/hello-ng.c      |  2 +-
 src/hello/test_hello-ng.c | 37 +++++++++++++++++++++++++++++++++++++
 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;
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]