From 0f1ad9a15067dfeac453bea6a86542f428db8b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois?= Date: Thu, 21 Dec 2023 16:16:42 +0100 Subject: [PATCH] Add execute_read_only_call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-François --- massa_test_framework/node.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/massa_test_framework/node.py b/massa_test_framework/node.py index ca4b129..4597f7c 100644 --- a/massa_test_framework/node.py +++ b/massa_test_framework/node.py @@ -10,10 +10,13 @@ import betterproto from grpclib.client import Channel +from massa_proto_python.massa.model.v1 import ReadOnlyExecutionOutput # internal from massa_test_framework import massa_jsonrpc_api from massa_proto_python.massa.api.v1 import ( + ExecuteReadOnlyCallRequest, + ExecuteReadOnlyCallResponse, GetMipStatusRequest, GetMipStatusResponse, PublicServiceStub, @@ -513,7 +516,29 @@ def get_stakers_grpc(self) -> GetStakersResponse: return get_stakers_response - def wait_ready(self, timeout=20) -> None: + def execute_read_only_call( + self, request: ExecuteReadOnlyCallRequest + ) -> ReadOnlyExecutionOutput: + """ + Executes a read-only call using the specified request. + + Args: + request (ExecuteReadOnlyCallRequest): The request object for the read-only call. + + Returns: + ReadOnlyExecutionOutput: The output of the read-only call. + """ + response: ExecuteReadOnlyCallResponse = asyncio.run( + self._public_grpc_call( + self.grpc_host, + self.pub_grpc_port, + "execute_read_only_call", + request, + ) + ) + return response.output + + def wait_ready(self, timeout: int = 20) -> None: """Wait for node to be ready Blocking wait for node to be ready