diff --git a/massa_test_framework/node.py b/massa_test_framework/node.py index 4c41d01..ca4b129 100644 --- a/massa_test_framework/node.py +++ b/massa_test_framework/node.py @@ -6,7 +6,7 @@ import time from urllib.parse import urlparse -from typing import List, Dict, Optional, Callable +from typing import List, Dict, Optional, Callable, Union import betterproto from grpclib.client import Channel @@ -36,6 +36,7 @@ import requests import tomlkit + class Node: def __init__(self, server: Server, compile_unit: CompileUnit): """Init a Node (e.g. a Massa Node) object @@ -280,7 +281,6 @@ def edit_config(self): # print("is fp closed:", fp.closed) # print("end of edit_config") - @contextmanager def edit_json(self, json_filepath: Path, mode: str = "r+", default_json=None): fp = self.server.open(json_filepath, mode) @@ -383,10 +383,21 @@ def send_operations(self, operations: List[bytes]) -> List[str]: Args: operations: a list of serialized operations + Returns: - a list of operation id + If successful, returns a list of operation IDs. + + Raises: + Exception: If send_operation return an error, an exception is raised with the error message. + """ res = self.pub_api2.send_operations(operations) + + err = res.get("error", None) + if err is not None: + msg = str(err.get("message", "Unknown error")) + raise Exception(msg) + return res["result"] def node_peers_whitelist(self):