From e013015b1aa6835d56ebd8e7adf72c260afa3286 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Fri, 30 May 2025 14:43:56 +0200 Subject: [PATCH 1/2] Added helper method to Node class to encapsulate shared memory file path defaults. --- package/test_tools/__private/node.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/package/test_tools/__private/node.py b/package/test_tools/__private/node.py index 23cff866b..c7453e6b4 100644 --- a/package/test_tools/__private/node.py +++ b/package/test_tools/__private/node.py @@ -91,6 +91,16 @@ class Node(RunnableHandle[NodeProcess, NodeConfig, NodeArguments, Settings], Bas def directory(self) -> Path: return self.settings.ensured_working_directory + @property + def shared_file_path(self) -> Path: + shm_path = None + if self.config.shared_file_dir is not None: + shm_path = Path(str(self.config.shared_file_dir)) + else: + shm_path = self.directory / "state" / "mmapfiles" + + return shm_path / "shared_memory.bin" + def _get_settings(self) -> Settings: return self.settings @@ -570,7 +580,7 @@ class Node(RunnableHandle[NodeProcess, NodeConfig, NodeArguments, Settings], Bas def __remove_unneeded_files(self) -> None: unneeded_files_or_directories = [ - "blockchain/shared_memory.bin", + str(self.shared_file_path), "snapshot/", ] @@ -585,7 +595,7 @@ class Node(RunnableHandle[NodeProcess, NodeConfig, NodeArguments, Settings], Bas self.__remove(unneeded_file) def __register_rocksdb_data_to_remove(self, unneeded_files_or_directories: list[str]) -> None: - rocksdb_directory = self.directory.joinpath("blockchain/account-history-rocksdb-storage") + rocksdb_directory = self.directory.joinpath("state/rocksdb/account-history-rocksdb-storage") if not rocksdb_directory: return -- GitLab From 09d63b6f2937c0ac896abd0d4914266dd11e14c8 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Fri, 30 May 2025 16:27:18 +0200 Subject: [PATCH 2/2] RunnableNodeHandle extended by shared_file_path property --- .../handles/node_handles/runnable_node_handle.py | 5 +++++ 1 file changed, 5 insertions(+) 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 3c6ecd6ef..17c0c666c 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 @@ -52,6 +52,11 @@ class RunnableNodeHandle(NodeHandleBase): """Returns path to directory, where node runs and generates its files.""" return self.__implementation.directory + @property + def shared_file_path(self) -> Path: + """Returns path to directory, where node stores its shared memory file.""" + return self.__implementation.shared_file_path + def dump_config(self) -> NodeConfig: """Saves node's config to file and returns it as object. Requires that node is not running.""" return self.__implementation.dump_config() -- GitLab