commit d5659732d57089ec2325880e1ce38b997f50b620
Author: Matt Traudt <sirmatt(a)ksu.edu>
Date: Wed Jun 20 14:47:27 2018 -0400
Fixup MaxAdvertisedBandwidth test
---
tests/integration/core/test_scanner.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tests/integration/core/test_scanner.py b/tests/integration/core/test_scanner.py
index a9a467f..c1a8692 100644
--- a/tests/integration/core/test_scanner.py
+++ b/tests/integration/core/test_scanner.py
@@ -4,6 +4,7 @@ from sbws.util.config import get_config
from sbws.lib.relaylist import RelayList
from sbws.lib.destination import DestinationList
from sbws.lib.resultdump import ResultSuccess
+import logging
def assert_within(value, target, radius):
@@ -40,7 +41,8 @@ def get_everything_to_measure(dotsbws, cont, parser):
def test_measure_relay_with_maxadvertisedbandwidth(
- persistent_launch_tor, parser, persistent_empty_dotsbws):
+ persistent_launch_tor, parser, persistent_empty_dotsbws, caplog):
+ caplog.set_level(logging.DEBUG)
cont = persistent_launch_tor
dotsbws = persistent_empty_dotsbws.name
d = get_everything_to_measure(dotsbws, cont, parser)
@@ -57,10 +59,13 @@ def test_measure_relay_with_maxadvertisedbandwidth(
result = result[0]
assert isinstance(result, ResultSuccess)
one_mbyte = 1 * 1024 * 1024
- allowed_error = 5 # bytes per second
dls = result.downloads
for dl in dls:
- assert_within(dl['amount'] / dl['duration'], one_mbyte, allowed_error)
+ # This relay has MaxAdvertisedBandwidth set, but should not be limited
+ # to just 1 Mbyte. Assume and assert that all downloads where at least
+ # more than 10% faster than 1 MBps
+ assert dl['amount'] / dl['duration'] > one_mbyte * 1.1
+ assert result.relay_average_bandwidth == one_mbyte
def test_measure_relay_with_relaybandwidthrate(