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

fix: create data dir in clean method #2167

Merged
merged 6 commits into from
Jul 2, 2024
Merged
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
5 changes: 3 additions & 2 deletions src/ape_node/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def __init__(
self._data_dir = data_dir
self._hostname = hostname
self._port = port
self._data_dir.mkdir(exist_ok=True, parents=True)
self.is_running = False
self._auto_disconnect = auto_disconnect

Expand Down Expand Up @@ -140,7 +139,6 @@ def __init__(
bal_dict = {"balance": str(initial_balance)}
alloc = {a: bal_dict for a in addresses}
genesis = create_genesis_data(alloc, chain_id)
self._data_dir.mkdir(parents=True, exist_ok=True)
initialize_chain(genesis, self.data_dir)
super().__init__(geth_kwargs)

Expand Down Expand Up @@ -209,6 +207,9 @@ def _clean(self):
if self._data_dir.is_dir():
shutil.rmtree(self._data_dir)

# dir must exist when initializing chain.
self._data_dir.mkdir(parents=True, exist_ok=True)

def wait(self, *args, **kwargs):
if self.proc is None:
return
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,10 @@ def clean():
):
actual = pm.sources.lookup(closest)
expected = nested_source_b
assert actual == expected, f"Failed to lookup {closest}"

# Using stem in case it returns `Contract.__mock__`, which is
# added / removed as part of other tests (running x-dist).
assert actual.stem == expected.stem, f"Failed to lookup {closest}"

finally:
clean()
Expand Down
Loading