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

CHIA-1730: port chia plotnft to @chia_commands framework #18833

Merged
merged 62 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
27bb718
chia plotnft CLI improvements
emlowe Nov 7, 2024
2abc8ea
use CliRpcConnectionError
emlowe Nov 7, 2024
76141c1
add check to show
emlowe Nov 7, 2024
3012f25
fix typo
emlowe Nov 7, 2024
2d14e7c
Update plotnft CLI to newer framework
emlowe Nov 7, 2024
4600233
Fix help cut-paste error
emlowe Nov 7, 2024
fd610bb
add test using new framework
emlowe Nov 7, 2024
4255d8d
some minor fixes
emlowe Nov 7, 2024
55a6bd2
use click.Choice for pool/local option
emlowe Nov 7, 2024
709fbde
some click options
emlowe Nov 8, 2024
432a142
Some more plotnft cli tests
emlowe Nov 8, 2024
9237cb0
drop test_pool_cmdline from mypy-exclusions
emlowe Nov 8, 2024
7c1bd9d
mypy fixes
emlowe Nov 8, 2024
2d4a702
several fixes
emlowe Nov 8, 2024
f602d85
Add leave test
emlowe Nov 8, 2024
69e9186
join tests
emlowe Nov 8, 2024
933f5ed
more join tests
emlowe Nov 8, 2024
a3a8d9c
missing await
emlowe Nov 8, 2024
37e10c0
Try setting config
emlowe Nov 8, 2024
6ebf3b8
use root_path from NeedsWalletRPC
emlowe Nov 8, 2024
a784788
linting
emlowe Nov 8, 2024
e8c1d46
Some cleanup
emlowe Nov 8, 2024
963d94e
Add claim tests
emlowe Nov 8, 2024
847f451
Merge remote-tracking branch 'origin/main' into EL.plotnft-cli-id
emlowe Nov 12, 2024
18493b8
Improved tests
emlowe Nov 12, 2024
18e8d5b
refactor some test code
emlowe Nov 12, 2024
a47c2a4
Add inspect tests
emlowe Nov 13, 2024
4d86993
Skip bad test for now
emlowe Nov 13, 2024
0fefffe
Add in change payout tests
emlowe Nov 13, 2024
edbea38
quoting error
emlowe Nov 13, 2024
9595fed
Add test for get_login_link
emlowe Nov 13, 2024
d74bc3a
Add in a few negative tests for join
emlowe Nov 13, 2024
9c3389b
Few more tests
emlowe Nov 14, 2024
ac482e5
Experment with clirunner env overrides
emlowe Nov 14, 2024
ad0b89a
put back chia_root into context dict
emlowe Nov 14, 2024
34edcc0
Some cleanup and one more test
emlowe Nov 14, 2024
5030c51
maybe final test
emlowe Nov 14, 2024
e1ab54a
some updates
emlowe Nov 15, 2024
ebd553a
Merge remote-tracking branch 'origin/main' into EL.plotnft-cli-id
emlowe Nov 15, 2024
e2ab86b
some dedup and reorg of test code
emlowe Nov 15, 2024
093043d
run trusted and untrusted paramertization
emlowe Nov 15, 2024
b9f2822
make reuse puzhash stuff work
emlowe Nov 15, 2024
3c67791
Add in required mock object for test_update_pool_config_new_config
emlowe Nov 15, 2024
2f4dea1
rearrange code per review comment - limit use of NeedsWalletRPC to ch…
emlowe Nov 18, 2024
0210745
Add in plotnft click parsing tests
emlowe Nov 18, 2024
5999957
added ability to pass in obj to runner invoke
emlowe Nov 19, 2024
f3063c5
Add in some more test cases
emlowe Nov 19, 2024
ef68d75
fix up create issues with config
emlowe Nov 19, 2024
25f7cad
Add in couple more test cases for error conditions
emlowe Nov 19, 2024
21c1ee6
Minor code cleanup
emlowe Nov 19, 2024
64db81e
Use long options for readability, minor code cleanup
emlowe Nov 20, 2024
47acd59
Use config file for farmer rpc port
emlowe Nov 20, 2024
063a0e5
simplify code
emlowe Nov 20, 2024
6278a59
Add testing for prompt cases
emlowe Nov 20, 2024
c242f90
Add mocking for default_root_path
emlowe Nov 20, 2024
bc59679
context cleanup
emlowe Nov 21, 2024
d08d970
temp debugging output
emlowe Nov 21, 2024
d95c028
patch the proper object
emlowe Nov 21, 2024
3fb781f
merge to origin/main
emlowe Nov 22, 2024
2bee14e
move some wallet fixtures into top level conftest and remove conftest…
emlowe Nov 26, 2024
6074bf8
Merge remote-tracking branch 'origin/main' into EL.plotnft-cli-id
emlowe Nov 26, 2024
46d9df5
merge to origin/main
emlowe Nov 26, 2024
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
4 changes: 2 additions & 2 deletions chia/_tests/cmds/test_cmd_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from chia.types.blockchain_format.sized_bytes import bytes32


def check_click_parsing(cmd: ChiaCommand, *args: str) -> None:
def check_click_parsing(cmd: ChiaCommand, *args: str, obj: Optional[Any] = None) -> None:
altendky marked this conversation as resolved.
Show resolved Hide resolved
@click.group()
def _cmd() -> None:
pass
Expand All @@ -40,7 +40,7 @@ def new_run(self: Any) -> None:
chia_command(_cmd, "_", "")(mock_type)

runner = CliRunner()
result = runner.invoke(_cmd, ["_", *args], catch_exceptions=False)
result = runner.invoke(_cmd, ["_", *args], catch_exceptions=False, obj=obj)
assert result.output == ""


Expand Down
3 changes: 3 additions & 0 deletions chia/_tests/pools/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from __future__ import annotations

from chia._tests.wallet.conftest import trusted_full_node, tx_config, wallet_environments # noqa: F401
altendky marked this conversation as resolved.
Show resolved Hide resolved
126 changes: 126 additions & 0 deletions chia/_tests/pools/test_pool_cli_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
from __future__ import annotations

from chia._tests.cmds.test_cmd_framework import check_click_parsing
from chia.cmds.cmd_classes import NeedsWalletRPC
from chia.cmds.param_types import CliAddress
from chia.cmds.plotnft import (
ChangePayoutInstructionsPlotNFTCMD,
ClaimPlotNFTCMD,
CreatePlotNFTCMD,
GetLoginLinkCMD,
InspectPlotNFTCMD,
JoinPlotNFTCMD,
LeavePlotNFTCMD,
ShowPlotNFTCMD,
)
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.bech32m import encode_puzzle_hash
from chia.util.ints import uint64
from chia.wallet.util.address_type import AddressType


def test_plotnft_command_default_parsing() -> None:
altendky marked this conversation as resolved.
Show resolved Hide resolved
launcher_id = bytes32([1] * 32)
check_click_parsing(
GetLoginLinkCMD(context=dict(), launcher_id=launcher_id),
"--launcher_id",
launcher_id.hex(),
)

burn_ph = bytes32.from_hexstr("0x000000000000000000000000000000000000000000000000000000000000dead")
burn_address = encode_puzzle_hash(burn_ph, "xch")
check_click_parsing(
ChangePayoutInstructionsPlotNFTCMD(
launcher_id=launcher_id, address=CliAddress(burn_ph, burn_address, AddressType.XCH)
),
"--launcher_id",
launcher_id.hex(),
"--address",
burn_address,
obj={"expected_prefix": "xch"}, # Needed for AddressParamType to work correctly without config
)

check_click_parsing(
ClaimPlotNFTCMD(
rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None), fee=uint64(1), id=5
),
"--id",
"5",
"--fee",
"0.000000000001",
)

check_click_parsing(
CreatePlotNFTCMD(
rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None),
pool_url="http://localhost:1234",
state="pool",
fee=uint64(0),
dont_prompt=False,
),
"--state",
"pool",
"--pool-url",
"http://localhost:1234",
"--fee",
"0.0",
)

check_click_parsing(
CreatePlotNFTCMD(
rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None),
pool_url=None,
state="local",
fee=uint64(0),
dont_prompt=True,
),
"--state",
"local",
"-y",
)

check_click_parsing(
InspectPlotNFTCMD(
rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None),
id=5,
),
"--id",
"5",
)

check_click_parsing(
JoinPlotNFTCMD(
rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None),
id=5,
fee=uint64(3),
pool_url="http://localhost:1234",
dont_prompt=True,
),
"--id",
"5",
"--fee",
"0.000000000003",
"--pool-url",
"http://localhost:1234",
"-y",
)

check_click_parsing(
LeavePlotNFTCMD(
rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None),
id=5,
fee=uint64(3),
dont_prompt=True,
),
"--id",
"5",
"--fee",
"0.000000000003",
"-y",
)

check_click_parsing(
ShowPlotNFTCMD(rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None), id=5),
"--id",
"5",
)
Loading
Loading