Commit 7d69bc7d authored by Matt Traudt's avatar Matt Traudt Committed by juga
Browse files

Fix tests that broke with new ed25519 stuff

parent 2c8212d2
...@@ -64,6 +64,7 @@ def dotsbws_error_result(empty_dotsbws_datadir): ...@@ -64,6 +64,7 @@ def dotsbws_error_result(empty_dotsbws_datadir):
''' '''
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'B' * 40 fp2 = 'B' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
nick = 'CowSayWhat' nick = 'CowSayWhat'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
...@@ -71,7 +72,7 @@ def dotsbws_error_result(empty_dotsbws_datadir): ...@@ -71,7 +72,7 @@ def dotsbws_error_result(empty_dotsbws_datadir):
scanner_nick = 'SBWSscanner' scanner_nick = 'SBWSscanner'
msg = 'UnitTest error message' msg = 'UnitTest error message'
t = time.time() 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) result = ResultError(relay, circ, server_ip, scanner_nick, t=t, msg=msg)
args = _PseudoArguments(directory=empty_dotsbws_datadir.name) args = _PseudoArguments(directory=empty_dotsbws_datadir.name)
conf = get_config(args) conf = get_config(args)
...@@ -87,6 +88,7 @@ def dotsbws_success_result(empty_dotsbws_datadir): ...@@ -87,6 +88,7 @@ def dotsbws_success_result(empty_dotsbws_datadir):
''' '''
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'B' * 40 fp2 = 'B' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
nick = 'CowSayWhat' nick = 'CowSayWhat'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
...@@ -95,7 +97,7 @@ def dotsbws_success_result(empty_dotsbws_datadir): ...@@ -95,7 +97,7 @@ def dotsbws_success_result(empty_dotsbws_datadir):
rtts = [4.242] rtts = [4.242]
downloads = [{'duration': 4, 'amount': 40*1024}] downloads = [{'duration': 4, 'amount': 40*1024}]
t = time.time() 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, result = ResultSuccess(rtts, downloads, relay, circ, server_ip,
scanner_nick, t=t) scanner_nick, t=t)
args = _PseudoArguments(directory=empty_dotsbws_datadir.name) args = _PseudoArguments(directory=empty_dotsbws_datadir.name)
...@@ -115,6 +117,7 @@ def dotsbws_success_result_one_relay(empty_dotsbws_datadir): ...@@ -115,6 +117,7 @@ def dotsbws_success_result_one_relay(empty_dotsbws_datadir):
dd = conf['paths']['datadir'] dd = conf['paths']['datadir']
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'B' * 40 fp2 = 'B' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
nick = 'CowSayWhat' nick = 'CowSayWhat'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
...@@ -123,7 +126,7 @@ def dotsbws_success_result_one_relay(empty_dotsbws_datadir): ...@@ -123,7 +126,7 @@ def dotsbws_success_result_one_relay(empty_dotsbws_datadir):
rtts = [5, 25] rtts = [5, 25]
downloads = [{'duration': 4, 'amount': 40*1024}] downloads = [{'duration': 4, 'amount': 40*1024}]
t = time.time() 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, result = ResultSuccess(rtts, downloads, relay, circ, server_ip,
scanner_nick, t=t) scanner_nick, t=t)
write_result_to_datadir(result, dd) write_result_to_datadir(result, dd)
...@@ -148,6 +151,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir): ...@@ -148,6 +151,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir):
dd = conf['paths']['datadir'] dd = conf['paths']['datadir']
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'C' * 40 fp2 = 'C' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
nick = 'CowSayWhat1' nick = 'CowSayWhat1'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
...@@ -156,7 +160,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir): ...@@ -156,7 +160,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir):
rtts = [5, 25] rtts = [5, 25]
downloads = [{'duration': 4, 'amount': 40*1024}] downloads = [{'duration': 4, 'amount': 40*1024}]
t = time.time() 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, result = ResultSuccess(rtts, downloads, relay, circ, server_ip,
scanner_nick, t=t) scanner_nick, t=t)
write_result_to_datadir(result, dd) write_result_to_datadir(result, dd)
...@@ -175,7 +179,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir): ...@@ -175,7 +179,7 @@ def dotsbws_success_result_two_relays(empty_dotsbws_datadir):
rtts = [50, 250] rtts = [50, 250]
downloads = [{'duration': 4, 'amount': 400*1024}] downloads = [{'duration': 4, 'amount': 400*1024}]
t = time.time() 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, result = ResultSuccess(rtts, downloads, relay, circ, server_ip,
scanner_nick, t=t) scanner_nick, t=t)
write_result_to_datadir(result, dd) write_result_to_datadir(result, dd)
......
...@@ -184,7 +184,7 @@ def test_generate_single_relay_success_noscale( ...@@ -184,7 +184,7 @@ def test_generate_single_relay_success_noscale(
for r in results for dl in r.downloads] for r in results for dl in r.downloads]
speed = round(median(speeds)) speed = round(median(speeds))
rtt = round(median([round(r * 1000) for r in result.rtts])) 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, result.fingerprint, speed, result.nickname, rtt,
unixts_to_isodt_str(round(result.time))) unixts_to_isodt_str(round(result.time)))
bw_line = V3BWLine(result.fingerprint, speed, nick=result.nickname, bw_line = V3BWLine(result.fingerprint, speed, nick=result.nickname,
...@@ -255,6 +255,7 @@ def test_generate_two_relays_success_noscale( ...@@ -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_time = unixts_to_isodt_str(round(max([r.time for r in r1_results])))
r1_name = r1_results[0].nickname r1_name = r1_results[0].nickname
r1_fingerprint = r1_results[0].fingerprint r1_fingerprint = r1_results[0].fingerprint
r1_ed25519 = r1_results[0].ed25519_master_key
r1_speeds = [dl['amount'] / dl['duration'] / 1024 r1_speeds = [dl['amount'] / dl['duration'] / 1024
for r in r1_results for dl in r.downloads] for r in r1_results for dl in r.downloads]
r1_speed = round(median(r1_speeds)) r1_speed = round(median(r1_speeds))
...@@ -265,11 +266,11 @@ def test_generate_two_relays_success_noscale( ...@@ -265,11 +266,11 @@ def test_generate_two_relays_success_noscale(
success=2, error_circ=0, error_misc=0, success=2, error_circ=0, error_misc=0,
error_stream=0) error_stream=0)
assert stdout_lines[1 + NUM_LINES_HEADER_V110] + '\n' == str(bw_line) 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_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_time = unixts_to_isodt_str(round(max([r.time for r in r2_results])))
r2_name = r2_results[0].nickname r2_name = r2_results[0].nickname
r2_fingerprint = r2_results[0].fingerprint r2_fingerprint = r2_results[0].fingerprint
r2_ed25519 = r2_results[0].ed25519_master_key
r2_speeds = [dl['amount'] / dl['duration'] / 1024 r2_speeds = [dl['amount'] / dl['duration'] / 1024
for r in r2_results for dl in r.downloads] for r in r2_results for dl in r.downloads]
r2_speed = round(median(r2_speeds)) r2_speed = round(median(r2_speeds))
......
...@@ -25,7 +25,7 @@ def init_directory(dname): ...@@ -25,7 +25,7 @@ def init_directory(dname):
def add_single_stale_result(dname): def add_single_stale_result(dname):
r = ResultError( r = ResultError(
Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1'), Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1', 'ed25519key'),
['DEADBEEF1111', 'BEADDEEF2222'], ['DEADBEEF1111', 'BEADDEEF2222'],
'127.0.1.1', 'SBWSscanner', t=19950216) '127.0.1.1', 'SBWSscanner', t=19950216)
dd = os.path.join(str(dname), 'datadir') dd = os.path.join(str(dname), 'datadir')
...@@ -35,7 +35,7 @@ def add_single_stale_result(dname): ...@@ -35,7 +35,7 @@ def add_single_stale_result(dname):
def add_single_fresh_result(dname): def add_single_fresh_result(dname):
r = ResultError( r = ResultError(
Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1'), Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1', 'ed25519key'),
['DEADBEEF1111', 'BEADDEEF2222'], ['DEADBEEF1111', 'BEADDEEF2222'],
'127.0.1.1', 'SBWSscanner', t=time.time()) '127.0.1.1', 'SBWSscanner', t=time.time())
dd = os.path.join(str(dname), 'datadir') dd = os.path.join(str(dname), 'datadir')
...@@ -45,12 +45,12 @@ def add_single_fresh_result(dname): ...@@ -45,12 +45,12 @@ def add_single_fresh_result(dname):
def add_two_fresh_results(dname, t): def add_two_fresh_results(dname, t):
r1 = ResultError( r1 = ResultError(
Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1'), Result.Relay('DEADBEEF1111', 'CowSayWhat', '127.0.0.1', 'ed25519key'),
['DEADBEEF1111', 'BEADDEEF2222'], ['DEADBEEF1111', 'BEADDEEF2222'],
'127.0.1.1', 'SBWSscanner', t=t) '127.0.1.1', 'SBWSscanner', t=t)
r2 = ResultSuccess( r2 = ResultSuccess(
[1, 2, 3], [{'amount': 100, 'duration': 1}], [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'], ['DEADBEEF1111', 'BEADDEEF2222'],
'127.0.1.1', 'SBWSscanner', t=t) '127.0.1.1', 'SBWSscanner', t=t)
dd = os.path.join(str(dname), 'datadir') dd = os.path.join(str(dname), 'datadir')
......
...@@ -19,12 +19,13 @@ def test_Result(time_mock): ...@@ -19,12 +19,13 @@ def test_Result(time_mock):
time_mock.side_effect = monotonic_time() time_mock.side_effect = monotonic_time()
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' 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) r = Result(relay, circ, dest_url, scanner_nick)
try: try:
str(r) str(r)
...@@ -64,12 +65,13 @@ def test_ResultSuccess(time_mock): ...@@ -64,12 +65,13 @@ def test_ResultSuccess(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
rtts = [5, 25] rtts = [5, 25]
downloads = [{'duration': 4, 'amount': 40}] downloads = [{'duration': 4, 'amount': 40}]
r1 = ResultSuccess(rtts, downloads, relay, circ, dest_url, scanner_nick) r1 = ResultSuccess(rtts, downloads, relay, circ, dest_url, scanner_nick)
...@@ -95,12 +97,13 @@ def test_ResultSuccess_from_dict(time_mock): ...@@ -95,12 +97,13 @@ def test_ResultSuccess_from_dict(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
rtts = [5, 25] rtts = [5, 25]
downloads = [{'duration': 4, 'amount': 40}] downloads = [{'duration': 4, 'amount': 40}]
r1 = ResultSuccess(rtts, downloads, relay, circ, dest_url, scanner_nick) r1 = ResultSuccess(rtts, downloads, relay, circ, dest_url, scanner_nick)
...@@ -109,6 +112,7 @@ def test_ResultSuccess_from_dict(time_mock): ...@@ -109,6 +112,7 @@ def test_ResultSuccess_from_dict(time_mock):
'nickname': nick, 'address': relay_ip, 'circ': circ, 'nickname': nick, 'address': relay_ip, 'circ': circ,
'dest_url': dest_url, 'scanner': scanner_nick, 'dest_url': dest_url, 'scanner': scanner_nick,
'version': RESULT_VERSION, 'type': _ResultType.Success, 'time': t, 'version': RESULT_VERSION, 'type': _ResultType.Success, 'time': t,
'ed25519_master_key': ed25519,
} }
r2 = Result.from_dict(d) r2 = Result.from_dict(d)
assert isinstance(r1, ResultSuccess) assert isinstance(r1, ResultSuccess)
...@@ -122,12 +126,13 @@ def test_ResultError(time_mock): ...@@ -122,12 +126,13 @@ def test_ResultError(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg)
r2 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg, t=t) r2 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg, t=t)
...@@ -150,12 +155,13 @@ def test_ResultError_from_dict(time_mock): ...@@ -150,12 +155,13 @@ def test_ResultError_from_dict(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultError(relay, circ, dest_url, scanner_nick, msg=msg)
d = { d = {
...@@ -163,6 +169,7 @@ def test_ResultError_from_dict(time_mock): ...@@ -163,6 +169,7 @@ def test_ResultError_from_dict(time_mock):
'nickname': nick, 'address': relay_ip, 'circ': circ, 'nickname': nick, 'address': relay_ip, 'circ': circ,
'dest_url': dest_url, 'scanner': scanner_nick, 'dest_url': dest_url, 'scanner': scanner_nick,
'version': RESULT_VERSION, 'type': _ResultType.Error, 'time': t, 'version': RESULT_VERSION, 'type': _ResultType.Error, 'time': t,
'ed25519_master_key': ed25519,
} }
r2 = Result.from_dict(d) r2 = Result.from_dict(d)
assert isinstance(r1, ResultError) assert isinstance(r1, ResultError)
...@@ -176,12 +183,13 @@ def test_ResultErrorCircuit(time_mock): ...@@ -176,12 +183,13 @@ def test_ResultErrorCircuit(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultErrorCircuit(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultErrorCircuit(relay, circ, dest_url, scanner_nick, msg=msg)
r2 = 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): ...@@ -205,12 +213,13 @@ def test_ResultErrorCircuit_from_dict(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultErrorCircuit(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultErrorCircuit(relay, circ, dest_url, scanner_nick, msg=msg)
d = { d = {
...@@ -218,6 +227,7 @@ def test_ResultErrorCircuit_from_dict(time_mock): ...@@ -218,6 +227,7 @@ def test_ResultErrorCircuit_from_dict(time_mock):
'nickname': nick, 'address': relay_ip, 'circ': circ, 'nickname': nick, 'address': relay_ip, 'circ': circ,
'dest_url': dest_url, 'scanner': scanner_nick, 'dest_url': dest_url, 'scanner': scanner_nick,
'version': RESULT_VERSION, 'type': _ResultType.ErrorCircuit, 'time': t, 'version': RESULT_VERSION, 'type': _ResultType.ErrorCircuit, 'time': t,
'ed25519_master_key': ed25519,
} }
r2 = Result.from_dict(d) r2 = Result.from_dict(d)
assert isinstance(r1, ResultErrorCircuit) assert isinstance(r1, ResultErrorCircuit)
...@@ -231,12 +241,13 @@ def test_ResultErrorStream(time_mock): ...@@ -231,12 +241,13 @@ def test_ResultErrorStream(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultErrorStream(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultErrorStream(relay, circ, dest_url, scanner_nick, msg=msg)
r2 = 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): ...@@ -260,12 +271,13 @@ def test_ResultErrorStream_from_dict(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultErrorStream(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultErrorStream(relay, circ, dest_url, scanner_nick, msg=msg)
d = { d = {
...@@ -273,6 +285,7 @@ def test_ResultErrorStream_from_dict(time_mock): ...@@ -273,6 +285,7 @@ def test_ResultErrorStream_from_dict(time_mock):
'nickname': nick, 'address': relay_ip, 'circ': circ, 'nickname': nick, 'address': relay_ip, 'circ': circ,
'dest_url': dest_url, 'scanner': scanner_nick, 'dest_url': dest_url, 'scanner': scanner_nick,
'version': RESULT_VERSION, 'type': _ResultType.ErrorStream, 'time': t, 'version': RESULT_VERSION, 'type': _ResultType.ErrorStream, 'time': t,
'ed25519_master_key': ed25519,
} }
r2 = Result.from_dict(d) r2 = Result.from_dict(d)
assert isinstance(r1, ResultErrorStream) assert isinstance(r1, ResultErrorStream)
...@@ -286,12 +299,13 @@ def test_ResultErrorAuth(time_mock): ...@@ -286,12 +299,13 @@ def test_ResultErrorAuth(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultErrorAuth(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultErrorAuth(relay, circ, dest_url, scanner_nick, msg=msg)
r2 = 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): ...@@ -315,12 +329,13 @@ def test_ResultErrorAuth_from_dict(time_mock):
time_mock.side_effect = monotonic_time(start=t) time_mock.side_effect = monotonic_time(start=t)
fp1 = 'A' * 40 fp1 = 'A' * 40
fp2 = 'Z' * 40 fp2 = 'Z' * 40
ed25519 = 'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
circ = [fp1, fp2] circ = [fp1, fp2]
dest_url = 'http://example.com/sbws.bin' dest_url = 'http://example.com/sbws.bin'
scanner_nick = 'sbwsscanner' scanner_nick = 'sbwsscanner'
nick = 'Mooooooo' nick = 'Mooooooo'
relay_ip = '169.254.100.1' relay_ip = '169.254.100.1'
relay = Result.Relay(fp1, nick, relay_ip) relay = Result.Relay(fp1, nick, relay_ip, ed25519)
msg = 'aaaaayyyyyy bb' msg = 'aaaaayyyyyy bb'
r1 = ResultErrorAuth(relay, circ, dest_url, scanner_nick, msg=msg) r1 = ResultErrorAuth(relay, circ, dest_url, scanner_nick, msg=msg)
d = { d = {
...@@ -328,6 +343,7 @@ def test_ResultErrorAuth_from_dict(time_mock): ...@@ -328,6 +343,7 @@ def test_ResultErrorAuth_from_dict(time_mock):
'nickname': nick, 'address': relay_ip, 'circ': circ, 'nickname': nick, 'address': relay_ip, 'circ': circ,
'dest_url': dest_url, 'scanner': scanner_nick, 'dest_url': dest_url, 'scanner': scanner_nick,
'version': RESULT_VERSION, 'type': _ResultType.ErrorAuth, 'time': t, 'version': RESULT_VERSION, 'type': _ResultType.ErrorAuth, 'time': t,
'ed25519_master_key': ed25519,
} }
r2 = Result.from_dict(d) r2 = Result.from_dict(d)
assert isinstance(r1, ResultErrorAuth) assert isinstance(r1, ResultErrorAuth)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment