diff --git a/package/test_tools/__private/node.py b/package/test_tools/__private/node.py index b6dfcbef57e438e5628b97188bac43b6df31562a..01e6f9dca29f0292a3b18b04a42d50d3c1c25906 100644 --- a/package/test_tools/__private/node.py +++ b/package/test_tools/__private/node.py @@ -67,6 +67,10 @@ class Node(RunnableHandle[NodeProcess, NodeConfig, NodeArguments, Settings], Bas self.__wallets: list[Wallet] = [] + # Store last run parameters for restart() to inherit + self._last_timeout: float = self.DEFAULT_WAIT_FOR_LIVE_TIMEOUT + self._last_max_retries: int = 1 + self.__is_testnet: bool | None = None @property @@ -270,6 +274,10 @@ class Node(RunnableHandle[NodeProcess, NodeConfig, NodeArguments, Settings], Bas is already defined, its value will be overwritten with one provided by this parameter. """ + # Store parameters for restart() to inherit + self._last_timeout = timeout + self._last_max_retries = max_retries + # This pylint warning is right, but this refactor has low priority. Will be done later... for attempt in range(max_retries): try: @@ -566,18 +574,18 @@ class Node(RunnableHandle[NodeProcess, NodeConfig, NodeArguments, Settings], Bas def restart( self, wait_for_live: bool = True, - timeout: float = DEFAULT_WAIT_FOR_LIVE_TIMEOUT, + timeout: float | None = None, time_control: TimeControl | None = None, alternate_chain_specs: AlternateChainSpecs | None = None, - max_retries: int = 1, + max_retries: int | None = None, ) -> None: self.close() self.run( wait_for_live=wait_for_live, - timeout=timeout, + timeout=timeout if timeout is not None else self._last_timeout, time_control=time_control, alternate_chain_specs=alternate_chain_specs, - max_retries=max_retries, + max_retries=max_retries if max_retries is not None else self._last_max_retries, ) def __remove_files(self) -> None: diff --git a/package/test_tools/__private/user_handles/handles/node_handles/runnable_node_handle.py b/package/test_tools/__private/user_handles/handles/node_handles/runnable_node_handle.py index 0f818df835feeef373258a8c305c48a79abc588b..8ffbd82bef4d702d8c745bb3d5d3652787761532 100644 --- a/package/test_tools/__private/user_handles/handles/node_handles/runnable_node_handle.py +++ b/package/test_tools/__private/user_handles/handles/node_handles/runnable_node_handle.py @@ -156,10 +156,10 @@ class RunnableNodeHandle(NodeHandleBase): def restart( self, wait_for_live: bool = True, - timeout: float = DEFAULT_WAIT_FOR_LIVE_TIMEOUT, + timeout: float | None = None, time_control: TimeControl | None = None, alternate_chain_specs: AlternateChainSpecs | None = None, - max_retries: int = 1, + max_retries: int | None = None, ) -> None: """ Stops node and immediately starts it again. Whole restart is performed synchronously. @@ -170,13 +170,13 @@ class RunnableNodeHandle(NodeHandleBase): :param wait_for_live: Blocks program execution until node starts to generate or receive blocks. :param timeout: If `wait_for_live` is set to True, this parameter sets how long waiting can take. When timeout - is reached, `TimeoutError` exception is thrown. Expressed in seconds. + is reached, `TimeoutError` exception is thrown. Expressed in seconds. If None, inherits from last run(). :param time_control: See parameter ``time_control`` in :func:`run`. :param alternate_chain_specs: See parameter ``alternate_chain_specs`` in :func:`run`. :param max_retries: - See parameter ``max_retries`` in :func:`run`. + See parameter ``max_retries`` in :func:`run`. If None, inherits from last run(). """ return self.__implementation.restart( wait_for_live=wait_for_live,