[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] Add forgotten "$" at the beginning of node_id value



commit a9b0f03cf112472ef9597b1eeeff4785223dc417
Author: juga0 <juga@xxxxxxxxxx>
Date:   Thu Jun 14 12:22:16 2018 +0000

    Add forgotten "$" at the beginning of node_id value
---
 sbws/lib/v3bwfile.py             |  3 ++-
 tests/unit/core/test_generate.py | 14 ++++++++------
 tests/unit/lib/data/v3bw.txt     |  2 +-
 tests/unit/lib/test_v3bwfile.py  |  2 +-
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 7019be2..c6ba9af 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -253,6 +253,7 @@ class V3BWLine(object):
     def __init__(self, node_id, bw, **kwargs):
         assert isinstance(node_id, str)
         assert isinstance(bw, int)
+        assert node_id.startswith('$')
         self.node_id = node_id
         self.bw = bw
         [setattr(self, k, v) for k, v in kwargs.items()
@@ -332,7 +333,7 @@ class V3BWLine(object):
     def from_results(cls, results):
         success_results = [r for r in results if isinstance(r, ResultSuccess)]
         # log.debug('len(success_results) %s', len(success_results))
-        node_id = results[0].fingerprint
+        node_id = '$' + results[0].fingerprint
         bw = cls.bw_from_results(success_results)
         kwargs = dict()
         kwargs['nick'] = results[0].nickname
diff --git a/tests/unit/core/test_generate.py b/tests/unit/core/test_generate.py
index ad1fff2..4dff161 100644
--- a/tests/unit/core/test_generate.py
+++ b/tests/unit/core/test_generate.py
@@ -116,7 +116,8 @@ def test_generate_single_success_noscale(dotsbws_success_result, caplog,
     bw = round(median([dl['amount'] / dl['duration'] / 1024
                        for dl in result.downloads]))
     rtt = median([round(r * 1000) for r in result.rtts])
-    bw_line = V3BWLine(result.fingerprint, bw, nick=result.nickname, rtt=rtt,
+    bw_line = V3BWLine('$' + result.fingerprint, bw, nick=result.nickname,
+                       rtt=rtt,
                        time=unixts_to_isodt_str(round(result.time)),
                        master_key_ed25519=result.master_key_ed25519,
                        success=1, error_circ=0, error_misc=0,
@@ -149,7 +150,8 @@ def test_generate_single_success_scale(dotsbws_success_result, parser,
 
     bw = 7500
     rtt = median([round(r * 1000) for r in result.rtts])
-    bw_line = V3BWLine(result.fingerprint, bw, nick=result.nickname, rtt=rtt,
+    bw_line = V3BWLine('$' + result.fingerprint, bw, nick=result.nickname,
+                       rtt=rtt,
                        time=unixts_to_isodt_str(round(result.time)),
                        master_key_ed25519=result.master_key_ed25519,
                        success=1, error_circ=0, error_misc=0,
@@ -184,7 +186,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 = V3BWLine(result.fingerprint, speed, nick=result.nickname,
+    bw_line = V3BWLine('$' + result.fingerprint, speed, nick=result.nickname,
                        rtt=rtt, master_key_ed25519=result.master_key_ed25519,
                        time=unixts_to_isodt_str(round(result.time)),
                        success=2, error_circ=0, error_misc=0,
@@ -217,7 +219,7 @@ def test_generate_single_relay_success_scale(
 
     speed = 7500
     rtt = round(median([round(r * 1000) for r in result.rtts]))
-    bw_line = V3BWLine(result.fingerprint, speed, nick=result.nickname,
+    bw_line = V3BWLine('$' + result.fingerprint, speed, nick=result.nickname,
                        rtt=rtt,
                        master_key_ed25519=result.master_key_ed25519,
                        time=unixts_to_isodt_str(round(result.time)),
@@ -252,7 +254,7 @@ def test_generate_two_relays_success_noscale(
     r1_results = [r for r in results if r.fingerprint == 'A' * 40]
     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_fingerprint = '$' + r1_results[0].fingerprint
     r1_ed25519 = r1_results[0].master_key_ed25519
     r1_speeds = [dl['amount'] / dl['duration'] / 1024
                  for r in r1_results for dl in r.downloads]
@@ -268,7 +270,7 @@ def test_generate_two_relays_success_noscale(
     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_fingerprint = '$' + r2_results[0].fingerprint
     r2_ed25519 = r2_results[0].master_key_ed25519
     r2_speeds = [dl['amount'] / dl['duration'] / 1024
                  for r in r2_results for dl in r.downloads]
diff --git a/tests/unit/lib/data/v3bw.txt b/tests/unit/lib/data/v3bw.txt
index 4252137..debbe5e 100644
--- a/tests/unit/lib/data/v3bw.txt
+++ b/tests/unit/lib/data/v3bw.txt
@@ -7,4 +7,4 @@ latest_bandwidth=2018-04-17T14:09:07
 software=sbws
 software_version=0.4.1-dev
 ====
-bw=54 error_circ=0 error_misc=0 error_stream=1 master_key_ed25519=g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s nick=A node_id=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA rtt=456 success=1 time=2018-04-17T14:09:07
+bw=54 error_circ=0 error_misc=0 error_stream=1 master_key_ed25519=g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s nick=A node_id=$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA rtt=456 success=1 time=2018-04-17T14:09:07
diff --git a/tests/unit/lib/test_v3bwfile.py b/tests/unit/lib/test_v3bwfile.py
index 750ab63..ca47a2b 100644
--- a/tests/unit/lib/test_v3bwfile.py
+++ b/tests/unit/lib/test_v3bwfile.py
@@ -37,7 +37,7 @@ header_extra_str = LINE_SEP.join(header_extra_ls) + LINE_SEP
 bwl_str = "bw=54 error_circ=0 error_misc=0 error_stream=1 " \
     "master_key_ed25519=g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s " \
     "nick=A " \
-    "node_id=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA rtt=456 success=1 " \
+    "node_id=$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA rtt=456 success=1 " \
     "time=2018-04-17T14:09:07\n"
 
 v3bw_str = header_extra_str + bwl_str



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits