Skip to content

Commit

Permalink
add installed test for chia init and fix importlib_resources uses (
Browse files Browse the repository at this point in the history
…#18102)

* add installed test for `chia init`

* `.rpartition(".")[0]`
  • Loading branch information
altendky authored Jun 3, 2024
1 parent b31806b commit e8d2710
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion chia/_tests/cmds/wallet/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from chia.wallet.util.wallet_types import WalletType
from chia.wallet.wallet_coin_store import GetCoinRecords

test_offer_file_path = importlib_resources.files(__name__).joinpath("test_offer.toffer")
test_offer_file_path = importlib_resources.files(__name__.rpartition(".")[0]).joinpath("test_offer.toffer")
test_offer_file_bech32 = test_offer_file_path.read_text(encoding="utf-8")
test_offer_id: str = "0xdfb7e8643376820ec995b0bcdb3fc1f764c16b814df5e074631263fcf1e00839"
test_offer_id_bytes: bytes32 = bytes32.from_hexstr(test_offer_id)
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/util/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# farmer puzzle hash
ph = bytes32(b"a" * 32)

clvm_generator_bin_path = importlib_resources.files(__name__).joinpath("clvm_generator.bin")
clvm_generator_bin_path = importlib_resources.files(__name__.rpartition(".")[0]).joinpath("clvm_generator.bin")
clvm_generator = clvm_generator_bin_path.read_bytes()


Expand Down
8 changes: 8 additions & 0 deletions chia/cmds/installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,11 @@ def test_command(expected_chia_version_str: str, require_madmax: bool) -> None:
# expected_output=b"\nBladebit Chia Plotter",
# specify_tmp_dir=False,
# )

args = [executable_for_service("chia"), "init"]
print(f"launching: {args}")
subprocess.run(
args,
check=True,
timeout=adjusted_timeout(30),
)
2 changes: 1 addition & 1 deletion chia/ssl/create_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


def get_chia_ca_crt_key() -> Tuple[Any, Any]:
here = importlib_resources.files(__name__)
here = importlib_resources.files(__name__.rpartition(".")[0])
crt = here.joinpath("chia_ca.crt").read_bytes()
key = here.joinpath("chia_ca.key").read_bytes()
return crt, key
Expand Down
2 changes: 1 addition & 1 deletion chia/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


def initial_config_file(filename: Union[str, Path]) -> str:
initial_config_path = importlib_resources.files(__name__).joinpath(f"initial-{filename}")
initial_config_path = importlib_resources.files(__name__.rpartition(".")[0]).joinpath(f"initial-{filename}")
contents: str = initial_config_path.read_text(encoding="utf-8")
return contents

Expand Down
2 changes: 1 addition & 1 deletion chia/util/keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def set_keys_root_path(keys_root_path: Path) -> None:


def bip39_word_list() -> str:
word_list_path = importlib_resources.files(__name__).joinpath("english.txt")
word_list_path = importlib_resources.files(__name__.rpartition(".")[0]).joinpath("english.txt")
contents: str = word_list_path.read_text(encoding="utf-8")
return contents

Expand Down

0 comments on commit e8d2710

Please sign in to comment.