diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-23 17:27:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-23 17:27:42 +0000 |
commit | 37488aed2cecebf4472d8e7bef0ebea2a92c9c01 (patch) | |
tree | 533bbc8cb1a64f230fd782b6deb2f9c5db846ca6 /src/namestore/test_plugin_namestore.c | |
parent | 6a970be4b56545fe71f12f7abe0384cd81975245 (diff) | |
download | gnunet-37488aed2cecebf4472d8e7bef0ebea2a92c9c01.tar.gz gnunet-37488aed2cecebf4472d8e7bef0ebea2a92c9c01.zip |
-fixing bugs and testcase, plugin now works for updated API again
Diffstat (limited to 'src/namestore/test_plugin_namestore.c')
-rw-r--r-- | src/namestore/test_plugin_namestore.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c index b95e9f0c9..be65934d9 100644 --- a/src/namestore/test_plugin_namestore.c +++ b/src/namestore/test_plugin_namestore.c | |||
@@ -102,6 +102,28 @@ test_record (void *cls, | |||
102 | const struct GNUNET_NAMESTORE_RecordData *rd, | 102 | const struct GNUNET_NAMESTORE_RecordData *rd, |
103 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 103 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
104 | { | 104 | { |
105 | int *idp = cls; | ||
106 | int id = *idp; | ||
107 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded tzone_key; | ||
108 | char tname[64]; | ||
109 | unsigned int trd_count = 1 + (id % 1024); | ||
110 | struct GNUNET_CRYPTO_RsaSignature tsignature; | ||
111 | unsigned int i; | ||
112 | |||
113 | GNUNET_snprintf (tname, sizeof (tname), | ||
114 | "a%u", (unsigned int ) id); | ||
115 | for (i=0;i<trd_count;i++) | ||
116 | { | ||
117 | GNUNET_assert (rd[i].data_size == id % 10); | ||
118 | GNUNET_assert (0 == memcmp ("Hello World", rd[i].data, id % 10)); | ||
119 | GNUNET_assert (rd[i].record_type == 1 + (id % 13)); | ||
120 | GNUNET_assert (rd[i].flags == (id % 7)); | ||
121 | } | ||
122 | memset (&tzone_key, (id % 241), sizeof (tzone_key)); | ||
123 | memset (&tsignature, (id % 243), sizeof (tsignature)); | ||
124 | GNUNET_assert (0 == strcmp (name, tname)); | ||
125 | GNUNET_assert (0 == memcmp (&tzone_key, zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))); | ||
126 | GNUNET_assert (0 == memcmp (&tsignature, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature))); | ||
105 | } | 127 | } |
106 | 128 | ||
107 | 129 | ||
@@ -117,6 +139,34 @@ get_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id) | |||
117 | static void | 139 | static void |
118 | put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id) | 140 | put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id) |
119 | { | 141 | { |
142 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key; | ||
143 | struct GNUNET_TIME_Absolute expire; | ||
144 | char name[64]; | ||
145 | unsigned int rd_count = 1 + (id % 1024); | ||
146 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | ||
147 | struct GNUNET_CRYPTO_RsaSignature signature; | ||
148 | unsigned int i; | ||
149 | |||
150 | GNUNET_snprintf (name, sizeof (name), | ||
151 | "a%u", (unsigned int ) id); | ||
152 | expire = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); | ||
153 | for (i=0;i<rd_count;i++) | ||
154 | { | ||
155 | rd[i].data = "Hello World"; | ||
156 | rd[i].data_size = id % 10; | ||
157 | rd[i].expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); | ||
158 | rd[i].record_type = 1 + (id % 13); | ||
159 | rd[i].flags = (id % 7); | ||
160 | } | ||
161 | memset (&zone_key, (id % 241), sizeof (zone_key)); | ||
162 | memset (&signature, (id % 243), sizeof (signature)); | ||
163 | GNUNET_assert (GNUNET_OK == nsp->put_records (nsp->cls, | ||
164 | &zone_key, | ||
165 | expire, | ||
166 | name, | ||
167 | rd_count, | ||
168 | rd, | ||
169 | &signature)); | ||
120 | } | 170 | } |
121 | 171 | ||
122 | 172 | ||
@@ -125,6 +175,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
125 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 175 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
126 | { | 176 | { |
127 | struct GNUNET_NAMESTORE_PluginFunctions *nsp; | 177 | struct GNUNET_NAMESTORE_PluginFunctions *nsp; |
178 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key; | ||
128 | GNUNET_HashCode zone; | 179 | GNUNET_HashCode zone; |
129 | 180 | ||
130 | ok = 0; | 181 | ok = 0; |
@@ -139,7 +190,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
139 | put_record (nsp, 1); | 190 | put_record (nsp, 1); |
140 | get_record (nsp, 1); | 191 | get_record (nsp, 1); |
141 | 192 | ||
142 | memset (&zone, 42, sizeof (zone)); | 193 | memset (&zone_key, 1, sizeof (zone_key)); |
194 | GNUNET_CRYPTO_hash (&zone_key, sizeof (zone_key), &zone); | ||
143 | nsp->delete_zone (nsp->cls, &zone); | 195 | nsp->delete_zone (nsp->cls, &zone); |
144 | unload_plugin (nsp); | 196 | unload_plugin (nsp); |
145 | } | 197 | } |