commit 7d69bc7d78cac4734ebc27c9b998dce3a57f8e48 Author: Matt Traudt sirmatt@ksu.edu Date: Thu Jun 7 21:26:39 2018 -0400
Fix tests that broke with new ed25519 stuff --- tests/unit/conftest.py | 14 +++++++++----- tests/unit/core/test_generate.py | 5 +++-- tests/unit/core/test_stats.py | 8 ++++---- tests/unit/lib/test_results.py | 38 +++++++++++++++++++++++++++----------- 4 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 0701646..bb9f8e3 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -64,6 +64,7 @@ def dotsbws_error_result(empty_dotsbws_datadir): ''' fp1 = 'A' * 40 fp2 = 'B' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] nick = 'CowSayWhat' relay_ip = '169.254.100.1' @@ -71,7 +72,7 @@ def dotsbws_error_result(empty_dotsbws_datadir): scanner_nick = 'SBWSscanner' msg = 'UnitTest error message' t = time.time() - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) result = ResultError(relay, circ, server_ip, scanner_nick, t=t, msg=msg) args = _PseudoArguments(directory=empty_dotsbws_datadir.name) conf = get_config(args) @@ -87,6 +88,7 @@ def dotsbws_success_result(empty_dotsbws_datadir): ''' fp1 = 'A' * 40 fp2 = 'B' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] nick = 'CowSayWhat' relay_ip = '169.254.100.1' @@ -95,7 +97,7 @@ def dotsbws_success_result(empty_dotsbws_datadir): rtts = [4.242] downloads = [{'duration': 4, 'amount': 40*1024}] t = time.time() - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) result = ResultSuccess(rtts, downloads, relay, circ, server_ip, scanner_nick, t=t) args = _PseudoArguments(directory=empty_dotsbws_datadir.name) @@ -115,6 +117,7 @@ def dotsbws_success_result_one_relay(empty_dotsbws_datadir): dd = conf['paths']['datadir'] fp1 = 'A' * 40 fp2 = 'B' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] nick = 'CowSayWhat' relay_ip = '169.254.100.1' @@ -123,7 +126,7 @@ def dotsbws_success_result_one_relay(empty_dotsbws_datadir): rtts = [5, 25] downloads = [{'duration': 4, 'amount': 40*1024}] t = time.time() - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) result = ResultSuccess(rtts, downloads, relay, circ, server_ip, scanner_nick, t=t) write_result_to_datadir(result, dd) @@ -148,6 +151,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir): dd = conf['paths']['datadir'] fp1 = 'A' * 40 fp2 = 'C' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] nick = 'CowSayWhat1' relay_ip = '169.254.100.1' @@ -156,7 +160,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir): rtts = [5, 25] downloads = [{'duration': 4, 'amount': 40*1024}] t = time.time() - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) result = ResultSuccess(rtts, downloads, relay, circ, server_ip, scanner_nick, t=t) write_result_to_datadir(result, dd) @@ -175,7 +179,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir): rtts = [50, 250] downloads = [{'duration': 4, 'amount': 400*1024}] t = time.time() - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) result = ResultSuccess(rtts, downloads, relay, circ, server_ip, scanner_nick, t=t) write_result_to_datadir(result, dd) diff --git a/tests/unit/core/test_generate.py b/tests/unit/core/test_generate.py index e9b341c..5598a2a 100644 --- a/tests/unit/core/test_generate.py +++ b/tests/unit/core/test_generate.py @@ -184,7 +184,7 @@ def test_generate_single_relay_success_noscale( for r in results for dl in r.downloads] speed = round(median(speeds)) rtt = round(median([round(r * 1000) for r in result.rtts])) - bw_line = 'node_id=${} bw={} nick={} rtt={} time={}'.format( + bw_line = 'node_id=${} bw={} nick={} rtt={} time={} ed25519={}'.format( result.fingerprint, speed, result.nickname, rtt, unixts_to_isodt_str(round(result.time))) bw_line = V3BWLine(result.fingerprint, speed, nick=result.nickname, @@ -255,6 +255,7 @@ def test_generate_two_relays_success_noscale( r1_time = unixts_to_isodt_str(round(max([r.time for r in r1_results]))) r1_name = r1_results[0].nickname r1_fingerprint = r1_results[0].fingerprint + r1_ed25519 = r1_results[0].ed25519_master_key r1_speeds = [dl['amount'] / dl['duration'] / 1024 for r in r1_results for dl in r.downloads] r1_speed = round(median(r1_speeds)) @@ -265,11 +266,11 @@ def test_generate_two_relays_success_noscale( success=2, error_circ=0, error_misc=0, error_stream=0) assert stdout_lines[1 + NUM_LINES_HEADER_V110] + '\n' == str(bw_line) - r2_results = [r for r in results if r.fingerprint == 'B' * 40] r2_time = unixts_to_isodt_str(round(max([r.time for r in r2_results]))) r2_name = r2_results[0].nickname r2_fingerprint = r2_results[0].fingerprint + r2_ed25519 = r2_results[0].ed25519_master_key r2_speeds = [dl['amount'] / dl['duration'] / 1024 for r in r2_results for dl in r.downloads] r2_speed = round(median(r2_speeds)) diff --git a/tests/unit/core/test_stats.py b/tests/unit/core/test_stats.py index e77b0c4..9554b16 100644 --- a/tests/unit/core/test_stats.py +++ b/tests/unit/core/test_stats.py @@ -25,7 +25,7 @@ def init_directory(dname):
def add_single_stale_result(dname): r = ResultError( - Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1'), + Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1', 'ed25519key'), ['DEADBEEF1111', 'BEADDEEF2222'], '127.0.1.1', 'SBWSscanner', t=19950216) dd = os.path.join(str(dname), 'datadir') @@ -35,7 +35,7 @@ def add_single_stale_result(dname):
def add_single_fresh_result(dname): r = ResultError( - Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1'), + Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1', 'ed25519key'), ['DEADBEEF1111', 'BEADDEEF2222'], '127.0.1.1', 'SBWSscanner', t=time.time()) dd = os.path.join(str(dname), 'datadir') @@ -45,12 +45,12 @@ def add_single_fresh_result(dname):
def add_two_fresh_results(dname, t): r1 = ResultError( - Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1'), + Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1', 'ed25519key'), ['DEADBEEF1111', 'BEADDEEF2222'], '127.0.1.1', 'SBWSscanner', t=t) r2 = ResultSuccess( [1, 2, 3], [{'amount': 100, 'duration': 1}], - Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1'), + Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1', 'ed25519key'), ['DEADBEEF1111', 'BEADDEEF2222'], '127.0.1.1', 'SBWSscanner', t=t) dd = os.path.join(str(dname), 'datadir') diff --git a/tests/unit/lib/test_results.py b/tests/unit/lib/test_results.py index 449222e..010d505 100644 --- a/tests/unit/lib/test_results.py +++ b/tests/unit/lib/test_results.py @@ -19,12 +19,13 @@ def test_Result(time_mock): time_mock.side_effect = monotonic_time() fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) r = Result(relay, circ, dest_url, scanner_nick) try: str(r) @@ -64,12 +65,13 @@ def test_ResultSuccess(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) rtts = [5, 25] downloads = [{'duration': 4, 'amount': 40}] r1 = ResultSuccess(rtts, downloads, relay, circ, dest_url, scanner_nick) @@ -95,12 +97,13 @@ def test_ResultSuccess_from_dict(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) rtts = [5, 25] downloads = [{'duration': 4, 'amount': 40}] r1 = ResultSuccess(rtts, downloads, relay, circ, dest_url, scanner_nick) @@ -109,6 +112,7 @@ def test_ResultSuccess_from_dict(time_mock): 'nickname': nick, 'address': relay_ip, 'circ': circ, 'dest_url': dest_url, 'scanner': scanner_nick, 'version': RESULT_VERSION, 'type': _ResultType.Success, 'time': t, + 'ed25519_master_key': ed25519, } r2 = Result.from_dict(d) assert isinstance(r1, ResultSuccess) @@ -122,12 +126,13 @@ def test_ResultError(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg) r2 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg, t=t) @@ -150,12 +155,13 @@ def test_ResultError_from_dict(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg) d = { @@ -163,6 +169,7 @@ def test_ResultError_from_dict(time_mock): 'nickname': nick, 'address': relay_ip, 'circ': circ, 'dest_url': dest_url, 'scanner': scanner_nick, 'version': RESULT_VERSION, 'type': _ResultType.Error, 'time': t, + 'ed25519_master_key': ed25519, } r2 = Result.from_dict(d) assert isinstance(r1, ResultError) @@ -176,12 +183,13 @@ def test_ResultErrorCircuit(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultErrorCircuit(relay, circ, dest_url, scanner_nick, msg=msg) r2 = ResultErrorCircuit(relay, circ, dest_url, scanner_nick, msg=msg, @@ -205,12 +213,13 @@ def test_ResultErrorCircuit_from_dict(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultErrorCircuit(relay, circ, dest_url, scanner_nick, msg=msg) d = { @@ -218,6 +227,7 @@ def test_ResultErrorCircuit_from_dict(time_mock): 'nickname': nick, 'address': relay_ip, 'circ': circ, 'dest_url': dest_url, 'scanner': scanner_nick, 'version': RESULT_VERSION, 'type': _ResultType.ErrorCircuit, 'time': t, + 'ed25519_master_key': ed25519, } r2 = Result.from_dict(d) assert isinstance(r1, ResultErrorCircuit) @@ -231,12 +241,13 @@ def test_ResultErrorStream(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultErrorStream(relay, circ, dest_url, scanner_nick, msg=msg) r2 = ResultErrorStream(relay, circ, dest_url, scanner_nick, msg=msg, @@ -260,12 +271,13 @@ def test_ResultErrorStream_from_dict(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultErrorStream(relay, circ, dest_url, scanner_nick, msg=msg) d = { @@ -273,6 +285,7 @@ def test_ResultErrorStream_from_dict(time_mock): 'nickname': nick, 'address': relay_ip, 'circ': circ, 'dest_url': dest_url, 'scanner': scanner_nick, 'version': RESULT_VERSION, 'type': _ResultType.ErrorStream, 'time': t, + 'ed25519_master_key': ed25519, } r2 = Result.from_dict(d) assert isinstance(r1, ResultErrorStream) @@ -286,12 +299,13 @@ def test_ResultErrorAuth(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultErrorAuth(relay, circ, dest_url, scanner_nick, msg=msg) r2 = ResultErrorAuth(relay, circ, dest_url, scanner_nick, msg=msg, @@ -315,12 +329,13 @@ def test_ResultErrorAuth_from_dict(time_mock): time_mock.side_effect = monotonic_time(start=t) fp1 = 'A' * 40 fp2 = 'Z' * 40 + ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s' circ = [fp1, fp2] dest_url = 'http://example.com/sbws.bin' scanner_nick = 'sbwsscanner' nick = 'Mooooooo' relay_ip = '169.254.100.1' - relay = Result.Relay(fp1, nick, relay_ip) + relay = Result.Relay(fp1, nick, relay_ip, ed25519) msg = 'aaaaayyyyyy bb' r1 = ResultErrorAuth(relay, circ, dest_url, scanner_nick, msg=msg) d = { @@ -328,6 +343,7 @@ def test_ResultErrorAuth_from_dict(time_mock): 'nickname': nick, 'address': relay_ip, 'circ': circ, 'dest_url': dest_url, 'scanner': scanner_nick, 'version': RESULT_VERSION, 'type': _ResultType.ErrorAuth, 'time': t, + 'ed25519_master_key': ed25519, } r2 = Result.from_dict(d) assert isinstance(r1, ResultErrorAuth)
tor-commits@lists.torproject.org