aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dhtlog.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-09-07 14:33:14 +0000
committerNathan S. Evans <evans@in.tum.de>2010-09-07 14:33:14 +0000
commita6f9e3d3b78cb1e1333965620e957ffeed709ed0 (patch)
treed26f26029a9784c16293998504003412cf8dde28 /src/dht/test_dhtlog.c
parent13d8744f99d41435783f28fd683784705194a281 (diff)
downloadgnunet-a6f9e3d3b78cb1e1333965620e957ffeed709ed0.tar.gz
gnunet-a6f9e3d3b78cb1e1333965620e957ffeed709ed0.zip
add republish support in dht (default once an hour, just like kademlia), improved next hop selection (or so I think), use 'TrialInfo' struct in dhtlog testcase
Diffstat (limited to 'src/dht/test_dhtlog.c')
-rw-r--r--src/dht/test_dhtlog.c78
1 files changed, 68 insertions, 10 deletions
diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c
index c2c5ccf72..08ac6af65 100644
--- a/src/dht/test_dhtlog.c
+++ b/src/dht/test_dhtlog.c
@@ -28,7 +28,7 @@
28#include "gnunet_protocols.h" 28#include "gnunet_protocols.h"
29#include "dhtlog.h" 29#include "dhtlog.h"
30 30
31#define VERBOSE GNUNET_YES 31#define VERBOSE GNUNET_NO
32 32
33static int ok; 33static int ok;
34 34
@@ -43,13 +43,11 @@ test (struct GNUNET_DHTLOG_Handle * api)
43 struct GNUNET_PeerIdentity p2; 43 struct GNUNET_PeerIdentity p2;
44 struct GNUNET_PeerIdentity p3; 44 struct GNUNET_PeerIdentity p3;
45 struct GNUNET_PeerIdentity p4; 45 struct GNUNET_PeerIdentity p4;
46 46 struct GNUNET_DHTLOG_TrialInfo trial_info;
47 GNUNET_HashCode k1; 47 GNUNET_HashCode k1;
48 GNUNET_HashCode k2; 48 GNUNET_HashCode k2;
49
50 int ret; 49 int ret;
51 unsigned int i = 42; 50 unsigned int i = 42;
52 unsigned long long trialuid;
53 unsigned long long sqlqueryuid; 51 unsigned long long sqlqueryuid;
54 unsigned long long sqlrouteuid = 0; 52 unsigned long long sqlrouteuid = 0;
55 unsigned long long nodeuid = 0; 53 unsigned long long nodeuid = 0;
@@ -62,15 +60,42 @@ test (struct GNUNET_DHTLOG_Handle * api)
62 60
63 memset (&k1, 0, sizeof (GNUNET_HashCode)); 61 memset (&k1, 0, sizeof (GNUNET_HashCode));
64 memset (&k2, 1, sizeof (GNUNET_HashCode)); 62 memset (&k2, 1, sizeof (GNUNET_HashCode));
65 63 memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo));
64 trial_info.other_identifier = 777;
65 trial_info.num_nodes = i;
66 trial_info.topology = 5;
67 trial_info.blacklist_topology = 4;
68 trial_info.connect_topology = 3;
69 trial_info.connect_topology_option = 2;
70 trial_info.connect_topology_option_modifier = .75;
71 trial_info.topology_percentage = .25;
72 trial_info.topology_probability = .5;
73 trial_info.puts = 42;
74 trial_info.gets = 14;
75 trial_info.concurrent = 5;
76 trial_info.settle_time = 1;
77 trial_info.num_rounds = 12;
78 trial_info.malicious_getters = 0;
79 trial_info.malicious_putters = 0;
80 trial_info.malicious_droppers = 0;
81 trial_info.malicious_get_frequency = 1;
82 trial_info.malicious_put_frequency = 0;
83 trial_info.stop_closest = 1;
84 trial_info.stop_found = 0;
85 trial_info.strict_kademlia = 1;
86 trial_info.message = GNUNET_strdup("TEST INSERT_TRIAL");
66 ret = 87 ret =
67 api->insert_trial (&trialuid, i, 5, 4, 3, 2, 88 api->insert_trial (&trial_info);
68 .75, .25, .5, 42, 14, 89 GNUNET_free(trial_info.message);
69 5, 1, 12, 0, 0, 0, 1, 0, 1,
70 0, 1, 0, "TEST INSERT TRIAL");
71 CHECK(ret); 90 CHECK(ret);
91#if VERBOSE
92 fprintf(stderr, "Insert trial succeeded!\n");
93#endif
72 ret = api->insert_topology(500); 94 ret = api->insert_topology(500);
73 CHECK(ret); 95 CHECK(ret);
96#if VERBOSE
97 fprintf(stderr, "Insert topology succeeded!\n");
98#endif
74 ret = api->insert_node (&nodeuid, &p1); 99 ret = api->insert_node (&nodeuid, &p1);
75 CHECK(ret); 100 CHECK(ret);
76 ret = api->insert_node (&nodeuid, &p2); 101 ret = api->insert_node (&nodeuid, &p2);
@@ -79,22 +104,43 @@ test (struct GNUNET_DHTLOG_Handle * api)
79 CHECK(ret); 104 CHECK(ret);
80 ret = api->insert_node (&nodeuid, &p4); 105 ret = api->insert_node (&nodeuid, &p4);
81 CHECK(ret); 106 CHECK(ret);
107#if VERBOSE
108 fprintf(stderr, "Insert node succeeded!\n");
109#endif
82 ret = api->set_malicious(&p1); 110 ret = api->set_malicious(&p1);
83 CHECK(ret); 111 CHECK(ret);
112#if VERBOSE
113 fprintf(stderr, "Set malicious succeeded!\n");
114#endif
84 ret = api->insert_topology(0); 115 ret = api->insert_topology(0);
85 CHECK(ret); 116 CHECK(ret);
117#if VERBOSE
118 fprintf(stderr, "Insert topology succeeded!\n");
119#endif
86 ret = api->insert_extended_topology(&p1, &p2); 120 ret = api->insert_extended_topology(&p1, &p2);
87 CHECK(ret); 121 CHECK(ret);
88 ret = api->insert_extended_topology(&p3, &p4); 122 ret = api->insert_extended_topology(&p3, &p4);
89 CHECK(ret); 123 CHECK(ret);
124#if VERBOSE
125 fprintf(stderr, "Insert extended topology succeeded!\n");
126#endif
90 ret = api->update_topology(101); 127 ret = api->update_topology(101);
91 CHECK(ret); 128 CHECK(ret);
129#if VERBOSE
130 fprintf(stderr, "Update topology succeeded!\n");
131#endif
92 ret = api->insert_dhtkey (&dhtkeyuid, &k1); 132 ret = api->insert_dhtkey (&dhtkeyuid, &k1);
93 CHECK(ret); 133 CHECK(ret);
94 ret = api->insert_dhtkey (&dhtkeyuid, &k2); 134 ret = api->insert_dhtkey (&dhtkeyuid, &k2);
95 CHECK(ret); 135 CHECK(ret);
136#if VERBOSE
137 fprintf(stderr, "Insert dhtkey succeeded!\n");
138#endif
96 ret = api->insert_query (&sqlqueryuid, internaluid, 2, 4, 0, &p2, &k1); 139 ret = api->insert_query (&sqlqueryuid, internaluid, 2, 4, 0, &p2, &k1);
97 CHECK(ret); 140 CHECK(ret);
141#if VERBOSE
142 fprintf(stderr, "Insert query succeeded!\n");
143#endif
98 ret = 144 ret =
99 api->insert_route (&sqlrouteuid, sqlqueryuid, 1, 1, DHTLOG_GET, &p1, &k2, 145 api->insert_route (&sqlrouteuid, sqlqueryuid, 1, 1, DHTLOG_GET, &p1, &k2,
100 &p4, &p3); 146 &p4, &p3);
@@ -111,15 +157,27 @@ test (struct GNUNET_DHTLOG_Handle * api)
111 api->insert_route (&sqlrouteuid, sqlqueryuid, 4, 7, DHTLOG_ROUTE, &p3, &k2, 157 api->insert_route (&sqlrouteuid, sqlqueryuid, 4, 7, DHTLOG_ROUTE, &p3, &k2,
112 NULL, NULL); 158 NULL, NULL);
113 CHECK(ret); 159 CHECK(ret);
160#if VERBOSE
161 fprintf(stderr, "Insert route succeeded!\n");
162#endif
114 sleep (1); 163 sleep (1);
115 ret = api->insert_stat(&p1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); 164 ret = api->insert_stat(&p1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
116 CHECK(ret); 165 CHECK(ret);
117 ret = api->insert_stat(&p2, 12, 23, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27); 166 ret = api->insert_stat(&p2, 12, 23, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
118 CHECK(ret); 167 CHECK(ret);
119 ret = api->update_trial (trialuid, 787); 168#if VERBOSE
169 fprintf(stderr, "Insert stat succeeded!\n");
170#endif
171 ret = api->update_trial (trial_info.trialuid, 787);
120 CHECK(ret); 172 CHECK(ret);
173#if VERBOSE
174 fprintf(stderr, "Update trial succeeded!\n");
175#endif
121 ret = api->add_generic_stat (&p2, "nonsense", "section", 77765); 176 ret = api->add_generic_stat (&p2, "nonsense", "section", 77765);
122 CHECK(ret); 177 CHECK(ret);
178#if VERBOSE
179 fprintf(stderr, "Insert generic stat succeeded!\n");
180#endif
123 return 0; 181 return 0;
124} 182}
125 183