aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/test_revocation.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-04-20 16:56:16 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-04-20 16:56:16 +0200
commitee5cfec8640886ea3fa3f582cb04347762feebbd (patch)
treec884ba6d0b6304fb635e4fd1a482fdffc91cf6f3 /src/revocation/test_revocation.c
parent6d61330e3ae457a27f10247cd9caf53987604143 (diff)
downloadgnunet-ee5cfec8640886ea3fa3f582cb04347762feebbd.tar.gz
gnunet-ee5cfec8640886ea3fa3f582cb04347762feebbd.zip
fix tests
Diffstat (limited to 'src/revocation/test_revocation.c')
-rw-r--r--src/revocation/test_revocation.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/revocation/test_revocation.c b/src/revocation/test_revocation.c
index 012bac09e..07f5e6e61 100644
--- a/src/revocation/test_revocation.c
+++ b/src/revocation/test_revocation.c
@@ -45,7 +45,7 @@ struct TestPeer
45 struct GNUNET_IDENTITY_EgoLookup *ego_lookup; 45 struct GNUNET_IDENTITY_EgoLookup *ego_lookup;
46 struct GNUNET_REVOCATION_Handle *revok_handle; 46 struct GNUNET_REVOCATION_Handle *revok_handle;
47 struct GNUNET_CORE_Handle *ch; 47 struct GNUNET_CORE_Handle *ch;
48 uint64_t pow; 48 struct GNUNET_REVOCATION_PowCalculationHandle *pow;
49}; 49};
50 50
51static struct TestPeer testpeers[2]; 51static struct TestPeer testpeers[2];
@@ -146,6 +146,7 @@ static void
146ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 146ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
147{ 147{
148 static int completed = 0; 148 static int completed = 0;
149 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
149 150
150 if ((NULL != ego) && (cls == &testpeers[0])) 151 if ((NULL != ego) && (cls == &testpeers[0]))
151 { 152 {
@@ -159,30 +160,31 @@ ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
159 testpeers[1].ego_lookup = NULL; 160 testpeers[1].ego_lookup = NULL;
160 testpeers[1].privkey = GNUNET_IDENTITY_ego_get_private_key (ego); 161 testpeers[1].privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
161 GNUNET_IDENTITY_ego_get_public_key (ego, &testpeers[1].pubkey); 162 GNUNET_IDENTITY_ego_get_public_key (ego, &testpeers[1].pubkey);
162 GNUNET_REVOCATION_sign_revocation (testpeers[1].privkey, &testpeers[1].sig);
163
164 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calculating proof of work...\n"); 163 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calculating proof of work...\n");
165 testpeers[1].pow = 0; 164 privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
165 testpeers[1].pow = GNUNET_REVOCATION_pow_init (privkey,
166 1,
167 5);
166 int res = 168 int res =
167 GNUNET_REVOCATION_check_pow (&testpeers[1].pubkey, testpeers[1].pow, 5); 169 GNUNET_REVOCATION_pow_round (testpeers[1].pow);
168 while (GNUNET_OK != res) 170 while (GNUNET_OK != res)
169 { 171 {
170 testpeers[1].pow++;
171 res = 172 res =
172 GNUNET_REVOCATION_check_pow (&testpeers[1].pubkey, testpeers[1].pow, 5); 173 GNUNET_REVOCATION_pow_round (testpeers[1].pow);
173 } 174 }
174 fprintf (stderr, "Done calculating proof of work\n"); 175 fprintf (stderr, "Done calculating proof of work\n");
175 completed++; 176 completed++;
176 } 177 }
177 if (2 == completed) 178 if (2 == completed)
178 { 179 {
180 const struct GNUNET_REVOCATION_Pow *pow;
181 pow = GNUNET_REVOCATION_pow_get (testpeers[1].pow);
179 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Egos retrieved\n"); 182 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Egos retrieved\n");
180 testpeers[1].revok_handle = GNUNET_REVOCATION_revoke (testpeers[1].cfg, 183 testpeers[1].revok_handle = GNUNET_REVOCATION_revoke (testpeers[1].cfg,
181 &testpeers[1].pubkey, 184 pow,
182 &testpeers[1].sig,
183 testpeers[1].pow,
184 &revocation_cb, 185 &revocation_cb,
185 NULL); 186 NULL);
187 GNUNET_REVOCATION_pow_cleanup (testpeers[1].pow);
186 } 188 }
187} 189}
188 190