From a09d684cfc9cd20d7471b42e134fecc142786097 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 18 Aug 2015 12:24:51 +0200 Subject: [PATCH] handle permutations of keys in reply --- src/mint-lib/mint_api_refresh.c | 2 +- src/mint-lib/test_mint_api.c | 53 ++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/mint-lib/mint_api_refresh.c b/src/mint-lib/mint_api_refresh.c index e09c0d32f..c33d1714a 100644 --- a/src/mint-lib/mint_api_refresh.c +++ b/src/mint-lib/mint_api_refresh.c @@ -773,7 +773,7 @@ deserialize_melt_data (const char *buf, &buf[off], buf_size - off, &ok); - if (off != buf_size) + if (off != buf_size) { GNUNET_break (0); ok = GNUNET_NO; diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index 9681cb9ba..8a9d09cec 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -984,6 +984,8 @@ link_cb (void *cls, struct Command *cmd = &is->commands[is->ip]; const struct Command *ref; unsigned int i; + unsigned int j; + unsigned int found; cmd->details.refresh_link.rlh = NULL; if (cmd->expected_response_code != http_status) @@ -1012,25 +1014,42 @@ link_cb (void *cls, fprintf (stderr, "Got %u coins\n", num_coins); - /* FIXME: note: coins might be legitimately permutated in here... */ - /* (in fact, we currently get them in reverse order, and that's - why this is "failing") */ - for (i=0;idetails.refresh_reveal.fresh_coins[i]; - if ( (0 != memcmp (&coin_privs[i], - &fc->coin_priv, - sizeof (struct TALER_CoinSpendPrivateKeyP))) || - (0 != GNUNET_CRYPTO_rsa_signature_cmp (fc->sig.rsa_signature, - sigs[i].rsa_signature)) || - (0 != GNUNET_CRYPTO_rsa_public_key_cmp (fc->pk->key.rsa_public_key, - pubs[i].rsa_public_key)) ) + for (i=0;idetails.refresh_reveal.fresh_coins[j]; + if ( (0 == memcmp (&coin_privs[i], + &fc->coin_priv, + sizeof (struct TALER_CoinSpendPrivateKeyP))) && + (0 == GNUNET_CRYPTO_rsa_signature_cmp (fc->sig.rsa_signature, + sigs[i].rsa_signature)) && + (0 == GNUNET_CRYPTO_rsa_public_key_cmp (fc->pk->key.rsa_public_key, + pubs[i].rsa_public_key)) ) + { + found++; + break; + } } + if (found != num_coins) + { + fprintf (stderr, + "Only %u/%u coins match expectations\n", + found, + num_coins); + GNUNET_break (0); + fail (is); + return; } break; default: @@ -2072,7 +2091,7 @@ main (int argc, fprintf (stderr, "."); sleep (1); } - while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8081/agpl -o /dev/null -O /dev/null")); + while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8081/keys -o /dev/null -O /dev/null")); fprintf (stderr, "\n"); result = GNUNET_SYSERR; GNUNET_SCHEDULER_run (&run, NULL);