aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_container_bloomfilter.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_container_bloomfilter.c')
-rw-r--r--src/util/test_container_bloomfilter.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/util/test_container_bloomfilter.c b/src/util/test_container_bloomfilter.c
index 67fbaf38b..06a3fb500 100644
--- a/src/util/test_container_bloomfilter.c
+++ b/src/util/test_container_bloomfilter.c
@@ -31,6 +31,47 @@
31#define SIZE 65536 31#define SIZE 65536
32#define TESTFILE "/tmp/bloomtest.dat" 32#define TESTFILE "/tmp/bloomtest.dat"
33 33
34
35static void
36bernd_interop (void)
37{
38 struct GNUNET_HashCode hc;
39 char val[128];
40 size_t len;
41 struct GNUNET_CONTAINER_BloomFilter *bf;
42
43 len = GNUNET_DNSPARSER_hex_to_bin (
44 "ac4d46b62f8ddaf3cefbc1c01e47536b7ff297cb081e27a396362b1e92e5729b",
45 val);
46 GNUNET_assert (len < 128);
47 GNUNET_CRYPTO_hash (val,
48 len,
49 &hc);
50 fprintf (stderr,
51 "sha512: %s\n",
52 GNUNET_DNSPARSER_bin_to_hex (&hc,
53 sizeof (hc)));
54 bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
55 128,
56 16);
57 GNUNET_CONTAINER_bloomfilter_add (bf,
58 &hc);
59 len = GNUNET_CONTAINER_bloomfilter_get_size (bf);
60 {
61 char raw[len];
62
63 GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
64 raw,
65 len);
66 fprintf (stderr,
67 "BF: %s\n",
68 GNUNET_DNSPARSER_bin_to_hex (raw,
69 len));
70 }
71
72}
73
74
34/** 75/**
35 * Generate a random hashcode. 76 * Generate a random hashcode.
36 */ 77 */
@@ -68,7 +109,14 @@ main (int argc, char *argv[])
68 char buf[SIZE]; 109 char buf[SIZE];
69 struct stat sbuf; 110 struct stat sbuf;
70 111
71 GNUNET_log_setup ("test-container-bloomfilter", "WARNING", NULL); 112 GNUNET_log_setup ("test-container-bloomfilter",
113 "WARNING",
114 NULL);
115 if (0)
116 {
117 bernd_interop ();
118 return 0;
119 }
72 GNUNET_CRYPTO_seed_weak_random (1); 120 GNUNET_CRYPTO_seed_weak_random (1);
73 if (0 == stat (TESTFILE, &sbuf)) 121 if (0 == stat (TESTFILE, &sbuf))
74 if (0 != unlink (TESTFILE)) 122 if (0 != unlink (TESTFILE))