aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_pseudonym.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_pseudonym.c')
-rw-r--r--src/util/test_pseudonym.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/src/util/test_pseudonym.c b/src/util/test_pseudonym.c
index dfdcbb1bb..20a3d3d96 100644
--- a/src/util/test_pseudonym.c
+++ b/src/util/test_pseudonym.c
@@ -38,15 +38,12 @@ static struct GNUNET_CONTAINER_MetaData *meta;
38static GNUNET_HashCode id1; 38static GNUNET_HashCode id1;
39 39
40static int 40static int
41iter (void *cls, 41iter (void *cls, const GNUNET_HashCode * pseudonym,
42 const GNUNET_HashCode * 42 const struct GNUNET_CONTAINER_MetaData *md, int rating)
43 pseudonym, const struct GNUNET_CONTAINER_MetaData *md, int rating)
44{ 43{
45 int *ok = cls; 44 int *ok = cls;
46 45
47 if ((0 == memcmp (pseudonym, 46 if ((0 == memcmp (pseudonym, &id1, sizeof (GNUNET_HashCode))) &&
48 &id1,
49 sizeof (GNUNET_HashCode))) &&
50 (!GNUNET_CONTAINER_meta_data_test_equal (md, meta))) 47 (!GNUNET_CONTAINER_meta_data_test_equal (md, meta)))
51 { 48 {
52 *ok = GNUNET_NO; 49 *ok = GNUNET_NO;
@@ -56,9 +53,7 @@ iter (void *cls,
56} 53}
57 54
58static int 55static int
59noti_callback (void *cls, 56noti_callback (void *cls, const GNUNET_HashCode * pseudonym,
60 const GNUNET_HashCode *
61 pseudonym,
62 const struct GNUNET_CONTAINER_MetaData *md, int rating) 57 const struct GNUNET_CONTAINER_MetaData *md, int rating)
63{ 58{
64 int *ret = cls; 59 int *ret = cls;
@@ -68,9 +63,7 @@ noti_callback (void *cls,
68} 63}
69 64
70static int 65static int
71fake_noti_callback (void *cls, 66fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym,
72 const GNUNET_HashCode *
73 pseudonym,
74 const struct GNUNET_CONTAINER_MetaData *md, int rating) 67 const struct GNUNET_CONTAINER_MetaData *md, int rating)
75{ 68{
76 int *ret = cls; 69 int *ret = cls;
@@ -80,8 +73,7 @@ fake_noti_callback (void *cls,
80} 73}
81 74
82static int 75static int
83false_callback (void *cls, 76false_callback (void *cls, const GNUNET_HashCode * pseudonym,
84 const GNUNET_HashCode * pseudonym,
85 const struct GNUNET_CONTAINER_MetaData *md, int rating) 77 const struct GNUNET_CONTAINER_MetaData *md, int rating)
86{ 78{
87 return GNUNET_OK; 79 return GNUNET_OK;
@@ -125,8 +117,7 @@ main (int argc, char *argv[])
125 notiCount = 0; 117 notiCount = 0;
126 fakenotiCount = 0; 118 fakenotiCount = 0;
127 count = 0; 119 count = 0;
128 GNUNET_PSEUDONYM_discovery_callback_register (cfg, 120 GNUNET_PSEUDONYM_discovery_callback_register (cfg, &fake_noti_callback,
129 &fake_noti_callback,
130 &fakenotiCount); 121 &fakenotiCount);
131 GNUNET_PSEUDONYM_discovery_callback_register (cfg, &noti_callback, 122 GNUNET_PSEUDONYM_discovery_callback_register (cfg, &noti_callback,
132 &notiCount); 123 &notiCount);
@@ -137,11 +128,9 @@ main (int argc, char *argv[])
137 /* ACTUAL TEST CODE */ 128 /* ACTUAL TEST CODE */
138 old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL); 129 old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL);
139 meta = GNUNET_CONTAINER_meta_data_create (); 130 meta = GNUNET_CONTAINER_meta_data_create ();
140 GNUNET_CONTAINER_meta_data_insert (meta, 131 GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE,
141 "<test>", 132 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
142 EXTRACTOR_METATYPE_TITLE, 133 "test", strlen ("test") + 1);
143 EXTRACTOR_METAFORMAT_UTF8,
144 "text/plain", "test", strlen ("test") + 1);
145 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1); 134 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1);
146 GNUNET_PSEUDONYM_add (cfg, &id1, meta); 135 GNUNET_PSEUDONYM_add (cfg, &id1, meta);
147 CHECK (notiCount == 1); 136 CHECK (notiCount == 1);
@@ -155,14 +144,12 @@ main (int argc, char *argv[])
155 CHECK (notiCount == 3); 144 CHECK (notiCount == 3);
156 newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok); 145 newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok);
157 CHECK (old < newVal); 146 CHECK (old < newVal);
158 GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (meta, 147 GNUNET_assert (GNUNET_OK ==
159 "<test>", 148 GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
160 EXTRACTOR_METATYPE_COMMENT, 149 EXTRACTOR_METATYPE_COMMENT,
161 EXTRACTOR_METAFORMAT_UTF8, 150 EXTRACTOR_METAFORMAT_UTF8,
162 "text/plain", 151 "text/plain", m,
163 m, 152 strlen (m) + 1));
164 strlen (m) +
165 1));
166 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); 153 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3);
167 GNUNET_PSEUDONYM_add (cfg, &id3, meta); 154 GNUNET_PSEUDONYM_add (cfg, &id3, meta);
168 name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3); 155 name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3);