aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-08-21 08:15:48 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-08-21 08:15:48 +0000
commitc30fb461c37dd2339061d42c4a92d80e46eb761d (patch)
treef4983c6d234bc848ab10f22310f072e31c7e9139
parent72009b5f3332e9472290f0495596d43e647f6bff (diff)
downloadgnunet-c30fb461c37dd2339061d42c4a92d80e46eb761d.tar.gz
gnunet-c30fb461c37dd2339061d42c4a92d80e46eb761d.zip
test compiles again, but fail to get the stored record:
in sqlite:get_record_and_call_iterator: if (SQLITE_ROW == (sret = sqlite3_step (stmt))) is false
-rw-r--r--src/namestore/test_plugin_namestore.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c
index 4b5a75b5e..0840de48c 100644
--- a/src/namestore/test_plugin_namestore.c
+++ b/src/namestore/test_plugin_namestore.c
@@ -79,7 +79,6 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
79 return ret; 79 return ret;
80} 80}
81 81
82
83/** 82/**
84 * Function called by for each matching record. 83 * Function called by for each matching record.
85 * 84 *
@@ -95,19 +94,16 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
95 */ 94 */
96static void 95static void
97test_record (void *cls, 96test_record (void *cls,
98 const struct GNUNET_CRYPTO_EccPublicKey *zone_key, 97 const struct GNUNET_CRYPTO_EccPrivateKey *private_key,
99 struct GNUNET_TIME_Absolute expire, 98 const char *label,
100 const char *name, 99 unsigned int rd_count,
101 unsigned int rd_count, 100 const struct GNUNET_NAMESTORE_RecordData *rd)
102 const struct GNUNET_NAMESTORE_RecordData *rd,
103 const struct GNUNET_CRYPTO_EccSignature *signature)
104{ 101{
105 int *idp = cls; 102 int *idp = cls;
106 int id = *idp; 103 int id = *idp;
107 struct GNUNET_CRYPTO_EccPublicKey tzone_key; 104 struct GNUNET_CRYPTO_EccPrivateKey tzone_private_key;
108 char tname[64]; 105 char tname[64];
109 unsigned int trd_count = 1 + (id % 1024); 106 unsigned int trd_count = 1 + (id % 1024);
110 struct GNUNET_CRYPTO_EccSignature tsignature;
111 unsigned int i; 107 unsigned int i;
112 108
113 GNUNET_snprintf (tname, sizeof (tname), 109 GNUNET_snprintf (tname, sizeof (tname),
@@ -119,37 +115,32 @@ test_record (void *cls,
119 GNUNET_assert (rd[i].record_type == 1 + (id % 13)); 115 GNUNET_assert (rd[i].record_type == 1 + (id % 13));
120 GNUNET_assert (rd[i].flags == (id % 7)); 116 GNUNET_assert (rd[i].flags == (id % 7));
121 } 117 }
122 memset (&tzone_key, (id % 241), sizeof (tzone_key)); 118 memset (&tzone_private_key, (id % 241), sizeof (tzone_private_key));
123 memset (&tsignature, (id % 243), sizeof (tsignature)); 119 GNUNET_assert (0 == strcmp (label, tname));
124 GNUNET_assert (0 == strcmp (name, tname)); 120 GNUNET_assert (0 == memcmp (&tzone_private_key, private_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey)));
125 GNUNET_assert (0 == memcmp (&tzone_key, zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKey)));
126 GNUNET_assert (0 == memcmp (&tsignature, signature, sizeof (struct GNUNET_CRYPTO_EccSignature)));
127} 121}
128 122
129 123
130static void 124static void
131get_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id) 125get_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
132{ 126{
133 GNUNET_assert (1 == nsp->iterate_records (nsp->cls, 127 GNUNET_assert (GNUNET_OK == nsp->iterate_records (nsp->cls,
134 NULL, NULL, 0, 128 NULL, 0, &test_record, &id));
135 &test_record, &id));
136} 129}
137 130
138 131
139static void 132static void
140put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id) 133put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
141{ 134{
142 struct GNUNET_CRYPTO_EccPublicKey zone_key; 135 struct GNUNET_CRYPTO_EccPrivateKey zone_private_key;
143 struct GNUNET_TIME_Absolute expire; 136 char label[64];
144 char name[64];
145 unsigned int rd_count = 1 + (id % 1024); 137 unsigned int rd_count = 1 + (id % 1024);
146 struct GNUNET_NAMESTORE_RecordData rd[rd_count]; 138 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
147 struct GNUNET_CRYPTO_EccSignature signature; 139 struct GNUNET_CRYPTO_EccSignature signature;
148 unsigned int i; 140 unsigned int i;
149 141
150 GNUNET_snprintf (name, sizeof (name), 142 GNUNET_snprintf (label, sizeof (label),
151 "a%u", (unsigned int ) id); 143 "a%u", (unsigned int ) id);
152 expire = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
153 for (i=0;i<rd_count;i++) 144 for (i=0;i<rd_count;i++)
154 { 145 {
155 rd[i].data = "Hello World"; 146 rd[i].data = "Hello World";
@@ -158,15 +149,13 @@ put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
158 rd[i].record_type = 1 + (id % 13); 149 rd[i].record_type = 1 + (id % 13);
159 rd[i].flags = (id % 7); 150 rd[i].flags = (id % 7);
160 } 151 }
161 memset (&zone_key, (id % 241), sizeof (zone_key)); 152 memset (&zone_private_key, (id % 241), sizeof (zone_private_key));
162 memset (&signature, (id % 243), sizeof (signature)); 153 memset (&signature, (id % 243), sizeof (signature));
163 GNUNET_assert (GNUNET_OK == nsp->put_records (nsp->cls, 154 GNUNET_assert (GNUNET_OK == nsp->store_records (nsp->cls,
164 &zone_key, 155 &zone_private_key,
165 expire, 156 label,
166 name,
167 rd_count, 157 rd_count,
168 rd, 158 rd));
169 &signature));
170} 159}
171 160
172 161
@@ -175,8 +164,6 @@ run (void *cls, char *const *args, const char *cfgfile,
175 const struct GNUNET_CONFIGURATION_Handle *cfg) 164 const struct GNUNET_CONFIGURATION_Handle *cfg)
176{ 165{
177 struct GNUNET_NAMESTORE_PluginFunctions *nsp; 166 struct GNUNET_NAMESTORE_PluginFunctions *nsp;
178 struct GNUNET_CRYPTO_EccPublicKey zone_key;
179 struct GNUNET_CRYPTO_ShortHashCode zone;
180 167
181 ok = 0; 168 ok = 0;
182 nsp = load_plugin (cfg); 169 nsp = load_plugin (cfg);
@@ -190,9 +177,6 @@ run (void *cls, char *const *args, const char *cfgfile,
190 put_record (nsp, 1); 177 put_record (nsp, 1);
191 get_record (nsp, 1); 178 get_record (nsp, 1);
192 179
193 memset (&zone_key, 1, sizeof (zone_key));
194 GNUNET_CRYPTO_short_hash (&zone_key, sizeof (zone_key), &zone);
195 nsp->delete_zone (nsp->cls, &zone);
196 unload_plugin (nsp); 180 unload_plugin (nsp);
197} 181}
198 182