diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-04-25 14:52:40 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-27 21:40:46 -0400 |
commit | a1172b6774bc95ff951ac58051ea42bc0a62e32b (patch) | |
tree | 2c240b577ee2fb98768a115f7c9089a64fc6f0ef /src/test/test_consdiffmgr.c | |
parent | 9e081a44a9ca3b9952b536cd0317538263d59f9b (diff) | |
download | tor-a1172b6774bc95ff951ac58051ea42bc0a62e32b.tar.gz tor-a1172b6774bc95ff951ac58051ea42bc0a62e32b.zip |
Store archived consensuses compressed on disk.
I'm just using gzip compression now, for performance.
Diffstat (limited to 'src/test/test_consdiffmgr.c')
-rw-r--r-- | src/test/test_consdiffmgr.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/test/test_consdiffmgr.c b/src/test/test_consdiffmgr.c index 2fb7dd2dfb..b3fa3886f1 100644 --- a/src/test/test_consdiffmgr.c +++ b/src/test/test_consdiffmgr.c @@ -149,7 +149,6 @@ lookup_apply_and_verify_diff(consensus_flavor_t flav, const char *str1, const char *str2) { - char *diff_string = NULL; consensus_cache_entry_t *ent = NULL; consdiff_status_t status = lookup_diff_from(&ent, flav, str1); if (ent == NULL || status != CONSDIFF_AVAILABLE) @@ -157,12 +156,10 @@ lookup_apply_and_verify_diff(consensus_flavor_t flav, consensus_cache_entry_incref(ent); size_t size; - const uint8_t *body; - int r = consensus_cache_entry_get_body(ent, &body, &size); - if (r == 0) - diff_string = tor_memdup_nulterm(body, size); + char *diff_string = NULL; + int r = uncompress_or_copy(&diff_string, &size, ent); consensus_cache_entry_decref(ent); - if (diff_string == NULL) + if (diff_string == NULL || r < 0) return -1; char *applied = consensus_diff_apply(str1, diff_string); @@ -266,6 +263,8 @@ test_consdiffmgr_add(void *arg) (void) arg; time_t now = approx_time(); + char *body = NULL; + consensus_cache_entry_t *ent = NULL; networkstatus_t *ns_tmp = fake_ns_new(FLAV_NS, now); const char *dummy = "foo"; @@ -306,8 +305,7 @@ test_consdiffmgr_add(void *arg) tt_assert(ent); consensus_cache_entry_incref(ent); size_t s; - const uint8_t *body; - r = consensus_cache_entry_get_body(ent, &body, &s); + r = uncompress_or_copy(&body, &s, ent); tt_int_op(r, OP_EQ, 0); tt_int_op(s, OP_EQ, 4); tt_mem_op(body, OP_EQ, "quux", 4); @@ -320,6 +318,7 @@ test_consdiffmgr_add(void *arg) networkstatus_vote_free(ns_tmp); teardown_capture_of_logs(); consensus_cache_entry_decref(ent); + tor_free(body); } static void |