diff options
author | Markus Teich <markus.teich@stusta.mhn.de> | 2016-11-22 03:17:01 +0100 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2016-11-22 03:17:01 +0100 |
commit | 5706e91058ff6aa4b23b6fb13871853a54a5c4d2 (patch) | |
tree | a10f6e774ff6bd9eae30410613f30b90c153ca6a /test_brandt.c | |
parent | a74e1503752e310fbfc8dda142c5803eff86dc88 (diff) |
add m+1st price auctions with public outcome
Diffstat (limited to 'test_brandt.c')
-rw-r--r-- | test_brandt.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/test_brandt.c b/test_brandt.c index 46ec90d..d18b17a 100644 --- a/test_brandt.c +++ b/test_brandt.c @@ -54,7 +54,7 @@ static struct testcase tcase; static struct BRANDT_Result * -expected_outcome (uint16_t i) +expected_outcome (uint16_t i, uint16_t *rlen) { struct BRANDT_Result *ret = NULL; int32_t highest_bidder = -1; @@ -65,6 +65,8 @@ expected_outcome (uint16_t i) uint16_t winners = MIN (tcase.m, tcase.n); uint16_t cur_winner = 0; + *rlen = 0; + if (0 == tcase.n) return NULL; @@ -81,6 +83,7 @@ expected_outcome (uint16_t i) ret->bidder = highest_bidder; ret->price = highest_bid; ret->status = BRANDT_bidder_won; + *rlen = 1; return ret; } @@ -89,7 +92,7 @@ expected_outcome (uint16_t i) { if (tcase.outcome_public || i == tcase.n) { - ret = GNUNET_new_array (tcase.n, struct BRANDT_Result); + ret = GNUNET_new_array ((*rlen = tcase.n), struct BRANDT_Result); for (uint16_t h = 0; h < tcase.n; h++) { ret[h].bidder = h; @@ -103,6 +106,7 @@ expected_outcome (uint16_t i) ret->bidder = i; ret->price = 0; ret->status = BRANDT_bidder_won; + *rlen = 1; } return ret; } @@ -154,6 +158,7 @@ expected_outcome (uint16_t i) cur_winner++; } } + *rlen = cur_winner; return ret; } @@ -250,7 +255,16 @@ cb_result (void *auction_closure, uint16_t results_len) { uint16_t *s = (uint16_t *)auction_closure; - struct BRANDT_Result *must = expected_outcome (*s); + uint16_t mustlen = -1; + struct BRANDT_Result *must = expected_outcome (*s, &mustlen); + + if (mustlen != results_len) + { + weprintf ("expected result len is: %d", mustlen); + weprintf ("computed result len is: %d (by agent %d)", results_len, *s); + tcase.ret = 1; + goto quit; + } if (0 == results_len) { @@ -281,6 +295,7 @@ cb_result (void *auction_closure, tcase.ret = 1; } +quit: tcase.result_called[*s] = 1; if (must) GNUNET_free (must); @@ -406,17 +421,24 @@ main (int argc, char *argv[]) BRANDT_init (edc); ret |= 0 || + // zero bidders test_auction (0, 2, NULL, 0, 0) || test_auction (0, 2, NULL, 0, 1) || test_auction (0, 2, NULL, 1, 0) || test_auction (0, 2, NULL, 2, 0) || + + // too few bidders => outcome is lowest possible price test_auction (1, 2, (uint16_t[]) { 1 }, 1, 0) || test_auction (1, 2, (uint16_t[]) { 0 }, 2, 0) || test_auction (2, 2, (uint16_t[]) { 1, 0 }, 2, 0) || test_auction (2, 2, (uint16_t[]) { 1, 0 }, 1, 0) || test_auction (3, 2, (uint16_t[]) { 0, 0, 1 }, 2, 0) || + + // general checks of all four algorithms test_auction (3, 2, (uint16_t[]) { 0, 1, 1 }, 0, 0) || test_auction (3, 2, (uint16_t[]) { 0, 1, 1 }, 0, 1) || + test_auction (3, 2, (uint16_t[]) { 0, 1, 1 }, 2, 0) || + test_auction (3, 2, (uint16_t[]) { 0, 1, 1 }, 2, 1) || 0; GNUNET_CRYPTO_ecc_dlog_release (edc); |