Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to set build directory #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions massa_test_framework/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}

Expand Down Expand Up @@ -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"]
Expand Down
13 changes: 13 additions & 0 deletions massa_test_framework/massa_jsonrpc_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions massa_test_framework/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions massa_test_framework/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading