diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-03 22:26:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-03 22:26:48 +0000 |
commit | faf0396be4edcb8f322784037f47a819f4353f3e (patch) | |
tree | f4d03d22f17e642dcb4a31582bb59f7892f2c9ef /src/namestore/test_namestore_api_store_update.c | |
parent | 81fcafdcda082db0cf0e8a9e52d7494c8b736b6d (diff) | |
download | gnunet-faf0396be4edcb8f322784037f47a819f4353f3e.tar.gz gnunet-faf0396be4edcb8f322784037f47a819f4353f3e.zip |
-reindent
Diffstat (limited to 'src/namestore/test_namestore_api_store_update.c')
-rw-r--r-- | src/namestore/test_namestore_api_store_update.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/src/namestore/test_namestore_api_store_update.c b/src/namestore/test_namestore_api_store_update.c index 288fdc38f..918b17021 100644 --- a/src/namestore/test_namestore_api_store_update.c +++ b/src/namestore/test_namestore_api_store_update.c | |||
@@ -20,6 +20,7 @@ | |||
20 | /** | 20 | /** |
21 | * @file namestore/test_namestore_api_store_update.c | 21 | * @file namestore/test_namestore_api_store_update.c |
22 | * @brief testcase for namestore_api.c: store a record, update it and perform a lookup | 22 | * @brief testcase for namestore_api.c: store a record, update it and perform a lookup |
23 | * @author Matthias Wachs | ||
23 | */ | 24 | */ |
24 | #include "platform.h" | 25 | #include "platform.h" |
25 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
@@ -57,6 +58,7 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe; | |||
57 | 58 | ||
58 | static const char * name = "dummy.dummy.gnunet"; | 59 | static const char * name = "dummy.dummy.gnunet"; |
59 | 60 | ||
61 | |||
60 | static void | 62 | static void |
61 | cleanup () | 63 | cleanup () |
62 | { | 64 | { |
@@ -81,7 +83,8 @@ cleanup () | |||
81 | * @param tc scheduler context | 83 | * @param tc scheduler context |
82 | */ | 84 | */ |
83 | static void | 85 | static void |
84 | endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 86 | endbadly (void *cls, |
87 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
85 | { | 88 | { |
86 | if (NULL != nsqe) | 89 | if (NULL != nsqe) |
87 | { | 90 | { |
@@ -94,20 +97,22 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
94 | 97 | ||
95 | 98 | ||
96 | static void | 99 | static void |
97 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 100 | end (void *cls, |
101 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
98 | { | 102 | { |
99 | cleanup (); | 103 | cleanup (); |
100 | res = 0; | 104 | res = 0; |
101 | } | 105 | } |
102 | 106 | ||
107 | |||
103 | static void | 108 | static void |
104 | put_cont (void *cls, int32_t success, const char *emsg); | 109 | put_cont (void *cls, int32_t success, const char *emsg); |
105 | 110 | ||
106 | 111 | ||
107 | static void | 112 | static void |
108 | rd_decrypt_cb (void *cls, | 113 | rd_decrypt_cb (void *cls, |
109 | unsigned int rd_count, | 114 | unsigned int rd_count, |
110 | const struct GNUNET_NAMESTORE_RecordData *rd) | 115 | const struct GNUNET_NAMESTORE_RecordData *rd) |
111 | { | 116 | { |
112 | struct GNUNET_NAMESTORE_RecordData rd_new; | 117 | struct GNUNET_NAMESTORE_RecordData rd_new; |
113 | 118 | ||
@@ -117,42 +122,42 @@ rd_decrypt_cb (void *cls, | |||
117 | if (GNUNET_NO == update_performed) | 122 | if (GNUNET_NO == update_performed) |
118 | { | 123 | { |
119 | char rd_cmp_data[TEST_RECORD_DATALEN]; | 124 | char rd_cmp_data[TEST_RECORD_DATALEN]; |
120 | memset (rd_cmp_data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); | 125 | memset (rd_cmp_data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); |
121 | 126 | ||
122 | GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type); | 127 | GNUNET_assert (TEST_RECORD_TYPE == rd[0].record_type); |
123 | GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size); | 128 | GNUNET_assert (TEST_RECORD_DATALEN == rd[0].data_size); |
124 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN)); | 129 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN)); |
125 | 130 | ||
126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
127 | "Block was decrypted successfully, updating record \n"); | 132 | "Block was decrypted successfully, updating record \n"); |
128 | 133 | ||
129 | rd_new.expiration_time = GNUNET_TIME_absolute_get().abs_value_us; | 134 | rd_new.expiration_time = GNUNET_TIME_absolute_get().abs_value_us; |
130 | rd_new.record_type = TEST_RECORD_TYPE2; | 135 | rd_new.record_type = TEST_RECORD_TYPE2; |
131 | rd_new.data_size = TEST_RECORD_DATALEN2; | 136 | rd_new.data_size = TEST_RECORD_DATALEN2; |
132 | rd_new.data = GNUNET_malloc (TEST_RECORD_DATALEN2); | 137 | rd_new.data = GNUNET_malloc (TEST_RECORD_DATALEN2); |
133 | memset ((char *) rd_new.data, TEST_RECORD_DATA2, TEST_RECORD_DATALEN2); | 138 | memset ((char *) rd_new.data, TEST_RECORD_DATA2, TEST_RECORD_DATALEN2); |
134 | 139 | ||
135 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, | 140 | nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, |
136 | 1, &rd_new, &put_cont, (void *) name); | 141 | 1, &rd_new, &put_cont, (void *) name); |
137 | update_performed = GNUNET_YES; | 142 | update_performed = GNUNET_YES; |
138 | } | 143 | } |
139 | else | 144 | else |
140 | { | 145 | { |
141 | char rd_cmp_data[TEST_RECORD_DATALEN2]; | 146 | char rd_cmp_data[TEST_RECORD_DATALEN2]; |
142 | memset (rd_cmp_data, TEST_RECORD_DATA2, TEST_RECORD_DATALEN2); | 147 | memset (rd_cmp_data, TEST_RECORD_DATA2, TEST_RECORD_DATALEN2); |
143 | 148 | ||
144 | GNUNET_assert (TEST_RECORD_TYPE2 == rd[0].record_type); | 149 | GNUNET_assert (TEST_RECORD_TYPE2 == rd[0].record_type); |
145 | GNUNET_assert (TEST_RECORD_DATALEN2 == rd[0].data_size); | 150 | GNUNET_assert (TEST_RECORD_DATALEN2 == rd[0].data_size); |
146 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN2)); | 151 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN2)); |
147 | 152 | ||
148 | GNUNET_SCHEDULER_add_now (&end, NULL); | 153 | GNUNET_SCHEDULER_add_now (&end, NULL); |
149 | } | 154 | } |
150 | |||
151 | } | 155 | } |
152 | 156 | ||
157 | |||
153 | static void | 158 | static void |
154 | name_lookup_proc (void *cls, | 159 | name_lookup_proc (void *cls, |
155 | const struct GNUNET_NAMESTORE_Block *block) | 160 | const struct GNUNET_NAMESTORE_Block *block) |
156 | { | 161 | { |
157 | const char *name = cls; | 162 | const char *name = cls; |
158 | nsqe = NULL; | 163 | nsqe = NULL; |
@@ -181,6 +186,7 @@ name_lookup_proc (void *cls, | |||
181 | &pubkey, name, &rd_decrypt_cb, (void *) name)); | 186 | &pubkey, name, &rd_decrypt_cb, (void *) name)); |
182 | } | 187 | } |
183 | 188 | ||
189 | |||
184 | static void | 190 | static void |
185 | put_cont (void *cls, int32_t success, const char *emsg) | 191 | put_cont (void *cls, int32_t success, const char *emsg) |
186 | { | 192 | { |