Skip to content

Commit

Permalink
Throws on on send_operations error
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-François <[email protected]>
  • Loading branch information
bilboquet committed Dec 14, 2023
1 parent d5c7cc9 commit 159ad3b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions massa_test_framework/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 159ad3b

Please sign in to comment.