diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-03-07 12:04:45 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-03-16 14:38:29 -0400 |
commit | c86e77ac20997282ca007ac7347e9910f55f880e (patch) | |
tree | d5dfe0db52d6bf6b89a194bb72d70b97536129eb /src/test/test_consdiff.c | |
parent | e1418c09fc2609c4c43b0eebb6b6676139573a02 (diff) | |
download | tor-c86e77ac20997282ca007ac7347e9910f55f880e.tar.gz tor-c86e77ac20997282ca007ac7347e9910f55f880e.zip |
Cover two more failing cases with unit tests
Diffstat (limited to 'src/test/test_consdiff.c')
-rw-r--r-- | src/test/test_consdiff.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/test/test_consdiff.c b/src/test/test_consdiff.c index 00fba67b05..b511d94ec3 100644 --- a/src/test/test_consdiff.c +++ b/src/test/test_consdiff.c @@ -703,6 +703,17 @@ test_consdiff_apply_ed_diff(void *arg) smartlist_clear(diff); + /* Now it it inserts something, but has no terminator. */ + smartlist_add(diff, (char*)"0a"); + smartlist_add(diff, (char*)"hello"); + mock_clean_saved_logs(); + cons2 = apply_ed_diff(cons1, diff); + tt_ptr_op(NULL, OP_EQ, cons2); + expect_single_log_msg_containing("lines to be inserted that don't end with " + "a \".\"."); + + smartlist_clear(diff); + /* Test appending text, 'a'. */ smartlist_split_string(diff, "3a:U:O:.:0a:V:.", ":", 0, 0); cons2 = apply_ed_diff(cons1, diff); @@ -964,7 +975,22 @@ test_consdiff_apply_diff(void *arg) cons2 = consdiff_apply_diff(cons1, diff, &digests1); tt_ptr_op(NULL, OP_EQ, cons2); expect_log_msg_containing("resulting consensus doesn't match the " - "digest as found") + "digest as found"); + + /* Resulting consensus digest cannot be computed */ + smartlist_clear(diff); + smartlist_add(diff, (char*)"network-status-diff-version 1"); + smartlist_add(diff, (char*)"hash" + /* sha256 of cons1. */ + " C2199B6827514F39ED9B3F2E2E73735C6C5468FD636240BB454C526220DE702A" + /* bogus sha256. */ + " 3333333333333333333333333333333333333333333333333333333333333333"); + smartlist_add(diff, (char*)"1,2d"); // remove starting line + mock_clean_saved_logs(); + cons2 = consdiff_apply_diff(cons1, diff, &digests1); + tt_ptr_op(NULL, OP_EQ, cons2); + expect_log_msg_containing("Could not compute digests of the consensus " + "resulting from applying a consensus diff."); /* Very simple test, only to see that nothing errors. */ smartlist_clear(diff); |