aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_api.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-03-19 12:43:34 +0000
committerNathan S. Evans <evans@in.tum.de>2010-03-19 12:43:34 +0000
commit0c996c9a9e418c21c7e063d443f4fa1846b9448e (patch)
treeadcecf9285343713af6dfd1bb37aaa138b27a8bc /src/dht/test_dht_api.c
parent9618f4481593c6300c04e8253f2e03a2380a899d (diff)
downloadgnunet-0c996c9a9e418c21c7e063d443f4fa1846b9448e.tar.gz
gnunet-0c996c9a9e418c21c7e063d443f4fa1846b9448e.zip
added better continuation behavior to get start, put, and route start. test case now properly handles message confirmation receipts from service. find_peer api call still needs implemented, but we are generally much closer to a working point. i'm sure there are coverity issues as well as doxygen crap to be addressed
Diffstat (limited to 'src/dht/test_dht_api.c')
-rw-r--r--src/dht/test_dht_api.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c
index 578af5aef..78e7dcd87 100644
--- a/src/dht/test_dht_api.c
+++ b/src/dht/test_dht_api.c
@@ -75,7 +75,8 @@ GNUNET_SCHEDULER_TaskIdentifier die_task;
75 75
76 76
77static void 77static void
78end () 78end (void *cls,
79 const struct GNUNET_SCHEDULER_TaskContext * tc)
79{ 80{
80 /* do work here */ 81 /* do work here */
81 GNUNET_SCHEDULER_cancel (sched, die_task); 82 GNUNET_SCHEDULER_cancel (sched, die_task);
@@ -83,8 +84,17 @@ end ()
83 GNUNET_DHT_disconnect (p1.dht_handle); 84 GNUNET_DHT_disconnect (p1.dht_handle);
84 85
85 die_task = GNUNET_SCHEDULER_NO_TASK; 86 die_task = GNUNET_SCHEDULER_NO_TASK;
86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DHT disconnected, returning success!\n"); 87
87 ok = 0; 88 if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
89 {
90 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DHT disconnected, returning FAIL!\n");
91 ok = 365;
92 }
93 else
94 {
95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DHT disconnected, returning success!\n");
96 ok = 0;
97 }
88} 98}
89 99
90static void 100static void
@@ -130,14 +140,14 @@ void test_put (void *cls,
130 memset(&hash, 42, sizeof(GNUNET_HashCode)); 140 memset(&hash, 42, sizeof(GNUNET_HashCode));
131 data = GNUNET_malloc(data_size); 141 data = GNUNET_malloc(data_size);
132 memset(data, 43, data_size); 142 memset(data, 43, data_size);
133 143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_put!\n");
134 GNUNET_assert (peer->dht_handle != NULL); 144 GNUNET_assert (peer->dht_handle != NULL);
135 145
136 GNUNET_DHT_put(peer->dht_handle, &hash, 0, data_size, data, GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 360)) ,GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 360), NULL, NULL); 146 GNUNET_DHT_put(peer->dht_handle, &hash, 0, data_size, data, GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 360)) ,GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 360), &end, NULL);
137 147
138 //GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &test_put, &p1); 148 //GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &test_put, &p1);
139 149
140 GNUNET_SCHEDULER_add_now(sched, &end, NULL); 150 //GNUNET_SCHEDULER_add_now(sched, &end, NULL);
141} 151}
142 152
143/** 153/**
@@ -153,12 +163,16 @@ void test_get_stop (void *cls,
153 GNUNET_HashCode hash; 163 GNUNET_HashCode hash;
154 memset(&hash, 42, sizeof(GNUNET_HashCode)); 164 memset(&hash, 42, sizeof(GNUNET_HashCode));
155 165
166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_get_stop!\n");
167 if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
168 GNUNET_SCHEDULER_add_now(sched, &end_badly, NULL);
169
156 GNUNET_assert (peer->dht_handle != NULL); 170 GNUNET_assert (peer->dht_handle != NULL);
157 171
158 GNUNET_DHT_get_stop(peer->get_handle); 172 GNUNET_DHT_get_stop(peer->get_handle);
159 173
160 //GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &test_put, &p1); 174 //GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &test_put, &p1);
161 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &end, &p1); 175 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &test_put, &p1);
162 176
163} 177}
164 178
@@ -175,15 +189,16 @@ void test_get (void *cls,
175 GNUNET_HashCode hash; 189 GNUNET_HashCode hash;
176 memset(&hash, 42, sizeof(GNUNET_HashCode)); 190 memset(&hash, 42, sizeof(GNUNET_HashCode));
177 191
192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_get!\n");
178 peer->dht_handle = GNUNET_DHT_connect (sched, peer->cfg, 100); 193 peer->dht_handle = GNUNET_DHT_connect (sched, peer->cfg, 100);
179 GNUNET_assert (peer->dht_handle != NULL); 194 GNUNET_assert (peer->dht_handle != NULL);
180 195
181 peer->get_handle = GNUNET_DHT_get_start(peer->dht_handle, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 100), 42, &hash, NULL, NULL); 196 peer->get_handle = GNUNET_DHT_get_start(peer->dht_handle, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 100), 42, &hash, NULL, NULL, &test_get_stop, &p1);
182 197
183 if (peer->get_handle == NULL) 198 if (peer->get_handle == NULL)
184 GNUNET_SCHEDULER_add_now(sched, &end_badly, &p1); 199 GNUNET_SCHEDULER_add_now(sched, &end_badly, &p1);
185 200
186 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &test_get_stop, &p1); 201 //GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &test_get_stop, &p1);
187} 202}
188 203
189static void 204static void