Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae committed Sep 9, 2024
1 parent 0ef2fd3 commit 30bf7a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies = [
"aleph-superfluid>=0.2.1",
"eth_typing==4.3.1",
"web3==6.3.0",
"rich==13.7.1",
]

[project.optional-dependencies]
Expand Down
9 changes: 7 additions & 2 deletions src/aleph/sdk/chains/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import sys
from abc import ABC, abstractmethod
from functools import lru_cache
from pathlib import Path
Expand Down Expand Up @@ -199,7 +200,7 @@ def save_key(private_key: bytes, path: Path):
"""
address = None
path.parent.mkdir(exist_ok=True, parents=True)
if path.name.endswith(".key"):
if path.name.endswith(".key") or "pytest" in sys.modules:
path.write_bytes(private_key)
address = Web3().to_checksum_address(
Web3().eth.account.from_key(private_key).address
Expand Down Expand Up @@ -280,7 +281,11 @@ def get_fallback_private_key(path: Optional[Path] = None) -> bytes:
if path.exists() and path.stat().st_size > 0:
private_key = load_key(path)
else:
private_key = create_key()
private_key = (
generate_key()
if path.name.endswith(".key") or "pytest" in sys.modules
else create_key()
)
save_key(private_key, path)
default_key_path = path.parent / "default.key"

Expand Down

0 comments on commit 30bf7a4

Please sign in to comment.