From 9d80e96c501280518d271e04ac3a90d2ab2df0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois?= Date: Thu, 5 Dec 2024 16:04:46 +0100 Subject: [PATCH 1/2] allow to set build directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-François --- massa_test_framework/compile.py | 15 +++++++++++++-- massa_test_framework/server.py | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/massa_test_framework/compile.py b/massa_test_framework/compile.py index d3fd4f8..1a784f6 100644 --- a/massa_test_framework/compile.py +++ b/massa_test_framework/compile.py @@ -83,7 +83,7 @@ def __init__(self, server: Server, compile_opts: CompileOpts): self.server = server self.compile_opts = compile_opts - self._repo = "" + self._repo: Path = Path("") self._target = "" self._patches: Dict[str, bytes | str | Path | PatchConstant] = {} @@ -115,7 +115,18 @@ def compile(self) -> None: Raise: RuntimeError: if git clone return non 0, cargo build return non 0, patch cannot be applied """ - tmp_folder = self.server.mkdtemp(prefix="compile_massa_") + # build or rebuild into the predefined directory + if self.compile_opts.already_compiled is not None: + # assuming we are in compile it means me want to rebuild + # and reuse the same folder + # TODO: if the folder exists do a git pull instead of clone + # for now we assume the user just want to reuse he folder name + tmp_folder = self.compile_opts.already_compiled + if tmp_folder.exists(): + self.server.rmtree(str(tmp_folder)) + #self.server.mkdir(tmp_folder) + else: # use a temporary folder + tmp_folder = self.server.mkdtemp(prefix="compile_massa_") # print(self.compile_opts) # print(type(self.compile_opts)) cmd = ["git", "clone"] diff --git a/massa_test_framework/server.py b/massa_test_framework/server.py index 37efcd3..471535c 100644 --- a/massa_test_framework/server.py +++ b/massa_test_framework/server.py @@ -281,6 +281,11 @@ def remove(self, path: str) -> None: os.unlink(path) else: self.server.remove(str(path)) + def rmtree(self, path: str) -> None: + if self.server_opts.local: + shutil.rmtree(path) + else: + raise NotImplementedError("Not implemented for remote server") def stop(self, process): if self.server_opts.local: From 71208fedd8846fdc34b5f62ef64a3be412d5064b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois?= Date: Thu, 19 Dec 2024 16:18:19 +0100 Subject: [PATCH 2/2] add get_blockclique_block_by_slot api call support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-François --- massa_test_framework/massa_jsonrpc_api/api.py | 13 +++++++++++++ massa_test_framework/node.py | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/massa_test_framework/massa_jsonrpc_api/api.py b/massa_test_framework/massa_jsonrpc_api/api.py index e9f7200..df9ab5b 100644 --- a/massa_test_framework/massa_jsonrpc_api/api.py +++ b/massa_test_framework/massa_jsonrpc_api/api.py @@ -113,6 +113,19 @@ def get_stakers(): ) return headers, payload + @staticmethod + def get_blockclique_block_by_slot(period: int, thread: int): + headers = {"Content-type": "application/json"} + payload = json.dumps( + { + "jsonrpc": "2.0", + "method": "get_blockclique_block_by_slot", + "id": 0, + "params": [{"period": period, "thread": thread}], + } + ) + return headers, payload + # class Api: # def __init__(self, url) -> None: diff --git a/massa_test_framework/node.py b/massa_test_framework/node.py index 56d38a1..21b4c9d 100644 --- a/massa_test_framework/node.py +++ b/massa_test_framework/node.py @@ -422,6 +422,11 @@ def get_stakers(self): print("get_stakers", res, type(res)) return res + def get_blockclique_block_by_slot(self, period: int, thread: int): + res = self.pub_api2.get_blockclique_block_by_slot(period, thread) + print("get_blockclique_block_by_slot", res, type(res)) + return res + # API GRPC async def _public_grpc_call(