[tor-commits] [sbws/master] Update tests to handle new result format and version

pastly at torproject.org pastly at torproject.org
Tue Jun 26 15:36:50 UTC 2018


commit c238a9387dbd44e79a6e7cd3436d456805e0966d
Author: Matt Traudt <sirmatt at ksu.edu>
Date:   Wed Jun 20 20:39:50 2018 -0400

    Update tests to handle new result format and version
---
 tests/unit/lib/data/results.txt | 4 ++--
 tests/unit/lib/test_results.py  | 4 +++-
 tests/unit/lib/test_v3bwfile.py | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/unit/lib/data/results.txt b/tests/unit/lib/data/results.txt
index d2005f6..359f213 100644
--- a/tests/unit/lib/data/results.txt
+++ b/tests/unit/lib/data/results.txt
@@ -1,2 +1,2 @@
-{"version": 3, "time": 1523887747, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "success", "rtts": [0.4596822261810303, 0.44872617721557617, 0.4563450813293457, 0.44872212409973145, 0.4561030864715576, 0.4765200614929199, 0.4495084285736084, 0.45711588859558105, 0.45520496368408203, 0.4635589122772217], "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "downloads": [{"amount": 590009, "duration": 6.1014368534088135}, {"amount": 590009, "duration": 8.391342878341675}, {"amount": 321663, "duration": 7.064587831497192}, {"amount": 321663, "duration": 8.266003131866455}, {"amount": 321663, "duration": 5.779450178146362}], "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s"}
-{"version": 3, "time": 1523974147, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "error-stream", "msg": "Something bad happened while measuring bandwidth", "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s"}
+{"version": 4, "time": 1523887747, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "success", "rtts": [0.4596822261810303, 0.44872617721557617, 0.4563450813293457, 0.44872212409973145, 0.4561030864715576, 0.4765200614929199, 0.4495084285736084, 0.45711588859558105, 0.45520496368408203, 0.4635589122772217], "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "downloads": [{"amount": 590009, "duration": 6.1014368534088135}, {"amount": 590009, "duration": 8.391342878341675}, {"amount": 321663, "duration": 7.064587831497192}, {"amount": 321663, "duration": 8.266003131866455}, {"amount": 321663, "duration": 5.779450178146362}], "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s", "relay_average_bandwidth": 1000000000}
+{"version": 4, "time": 1523974147, "circ": ["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"], "type": "error-stream", "msg": "Something bad happened while measuring bandwidth", "fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "scanner": "IDidntEditTheSBWSConfig", "dest_url": "http://y.z", "nickname": "A", "address": "111.111.111.111", "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s"}
diff --git a/tests/unit/lib/test_results.py b/tests/unit/lib/test_results.py
index 3d4770e..328d90a 100644
--- a/tests/unit/lib/test_results.py
+++ b/tests/unit/lib/test_results.py
@@ -103,7 +103,8 @@ def test_ResultSuccess_from_dict(time_mock):
     scanner_nick = 'sbwsscanner'
     nick = 'Mooooooo'
     relay_ip = '169.254.100.1'
-    relay = Result.Relay(fp1, nick, relay_ip, ed25519)
+    relay_average_bandwidth = 1 * 1024 * 1024
+    relay = Result.Relay(fp1, nick, relay_ip, ed25519, relay_average_bandwidth)
     rtts = [5, 25]
     downloads = [{'duration': 4, 'amount': 40}]
     r1 = ResultSuccess(rtts, downloads, relay, circ, dest_url, scanner_nick)
@@ -113,6 +114,7 @@ def test_ResultSuccess_from_dict(time_mock):
         'dest_url': dest_url, 'scanner': scanner_nick,
         'version': RESULT_VERSION, 'type': _ResultType.Success, 'time': t,
         'master_key_ed25519': ed25519,
+        'relay_average_bandwidth': relay_average_bandwidth,
     }
     r2 = Result.from_dict(d)
     assert isinstance(r1, ResultSuccess)
diff --git a/tests/unit/lib/test_v3bwfile.py b/tests/unit/lib/test_v3bwfile.py
index 2f4a631..bfe9d9b 100644
--- a/tests/unit/lib/test_v3bwfile.py
+++ b/tests/unit/lib/test_v3bwfile.py
@@ -78,7 +78,8 @@ RESULT_SUCCESS_DICT = {
         {"amount": 321663, "duration": 8.266003131866455},
         {"amount": 321663, "duration": 5.779450178146362}],
     "nickname": "A",
-    "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s"
+    "master_key_ed25519": "g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s",
+    "relay_average_bandwidth": 1 * 1024 * 1024,
 }
 RESULT_SUCCESS_STR = str(RESULT_SUCCESS_DICT)
 RESULT_ERROR_STREAM_STR = str(RESULT_ERROR_STREAM_DICT)





More information about the tor-commits mailing list