diff options
Diffstat (limited to 'src/secretsharing/test_secretsharing_api.c')
-rw-r--r-- | src/secretsharing/test_secretsharing_api.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/secretsharing/test_secretsharing_api.c b/src/secretsharing/test_secretsharing_api.c index 08533f703..227af1c3e 100644 --- a/src/secretsharing/test_secretsharing_api.c +++ b/src/secretsharing/test_secretsharing_api.c | |||
@@ -34,68 +34,68 @@ static struct GNUNET_SECRETSHARING_Session *keygen; | |||
34 | 34 | ||
35 | 35 | ||
36 | static void | 36 | static void |
37 | secret_ready_cb(void *cls, | 37 | secret_ready_cb (void *cls, |
38 | struct GNUNET_SECRETSHARING_Share *my_share, | 38 | struct GNUNET_SECRETSHARING_Share *my_share, |
39 | struct GNUNET_SECRETSHARING_PublicKey *public_key, | 39 | struct GNUNET_SECRETSHARING_PublicKey *public_key, |
40 | unsigned int num_ready_peers, | 40 | unsigned int num_ready_peers, |
41 | const struct GNUNET_PeerIdentity *ready_peers) | 41 | const struct GNUNET_PeerIdentity *ready_peers) |
42 | { | 42 | { |
43 | keygen = NULL; | 43 | keygen = NULL; |
44 | if (num_ready_peers == 1) | 44 | if (num_ready_peers == 1) |
45 | success = 1; | 45 | success = 1; |
46 | // FIXME: check that our share is valid, which we can do as there's only | 46 | // FIXME: check that our share is valid, which we can do as there's only |
47 | // one peer. | 47 | // one peer. |
48 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "secret ready, shutting down\n"); | 48 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "secret ready, shutting down\n"); |
49 | GNUNET_SCHEDULER_shutdown(); | 49 | GNUNET_SCHEDULER_shutdown (); |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | static void | 53 | static void |
54 | handle_shutdown(void *cls) | 54 | handle_shutdown (void *cls) |
55 | { | 55 | { |
56 | if (NULL != keygen) | 56 | if (NULL != keygen) |
57 | { | 57 | { |
58 | GNUNET_SECRETSHARING_session_destroy(keygen); | 58 | GNUNET_SECRETSHARING_session_destroy (keygen); |
59 | keygen = NULL; | 59 | keygen = NULL; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | static void | 64 | static void |
65 | run(void *cls, | 65 | run (void *cls, |
66 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 66 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
67 | struct GNUNET_TESTING_Peer *peer) | 67 | struct GNUNET_TESTING_Peer *peer) |
68 | { | 68 | { |
69 | struct GNUNET_HashCode session_id; | 69 | struct GNUNET_HashCode session_id; |
70 | struct GNUNET_TIME_Absolute start; | 70 | struct GNUNET_TIME_Absolute start; |
71 | struct GNUNET_TIME_Absolute deadline; | 71 | struct GNUNET_TIME_Absolute deadline; |
72 | 72 | ||
73 | GNUNET_SCHEDULER_add_shutdown(&handle_shutdown, NULL); | 73 | GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL); |
74 | 74 | ||
75 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "testing secretsharing api\n"); | 75 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "testing secretsharing api\n"); |
76 | 76 | ||
77 | GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &session_id); | 77 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &session_id); |
78 | 78 | ||
79 | start = GNUNET_TIME_absolute_get(); | 79 | start = GNUNET_TIME_absolute_get (); |
80 | deadline = GNUNET_TIME_absolute_add(start, GNUNET_TIME_UNIT_SECONDS); | 80 | deadline = GNUNET_TIME_absolute_add (start, GNUNET_TIME_UNIT_SECONDS); |
81 | 81 | ||
82 | keygen = GNUNET_SECRETSHARING_create_session(cfg, | 82 | keygen = GNUNET_SECRETSHARING_create_session (cfg, |
83 | 0, NULL, /* only the local peer */ | 83 | 0, NULL, /* only the local peer */ |
84 | &session_id, | 84 | &session_id, |
85 | start, deadline, | 85 | start, deadline, |
86 | 1, | 86 | 1, |
87 | secret_ready_cb, NULL); | 87 | secret_ready_cb, NULL); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | int | 91 | int |
92 | main(int argc, char **argv) | 92 | main (int argc, char **argv) |
93 | { | 93 | { |
94 | int ret; | 94 | int ret; |
95 | 95 | ||
96 | ret = GNUNET_TESTING_peer_run("test_secretsharing_api", | 96 | ret = GNUNET_TESTING_peer_run ("test_secretsharing_api", |
97 | "test_secretsharing.conf", | 97 | "test_secretsharing.conf", |
98 | &run, NULL); | 98 | &run, NULL); |
99 | if (0 != ret) | 99 | if (0 != ret) |
100 | return ret; | 100 | return ret; |
101 | return (GNUNET_YES == success) ? 0 : 1; | 101 | return (GNUNET_YES == success) ? 0 : 1; |