aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/test_peerstore_api_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerstore/test_peerstore_api_sync.c')
-rw-r--r--src/peerstore/test_peerstore_api_sync.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/peerstore/test_peerstore_api_sync.c b/src/peerstore/test_peerstore_api_sync.c
index b2ac860b7..bfeae6ed8 100644
--- a/src/peerstore/test_peerstore_api_sync.c
+++ b/src/peerstore/test_peerstore_api_sync.c
@@ -117,6 +117,28 @@ test_cont (void *cls)
117 NULL); 117 NULL);
118} 118}
119 119
120static void
121disc_cont (void *cls)
122{
123 GNUNET_PEERSTORE_disconnect (h, GNUNET_YES);
124 h = NULL;
125 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
126 &test_cont,
127 NULL);
128}
129
130static void
131store_cont (void *cls, int success)
132{
133 ok = success;
134 /* We need to wait a little bit to give the disconnect
135 a chance to actually finish the operation; otherwise,
136 the test may fail non-deterministically if the new
137 connection is faster than the cleanup routine of the
138 old one. */
139 GNUNET_SCHEDULER_add_now (&disc_cont,
140 NULL);
141}
120 142
121/** 143/**
122 * Actually run the test. 144 * Actually run the test.
@@ -132,18 +154,7 @@ test1 ()
132 val, strlen (val) + 1, 154 val, strlen (val) + 1,
133 GNUNET_TIME_UNIT_FOREVER_ABS, 155 GNUNET_TIME_UNIT_FOREVER_ABS,
134 GNUNET_PEERSTORE_STOREOPTION_REPLACE, 156 GNUNET_PEERSTORE_STOREOPTION_REPLACE,
135 NULL, NULL); 157 &store_cont, NULL);
136 GNUNET_PEERSTORE_disconnect (h,
137 GNUNET_YES);
138 h = NULL;
139 /* We need to wait a little bit to give the disconnect
140 a chance to actually finish the operation; otherwise,
141 the test may fail non-deterministically if the new
142 connection is faster than the cleanup routine of the
143 old one. */
144 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
145 &test_cont,
146 NULL);
147} 158}
148 159
149 160
@@ -171,7 +182,7 @@ main (int argc, char *argv[])
171 if (0 != 182 if (0 !=
172 GNUNET_TESTING_service_run ("test-gnunet-peerstore-sync", 183 GNUNET_TESTING_service_run ("test-gnunet-peerstore-sync",
173 "peerstore", 184 "peerstore",
174 "test_peerstore_api_data.conf", 185 "peerstore.conf",
175 &run, NULL)) 186 &run, NULL))
176 return 1; 187 return 1;
177 if (0 != ok) 188 if (0 != ok)