diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-11 12:26:59 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-11 12:26:59 +0000 |
commit | 2f9df8cdd7131faff5c73cea1566467bec2d5594 (patch) | |
tree | e589bbdbfd40f2449636e48ce61b0a88e68f94a1 /src/namestore/test_namestore_api_remove_not_existing_record.c | |
parent | 27170820d29df7dc805f98691f1352146277698d (diff) | |
download | gnunet-2f9df8cdd7131faff5c73cea1566467bec2d5594.tar.gz gnunet-2f9df8cdd7131faff5c73cea1566467bec2d5594.zip |
modified test
Diffstat (limited to 'src/namestore/test_namestore_api_remove_not_existing_record.c')
-rw-r--r-- | src/namestore/test_namestore_api_remove_not_existing_record.c | 72 |
1 files changed, 15 insertions, 57 deletions
diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c index b09748e69..396e69ff0 100644 --- a/src/namestore/test_namestore_api_remove_not_existing_record.c +++ b/src/namestore/test_namestore_api_remove_not_existing_record.c | |||
@@ -43,8 +43,6 @@ static struct GNUNET_CRYPTO_EccPrivateKey *privkey; | |||
43 | 43 | ||
44 | static struct GNUNET_CRYPTO_EccPublicKey pubkey; | 44 | static struct GNUNET_CRYPTO_EccPublicKey pubkey; |
45 | 45 | ||
46 | static struct GNUNET_HashCode derived_hash; | ||
47 | |||
48 | static int res; | 46 | static int res; |
49 | 47 | ||
50 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | 48 | static struct GNUNET_NAMESTORE_QueueEntry *nsqe; |
@@ -95,83 +93,43 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
95 | 93 | ||
96 | 94 | ||
97 | static void | 95 | static void |
98 | rd_decrypt_cb (void *cls, | 96 | put_cont (void *cls, int32_t success, const char *emsg) |
99 | unsigned int rd_count, | ||
100 | const struct GNUNET_NAMESTORE_RecordData *rd) | ||
101 | { | ||
102 | GNUNET_assert (0 == rd_count); | ||
103 | GNUNET_assert (NULL == rd); | ||
104 | |||
105 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
106 | } | ||
107 | |||
108 | static void | ||
109 | name_lookup_proc (void *cls, | ||
110 | const struct GNUNET_NAMESTORE_Block *block) | ||
111 | { | 97 | { |
112 | const char *name = cls; | ||
113 | nsqe = NULL; | ||
114 | |||
115 | GNUNET_assert (NULL != cls); | 98 | GNUNET_assert (NULL != cls); |
116 | 99 | ||
117 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 100 | nsqe = NULL; |
118 | { | ||
119 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
120 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | ||
121 | } | ||
122 | 101 | ||
123 | if (NULL == block) | 102 | if (GNUNET_SYSERR == success) |
124 | { | 103 | { |
104 | GNUNET_break (0); | ||
125 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 105 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
126 | _("Namestore returned no block\n")); | 106 | _("Namestore could not remove record: `%s'\n"), emsg); |
127 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 107 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
128 | GNUNET_SCHEDULER_cancel (endbadly_task); | 108 | GNUNET_SCHEDULER_cancel (endbadly_task); |
129 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 109 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
130 | return; | 110 | return; |
131 | } | 111 | } |
132 | 112 | else if (GNUNET_OK == success) | |
133 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
134 | "Namestore returned block, decrypting \n"); | ||
135 | GNUNET_assert (GNUNET_OK == GNUNET_NAMESTORE_block_decrypt(block, | ||
136 | &pubkey, name, &rd_decrypt_cb, (void *) name)); | ||
137 | } | ||
138 | |||
139 | static void | ||
140 | put_cont (void *cls, int32_t success, const char *emsg) | ||
141 | { | ||
142 | const char *name = cls; | ||
143 | |||
144 | GNUNET_assert (NULL != cls); | ||
145 | if (GNUNET_SYSERR == success) | ||
146 | { | 113 | { |
147 | GNUNET_break (0); | 114 | GNUNET_break (0); |
148 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
149 | _("Namestore could not store record: `%s'\n"), emsg); | 116 | _("Namestore did remove not exisiting record: `%s'\n"), emsg); |
150 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 117 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
151 | GNUNET_SCHEDULER_cancel (endbadly_task); | 118 | GNUNET_SCHEDULER_cancel (endbadly_task); |
152 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 119 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
153 | return; | 120 | return; |
154 | } | 121 | } |
155 | 122 | else | |
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
157 | "Name store added record for `%s': %s\n", | ||
158 | name, | ||
159 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | ||
160 | |||
161 | /* Create derived hash */ | ||
162 | GNUNET_NAMESTORE_query_from_private_key (privkey, name, &derived_hash); | ||
163 | |||
164 | nsqe = GNUNET_NAMESTORE_lookup_block (nsh, &derived_hash, | ||
165 | &name_lookup_proc, (void *) name); | ||
166 | if (NULL == nsqe) | ||
167 | { | 123 | { |
168 | GNUNET_break (0); | 124 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
169 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 125 | "Name was not removed\n"); |
170 | _("Namestore cannot perform lookup\n")); | 126 | res = 0; |
171 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 127 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
128 | { | ||
172 | GNUNET_SCHEDULER_cancel (endbadly_task); | 129 | GNUNET_SCHEDULER_cancel (endbadly_task); |
173 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 130 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
174 | return; | 131 | } |
132 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
175 | } | 133 | } |
176 | } | 134 | } |
177 | 135 | ||