File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 1
1
import json
2
2
import logging
3
+ import sys
3
4
from abc import ABC , abstractmethod
4
5
from functools import lru_cache
5
6
from pathlib import Path
@@ -199,7 +200,7 @@ def save_key(private_key: bytes, path: Path):
199
200
"""
200
201
address = None
201
202
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 :
203
204
path .write_bytes (private_key )
204
205
address = Web3 ().to_checksum_address (
205
206
Web3 ().eth .account .from_key (private_key ).address
@@ -280,7 +281,7 @@ def get_fallback_private_key(path: Optional[Path] = None) -> bytes:
280
281
if path .exists () and path .stat ().st_size > 0 :
281
282
private_key = load_key (path )
282
283
else :
283
- private_key = create_key ()
284
+ private_key = create_key () if "pytest" not in sys . modules else generate_key ()
284
285
save_key (private_key , path )
285
286
default_key_path = path .parent / "default.key"
286
287
You can’t perform that action at this time.
0 commit comments