Agent: Fix maximum_depth_reached()
This commit is contained in:
parent
526139bef1
commit
4c795343d0
|
@ -176,7 +176,7 @@ class AutomatedMaster(IMaster):
|
|||
current_depth = self._current_depth if self._current_depth is not None else 0
|
||||
logger.info(f"Current depth is {current_depth}")
|
||||
|
||||
if maximum_depth_reached(config.propagation.maximum_depth, current_depth):
|
||||
if not maximum_depth_reached(config.propagation.maximum_depth, current_depth):
|
||||
self._propagator.propagate(config.propagation, current_depth, self._servers, self._stop)
|
||||
else:
|
||||
logger.info("Skipping propagation: maximum depth reached")
|
||||
|
|
|
@ -189,7 +189,7 @@ class InfectionMonkey:
|
|||
client_disconnect_timeout=config.keep_tunnel_open_time,
|
||||
)
|
||||
|
||||
if maximum_depth_reached(config.propagation.maximum_depth, self._current_depth):
|
||||
if not maximum_depth_reached(config.propagation.maximum_depth, self._current_depth):
|
||||
self._relay.start()
|
||||
|
||||
StateTelem(is_done=False, version=get_version()).send()
|
||||
|
|
|
@ -1,2 +1,10 @@
|
|||
def maximum_depth_reached(maximum_depth: int, current_depth: int) -> bool:
|
||||
return maximum_depth > current_depth
|
||||
"""
|
||||
Return whether or not the current depth has eclipsed the maximum depth.
|
||||
Values are nonnegative. Depth should increase from zero.
|
||||
|
||||
:param maximum_depth: The maximum depth.
|
||||
:param current_depth: The current depth.
|
||||
:return: True if the current depth has reached the maximum depth, otherwise False.
|
||||
"""
|
||||
return current_depth >= maximum_depth
|
||||
|
|
|
@ -5,18 +5,18 @@ def test_maximum_depth_reached__current_less_than_max():
|
|||
maximum_depth = 2
|
||||
current_depth = 1
|
||||
|
||||
assert maximum_depth_reached(maximum_depth, current_depth) is True
|
||||
assert maximum_depth_reached(maximum_depth, current_depth) is False
|
||||
|
||||
|
||||
def test_maximum_depth_reached__current_greater_than_max():
|
||||
maximum_depth = 2
|
||||
current_depth = 3
|
||||
|
||||
assert maximum_depth_reached(maximum_depth, current_depth) is False
|
||||
assert maximum_depth_reached(maximum_depth, current_depth) is True
|
||||
|
||||
|
||||
def test_maximum_depth_reached__current_equal_to_max():
|
||||
maximum_depth = 2
|
||||
current_depth = maximum_depth
|
||||
|
||||
assert maximum_depth_reached(maximum_depth, current_depth) is False
|
||||
assert maximum_depth_reached(maximum_depth, current_depth) is True
|
||||
|
|
Loading…
Reference in New Issue