File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 11import json
22import logging
3+ import sys
34from abc import ABC , abstractmethod
45from functools import lru_cache
56from pathlib import Path
@@ -199,7 +200,7 @@ def save_key(private_key: bytes, path: Path):
199200 """
200201 address = None
201202 path .parent .mkdir (exist_ok = True , parents = True )
202- if path .name .endswith (".key" ):
203+ if path .name .endswith (".key" ) or "pytest" in sys . modules :
203204 path .write_bytes (private_key )
204205 address = Web3 ().to_checksum_address (
205206 Web3 ().eth .account .from_key (private_key ).address
@@ -280,7 +281,7 @@ def get_fallback_private_key(path: Optional[Path] = None) -> bytes:
280281 if path .exists () and path .stat ().st_size > 0 :
281282 private_key = load_key (path )
282283 else :
283- private_key = create_key ()
284+ private_key = create_key () if "pytest" not in sys . modules else generate_key ()
284285 save_key (private_key , path )
285286 default_key_path = path .parent / "default.key"
286287
You can’t perform that action at this time.
0 commit comments