[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6974 - GNUnet/src/applications/fs/pseudonyms
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6974 - GNUnet/src/applications/fs/pseudonyms |
Date: |
Sun, 1 Jun 2008 13:30:45 -0600 (MDT) |
Author: grothoff
Date: 2008-06-01 13:30:44 -0600 (Sun, 01 Jun 2008)
New Revision: 6974
Modified:
GNUnet/src/applications/fs/pseudonyms/info_test.c
GNUnet/src/applications/fs/pseudonyms/names.c
Log:
fixing
Modified: GNUnet/src/applications/fs/pseudonyms/info_test.c
===================================================================
--- GNUnet/src/applications/fs/pseudonyms/info_test.c 2008-06-01 19:22:45 UTC
(rev 6973)
+++ GNUnet/src/applications/fs/pseudonyms/info_test.c 2008-06-01 19:30:44 UTC
(rev 6974)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2005, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2005, 2006, 2008 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -37,12 +37,18 @@
{
int ok;
struct GNUNET_ECRS_MetaData *meta = NULL;
- GNUNET_HashCode id;
+ GNUNET_HashCode id1;
+ GNUNET_HashCode rid1;
+ GNUNET_HashCode id2;
+ GNUNET_HashCode rid2;
int old;
int newVal;
struct GNUNET_GC_Configuration *cfg;
struct GNUNET_GE_Context *ectx;
+ char * name1;
+ char * name2;
+ ok = GNUNET_YES;
GNUNET_disable_entropy_gathering ();
cfg = GNUNET_GC_create ();
if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
@@ -53,11 +59,27 @@
/* ACTUAL TEST CODE */
old = GNUNET_PSEUDO_list_all (ectx, cfg, NULL, NULL);
meta = GNUNET_ECRS_meta_data_create ();
- GNUNET_ECRS_meta_data_insert (meta, 0, "test");
- GNUNET_create_random_hash (&id);
- GNUNET_PSEUDO_add (ectx, cfg, &id, meta);
+ GNUNET_ECRS_meta_data_insert (meta, EXTRACTOR_TITLE, "test");
+ GNUNET_create_random_hash (&id1);
+ GNUNET_PSEUDO_add (ectx, cfg, &id1, meta);
+ newVal = GNUNET_PSEUDO_list_all (ectx, cfg, NULL, NULL);
+ CHECK (old < newVal);
+ old = newVal;
+ name1 = GNUNET_PSEUDO_id_to_name(ectx, cfg, &id1);
+ GNUNET_create_random_hash (&id2);
+ GNUNET_PSEUDO_add (ectx, cfg, &id2, meta);
newVal = GNUNET_PSEUDO_list_all (ectx, cfg, NULL, NULL);
CHECK (old < newVal);
+ name2 = GNUNET_PSEUDO_id_to_name(ectx, cfg, &id2);
+ CHECK (name2 != NULL);
+ name1 = GNUNET_PSEUDO_id_to_name(ectx, cfg, &id1);
+ CHECK (name1 != NULL);
+ CHECK (GNUNET_OK == GNUNET_PSEUDO_name_to_id(ectx, cfg, name2, &rid2));
+ CHECK (GNUNET_OK == GNUNET_PSEUDO_name_to_id(ectx, cfg, name1, &rid1));
+ CHECK (0 == memcmp(&id1, &rid1, sizeof(GNUNET_HashCode)));
+ CHECK (0 == memcmp(&id2, &rid2, sizeof(GNUNET_HashCode)));
+ GNUNET_free(name1);
+ GNUNET_free(name2);
/* END OF TEST CODE */
FAILURE:
GNUNET_ECRS_meta_data_destroy (meta);
Modified: GNUnet/src/applications/fs/pseudonyms/names.c
===================================================================
--- GNUnet/src/applications/fs/pseudonyms/names.c 2008-06-01 19:22:45 UTC
(rev 6973)
+++ GNUnet/src/applications/fs/pseudonyms/names.c 2008-06-01 19:30:44 UTC
(rev 6974)
@@ -80,13 +80,8 @@
GNUNET_hash (name, strlen (name), &nh);
fn = GNUNET_PSEUDO_internal_get_data_filename_ (ectx,
cfg, PS_NAMES_DIR, &nh);
- if ((GNUNET_OK != GNUNET_disk_file_test (ectx,
- fn) ||
- (GNUNET_OK != GNUNET_disk_file_size (ectx, fn, &len, GNUNET_YES))))
- {
- GNUNET_free (fn);
- return NULL;
- }
+ len = 0;
+ GNUNET_disk_file_size (ectx, fn, &len, GNUNET_YES);
fd = GNUNET_disk_file_open (ectx, fn, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
i = 0;
idx = -1;
@@ -140,7 +135,7 @@
if (slen == 0)
return GNUNET_SYSERR;
name = GNUNET_strdup (ns_uname);
- name[slen] = '\0';
+ name[slen-1] = '\0';
GNUNET_hash (name, strlen (name), &nh);
GNUNET_free (name);
fn = GNUNET_PSEUDO_internal_get_data_filename_ (ectx,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6974 - GNUnet/src/applications/fs/pseudonyms,
gnunet <=