diff options
Diffstat (limited to 'src/util/test_pseudonym.c')
-rw-r--r-- | src/util/test_pseudonym.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/util/test_pseudonym.c b/src/util/test_pseudonym.c index 30a04598c..20a3d3d96 100644 --- a/src/util/test_pseudonym.c +++ b/src/util/test_pseudonym.c | |||
@@ -45,16 +45,16 @@ iter (void *cls, const GNUNET_HashCode * pseudonym, | |||
45 | 45 | ||
46 | if ((0 == memcmp (pseudonym, &id1, sizeof (GNUNET_HashCode))) && | 46 | if ((0 == memcmp (pseudonym, &id1, sizeof (GNUNET_HashCode))) && |
47 | (!GNUNET_CONTAINER_meta_data_test_equal (md, meta))) | 47 | (!GNUNET_CONTAINER_meta_data_test_equal (md, meta))) |
48 | { | 48 | { |
49 | *ok = GNUNET_NO; | 49 | *ok = GNUNET_NO; |
50 | GNUNET_break (0); | 50 | GNUNET_break (0); |
51 | } | 51 | } |
52 | return GNUNET_OK; | 52 | return GNUNET_OK; |
53 | } | 53 | } |
54 | 54 | ||
55 | static int | 55 | static int |
56 | noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | 56 | noti_callback (void *cls, const GNUNET_HashCode * pseudonym, |
57 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 57 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
58 | { | 58 | { |
59 | int *ret = cls; | 59 | int *ret = cls; |
60 | 60 | ||
@@ -64,7 +64,7 @@ noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | |||
64 | 64 | ||
65 | static int | 65 | static int |
66 | fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | 66 | fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, |
67 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 67 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
68 | { | 68 | { |
69 | int *ret = cls; | 69 | int *ret = cls; |
70 | 70 | ||
@@ -74,7 +74,7 @@ fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, | |||
74 | 74 | ||
75 | static int | 75 | static int |
76 | false_callback (void *cls, const GNUNET_HashCode * pseudonym, | 76 | false_callback (void *cls, const GNUNET_HashCode * pseudonym, |
77 | const struct GNUNET_CONTAINER_MetaData *md, int rating) | 77 | const struct GNUNET_CONTAINER_MetaData *md, int rating) |
78 | { | 78 | { |
79 | return GNUNET_OK; | 79 | return GNUNET_OK; |
80 | } | 80 | } |
@@ -109,28 +109,28 @@ main (int argc, char *argv[]) | |||
109 | (void) GNUNET_DISK_directory_remove ("/tmp/gnunet-pseudonym-test"); | 109 | (void) GNUNET_DISK_directory_remove ("/tmp/gnunet-pseudonym-test"); |
110 | cfg = GNUNET_CONFIGURATION_create (); | 110 | cfg = GNUNET_CONFIGURATION_create (); |
111 | if (-1 == GNUNET_CONFIGURATION_parse (cfg, "test_pseudonym_data.conf")) | 111 | if (-1 == GNUNET_CONFIGURATION_parse (cfg, "test_pseudonym_data.conf")) |
112 | { | 112 | { |
113 | GNUNET_CONFIGURATION_destroy (cfg); | 113 | GNUNET_CONFIGURATION_destroy (cfg); |
114 | GNUNET_break (0); | 114 | GNUNET_break (0); |
115 | return -1; | 115 | return -1; |
116 | } | 116 | } |
117 | notiCount = 0; | 117 | notiCount = 0; |
118 | fakenotiCount = 0; | 118 | fakenotiCount = 0; |
119 | count = 0; | 119 | count = 0; |
120 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, &fake_noti_callback, | 120 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, &fake_noti_callback, |
121 | &fakenotiCount); | 121 | &fakenotiCount); |
122 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, ¬i_callback, | 122 | GNUNET_PSEUDONYM_discovery_callback_register (cfg, ¬i_callback, |
123 | ¬iCount); | 123 | ¬iCount); |
124 | GNUNET_PSEUDONYM_discovery_callback_unregister (&false_callback, &count); | 124 | GNUNET_PSEUDONYM_discovery_callback_unregister (&false_callback, &count); |
125 | GNUNET_PSEUDONYM_discovery_callback_unregister (&fake_noti_callback, | 125 | GNUNET_PSEUDONYM_discovery_callback_unregister (&fake_noti_callback, |
126 | &fakenotiCount); | 126 | &fakenotiCount); |
127 | 127 | ||
128 | /* ACTUAL TEST CODE */ | 128 | /* ACTUAL TEST CODE */ |
129 | old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL); | 129 | old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL); |
130 | meta = GNUNET_CONTAINER_meta_data_create (); | 130 | meta = GNUNET_CONTAINER_meta_data_create (); |
131 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE, | 131 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE, |
132 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", | 132 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", |
133 | "test", strlen ("test") + 1); | 133 | "test", strlen ("test") + 1); |
134 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1); | 134 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1); |
135 | GNUNET_PSEUDONYM_add (cfg, &id1, meta); | 135 | GNUNET_PSEUDONYM_add (cfg, &id1, meta); |
136 | CHECK (notiCount == 1); | 136 | CHECK (notiCount == 1); |
@@ -145,11 +145,11 @@ main (int argc, char *argv[]) | |||
145 | newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok); | 145 | newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok); |
146 | CHECK (old < newVal); | 146 | CHECK (old < newVal); |
147 | GNUNET_assert (GNUNET_OK == | 147 | GNUNET_assert (GNUNET_OK == |
148 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", | 148 | GNUNET_CONTAINER_meta_data_insert (meta, "<test>", |
149 | EXTRACTOR_METATYPE_COMMENT, | 149 | EXTRACTOR_METATYPE_COMMENT, |
150 | EXTRACTOR_METAFORMAT_UTF8, | 150 | EXTRACTOR_METAFORMAT_UTF8, |
151 | "text/plain", m, | 151 | "text/plain", m, |
152 | strlen (m) + 1)); | 152 | strlen (m) + 1)); |
153 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); | 153 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); |
154 | GNUNET_PSEUDONYM_add (cfg, &id3, meta); | 154 | GNUNET_PSEUDONYM_add (cfg, &id3, meta); |
155 | name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3); | 155 | name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3); |
@@ -184,7 +184,7 @@ FAILURE: | |||
184 | GNUNET_CONTAINER_meta_data_destroy (meta); | 184 | GNUNET_CONTAINER_meta_data_destroy (meta); |
185 | GNUNET_CONFIGURATION_destroy (cfg); | 185 | GNUNET_CONFIGURATION_destroy (cfg); |
186 | GNUNET_break (GNUNET_OK == | 186 | GNUNET_break (GNUNET_OK == |
187 | GNUNET_DISK_directory_remove ("/tmp/gnunet-pseudonym-test")); | 187 | GNUNET_DISK_directory_remove ("/tmp/gnunet-pseudonym-test")); |
188 | return (ok == GNUNET_YES) ? 0 : 1; | 188 | return (ok == GNUNET_YES) ? 0 : 1; |
189 | } | 189 | } |
190 | 190 | ||