From 191b63c36cd0287be4c27faa8ccf0644a6ee23f5 Mon Sep 17 00:00:00 2001 From: William Allen Date: Sun, 9 Feb 2025 17:00:19 -0600 Subject: [PATCH 01/15] Include plotNFT rewards in get_farmed_amount --- chia/wallet/wallet_rpc_api.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/chia/wallet/wallet_rpc_api.py b/chia/wallet/wallet_rpc_api.py index ed4630b7d27e..5094a79804b0 100644 --- a/chia/wallet/wallet_rpc_api.py +++ b/chia/wallet/wallet_rpc_api.py @@ -3668,9 +3668,6 @@ async def get_farmed_amount(self, request: dict[str, Any]) -> EndpointResult: if record.wallet_id not in self.service.wallet_state_manager.wallets: continue if record.type == TransactionType.COINBASE_REWARD.value: - if self.service.wallet_state_manager.wallets[record.wallet_id].type() == WalletType.POOLING_WALLET: - # Don't add pool rewards for pool wallets. - continue pool_reward_amount += record.amount height = record.height_farmed(self.service.constants.GENESIS_CHALLENGE) # .get_farming_rewards() above queries for only confirmed records. This From ec80624301487ea942f8ee9a82930b85024a89f3 Mon Sep 17 00:00:00 2001 From: wallentx Date: Thu, 24 Apr 2025 13:50:37 -0500 Subject: [PATCH 02/15] Add flag to include pool rewards in farm summary --- chia/cmds/farm.py | 8 ++++++++ chia/cmds/farm_funcs.py | 11 ++++++++--- chia/wallet/wallet_rpc_api.py | 6 ++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/chia/cmds/farm.py b/chia/cmds/farm.py index e14658a4b797..29ee21b73a3d 100644 --- a/chia/cmds/farm.py +++ b/chia/cmds/farm.py @@ -49,6 +49,12 @@ def farm_cmd() -> None: default=None, show_default=True, ) +@click.option( + "--include-pool-rewards", + help="Include pool farming rewards in the total farmed amount", + is_flag=True, + default=False, +) @click.pass_context def summary_cmd( ctx: click.Context, @@ -56,6 +62,7 @@ def summary_cmd( wallet_rpc_port: Optional[int], harvester_rpc_port: Optional[int], farmer_rpc_port: Optional[int], + include_pool_rewards: bool, ) -> None: import asyncio @@ -67,6 +74,7 @@ def summary_cmd( wallet_rpc_port, harvester_rpc_port, farmer_rpc_port, + include_pool_rewards, root_path=ChiaCliContext.set_default(ctx).root_path, ) ) diff --git a/chia/cmds/farm_funcs.py b/chia/cmds/farm_funcs.py index b251edded023..7d979062dcff 100644 --- a/chia/cmds/farm_funcs.py +++ b/chia/cmds/farm_funcs.py @@ -49,9 +49,13 @@ async def get_average_block_time(rpc_port: Optional[int], root_path: Path) -> fl return (curr.timestamp - past_curr.timestamp) / (curr.height - past_curr.height) -async def get_wallets_stats(wallet_rpc_port: Optional[int], root_path: Path) -> Optional[dict[str, Any]]: +async def get_wallets_stats( + wallet_rpc_port: Optional[int], + root_path: Path, + include_pool_rewards: bool, +) -> Optional[dict[str, Any]]: async with get_any_service_client(WalletRpcClient, root_path, wallet_rpc_port) as (wallet_client, _): - return await wallet_client.get_farmed_amount() + return await wallet_client.get_farmed_amount(include_pool_rewards) async def get_challenges(root_path: Path, farmer_rpc_port: Optional[int]) -> Optional[list[dict[str, Any]]]: @@ -80,6 +84,7 @@ async def summary( wallet_rpc_port: Optional[int], harvester_rpc_port: Optional[int], farmer_rpc_port: Optional[int], + include_pool_rewards: bool, root_path: Path, ) -> None: harvesters_summary = await get_harvesters_summary(farmer_rpc_port, root_path) @@ -97,7 +102,7 @@ async def summary( wallet_not_ready: bool = False amounts = None try: - amounts = await get_wallets_stats(wallet_rpc_port, root_path) + amounts = await get_wallets_stats(wallet_rpc_port, root_path, include_pool_rewards) except CliRpcConnectionError: wallet_not_ready = True except Exception: diff --git a/chia/wallet/wallet_rpc_api.py b/chia/wallet/wallet_rpc_api.py index 5094a79804b0..cfa7c272c2bf 100644 --- a/chia/wallet/wallet_rpc_api.py +++ b/chia/wallet/wallet_rpc_api.py @@ -3664,10 +3664,16 @@ async def get_farmed_amount(self, request: dict[str, Any]) -> EndpointResult: fee_amount = 0 blocks_won = 0 last_height_farmed = uint32(0) + + include_pool_rewards = request.get("include_pool_rewards", False) + for record in tx_records: if record.wallet_id not in self.service.wallet_state_manager.wallets: continue if record.type == TransactionType.COINBASE_REWARD.value: + if not include_pool_rewards and self.service.wallet_state_manager.wallets[record.wallet_id].type() == WalletType.POOLING_WALLET: + # Don't add pool rewards for pool wallets unless explicitly requested + continue pool_reward_amount += record.amount height = record.height_farmed(self.service.constants.GENESIS_CHALLENGE) # .get_farming_rewards() above queries for only confirmed records. This From 75c0470a24ad83a744a32af88d04c3958700edbf Mon Sep 17 00:00:00 2001 From: wallentx Date: Thu, 24 Apr 2025 13:57:52 -0500 Subject: [PATCH 03/15] Add -i for short flag --- chia/cmds/farm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/chia/cmds/farm.py b/chia/cmds/farm.py index 29ee21b73a3d..2fd131e39866 100644 --- a/chia/cmds/farm.py +++ b/chia/cmds/farm.py @@ -50,6 +50,7 @@ def farm_cmd() -> None: show_default=True, ) @click.option( + "-i", "--include-pool-rewards", help="Include pool farming rewards in the total farmed amount", is_flag=True, From 9b66239c03145b69087342510c1166c68d9cddd4 Mon Sep 17 00:00:00 2001 From: wallentx Date: Thu, 24 Apr 2025 14:04:38 -0500 Subject: [PATCH 04/15] Fix expected args --- chia/wallet/wallet_rpc_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chia/wallet/wallet_rpc_client.py b/chia/wallet/wallet_rpc_client.py index 88ae0084b14e..4205921a5bcc 100644 --- a/chia/wallet/wallet_rpc_client.py +++ b/chia/wallet/wallet_rpc_client.py @@ -427,8 +427,8 @@ async def extend_derivation_index(self, index: int) -> str: updated_index = response["index"] return str(updated_index) - async def get_farmed_amount(self) -> dict[str, Any]: - return await self.fetch("get_farmed_amount", {}) + async def get_farmed_amount(self, include_pool_rewards: bool = False) -> dict[str, Any]: + return await self.fetch("get_farmed_amount", {"include_pool_rewards": include_pool_rewards}) async def create_signed_transactions( self, From f3ff98ff8c2c5c04cd7c80d15260119633af4b41 Mon Sep 17 00:00:00 2001 From: wallentx Date: Thu, 24 Apr 2025 14:26:56 -0500 Subject: [PATCH 05/15] Include additional farming detail --- chia/cmds/farm_funcs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chia/cmds/farm_funcs.py b/chia/cmds/farm_funcs.py index 7d979062dcff..5b5823450007 100644 --- a/chia/cmds/farm_funcs.py +++ b/chia/cmds/farm_funcs.py @@ -127,6 +127,10 @@ async def summary( print(f"User transaction fees: {amounts['fee_amount'] / units['chia']}") print(f"Block rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") print(f"Last height farmed: {amounts['last_height_farmed']}") + if blockchain_state is not None and blockchain_state["peak"] is not None: + peak_height = blockchain_state["peak"].height + blocks_since_last_farm = peak_height - amounts['last_height_farmed'] + print(f"Blocks since last farmed: {blocks_since_last_farm}") class PlotStats: total_plot_size = 0 From cbf565a5b7709be453328b096c391469684dc728 Mon Sep 17 00:00:00 2001 From: wallentx Date: Thu, 24 Apr 2025 14:40:22 -0500 Subject: [PATCH 06/15] Include additional farming detail --- chia/cmds/farm_funcs.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chia/cmds/farm_funcs.py b/chia/cmds/farm_funcs.py index 5b5823450007..efe6b569658e 100644 --- a/chia/cmds/farm_funcs.py +++ b/chia/cmds/farm_funcs.py @@ -126,11 +126,19 @@ async def summary( print(f"Total chia farmed: {amounts['farmed_amount'] / units['chia']}") print(f"User transaction fees: {amounts['fee_amount'] / units['chia']}") print(f"Block rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") + if include_pool_rewards: + print(f" └─ Farmer rewards: {amounts['farmer_reward_amount'] / units['chia']}") + print(f" └─ Pool rewards: {amounts['pool_reward_amount'] / units['chia']}") print(f"Last height farmed: {amounts['last_height_farmed']}") - if blockchain_state is not None and blockchain_state["peak"] is not None: + + # Show additional information only when include_pool_rewards is True + if include_pool_rewards and blockchain_state is not None and blockchain_state["peak"] is not None: peak_height = blockchain_state["peak"].height blocks_since_last_farm = peak_height - amounts['last_height_farmed'] + print(f"\nDetailed farming information:") + print(f"Current height: {peak_height}") print(f"Blocks since last farmed: {blocks_since_last_farm}") + print(f"Time since last farmed: {format_minutes(int((blocks_since_last_farm * SECONDS_PER_BLOCK) / 60))}") class PlotStats: total_plot_size = 0 From f6b95f1ce421808d6ca141aa0e3a41832e6cb8d6 Mon Sep 17 00:00:00 2001 From: wallentx Date: Thu, 24 Apr 2025 14:48:43 -0500 Subject: [PATCH 07/15] Format/organize output --- chia/cmds/farm_funcs.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/chia/cmds/farm_funcs.py b/chia/cmds/farm_funcs.py index efe6b569658e..1a02481eb9c6 100644 --- a/chia/cmds/farm_funcs.py +++ b/chia/cmds/farm_funcs.py @@ -127,18 +127,16 @@ async def summary( print(f"User transaction fees: {amounts['fee_amount'] / units['chia']}") print(f"Block rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") if include_pool_rewards: - print(f" └─ Farmer rewards: {amounts['farmer_reward_amount'] / units['chia']}") - print(f" └─ Pool rewards: {amounts['pool_reward_amount'] / units['chia']}") - print(f"Last height farmed: {amounts['last_height_farmed']}") - - # Show additional information only when include_pool_rewards is True - if include_pool_rewards and blockchain_state is not None and blockchain_state["peak"] is not None: - peak_height = blockchain_state["peak"].height - blocks_since_last_farm = peak_height - amounts['last_height_farmed'] - print(f"\nDetailed farming information:") - print(f"Current height: {peak_height}") - print(f"Blocks since last farmed: {blocks_since_last_farm}") - print(f"Time since last farmed: {format_minutes(int((blocks_since_last_farm * SECONDS_PER_BLOCK) / 60))}") + print(f"├─ Farmer rewards: {amounts['farmer_reward_amount'] / units['chia']}") + print(f"└─ Pool rewards: {amounts['pool_reward_amount'] / units['chia']}") + if blockchain_state is not None and blockchain_state["peak"] is not None: + peak_height = blockchain_state["peak"].height + blocks_since_last_farm = peak_height - amounts['last_height_farmed'] + print(f"Current/Last height farmed: {peak_height}/{amounts['last_height_farmed']}") + print(f"Blocks since last farmed: {blocks_since_last_farm}") + print(f"Time since last farmed: {format_minutes(int((blocks_since_last_farm * SECONDS_PER_BLOCK) / 60))}") + else: + print(f"Last height farmed: {amounts['last_height_farmed']}") class PlotStats: total_plot_size = 0 From b7fbbad5444dd2b0d3df9ed41312043c4cad0a3c Mon Sep 17 00:00:00 2001 From: wallentx Date: Thu, 24 Apr 2025 14:52:46 -0500 Subject: [PATCH 08/15] Move block rewards --- chia/cmds/farm_funcs.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/chia/cmds/farm_funcs.py b/chia/cmds/farm_funcs.py index 1a02481eb9c6..c127632b60b7 100644 --- a/chia/cmds/farm_funcs.py +++ b/chia/cmds/farm_funcs.py @@ -125,10 +125,10 @@ async def summary( if amounts is not None: print(f"Total chia farmed: {amounts['farmed_amount'] / units['chia']}") print(f"User transaction fees: {amounts['fee_amount'] / units['chia']}") - print(f"Block rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") if include_pool_rewards: - print(f"├─ Farmer rewards: {amounts['farmer_reward_amount'] / units['chia']}") - print(f"└─ Pool rewards: {amounts['pool_reward_amount'] / units['chia']}") + print(f"Farmer rewards: {amounts['farmer_reward_amount'] / units['chia']}") + print(f"Pool rewards: {amounts['pool_reward_amount'] / units['chia']}") + print(f"Total rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") if blockchain_state is not None and blockchain_state["peak"] is not None: peak_height = blockchain_state["peak"].height blocks_since_last_farm = peak_height - amounts['last_height_farmed'] @@ -136,6 +136,7 @@ async def summary( print(f"Blocks since last farmed: {blocks_since_last_farm}") print(f"Time since last farmed: {format_minutes(int((blocks_since_last_farm * SECONDS_PER_BLOCK) / 60))}") else: + print(f"Block rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") print(f"Last height farmed: {amounts['last_height_farmed']}") class PlotStats: From ad0d433aca3de8186db56dd5004372a2e462aa5c Mon Sep 17 00:00:00 2001 From: wallentx Date: Mon, 28 Apr 2025 11:53:43 -0500 Subject: [PATCH 09/15] Update test --- chia/_tests/cmds/test_farm_cmd.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chia/_tests/cmds/test_farm_cmd.py b/chia/_tests/cmds/test_farm_cmd.py index 968152331e7b..3ce3ee9ca4b6 100644 --- a/chia/_tests/cmds/test_farm_cmd.py +++ b/chia/_tests/cmds/test_farm_cmd.py @@ -46,7 +46,14 @@ async def receiver_available() -> bool: wallet_rpc_port = wallet_service.rpc_server.webserver.listen_port farmer_rpc_port = farmer_service.rpc_server.webserver.listen_port - await summary(full_node_rpc_port, wallet_rpc_port, None, farmer_rpc_port, bt.root_path) + await summary( + rpc_port=full_node_rpc_port, + wallet_rpc_port=wallet_rpc_port, + harvester_rpc_port=None, + farmer_rpc_port=farmer_rpc_port, + include_pool_rewards=False, + root_path=bt.root_path, + ) captured = capsys.readouterr() match = re.search(r"^.+(Farming status:.+)$", captured.out, re.DOTALL) From 3673427969d82ed67679ec2fa0447317d0e065ba Mon Sep 17 00:00:00 2001 From: wallentx Date: Mon, 28 Apr 2025 12:00:25 -0500 Subject: [PATCH 10/15] Format --- chia/cmds/farm_funcs.py | 6 ++++-- chia/wallet/wallet_rpc_api.py | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/chia/cmds/farm_funcs.py b/chia/cmds/farm_funcs.py index c127632b60b7..560a65b39b76 100644 --- a/chia/cmds/farm_funcs.py +++ b/chia/cmds/farm_funcs.py @@ -131,10 +131,12 @@ async def summary( print(f"Total rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") if blockchain_state is not None and blockchain_state["peak"] is not None: peak_height = blockchain_state["peak"].height - blocks_since_last_farm = peak_height - amounts['last_height_farmed'] + blocks_since_last_farm = peak_height - amounts["last_height_farmed"] print(f"Current/Last height farmed: {peak_height}/{amounts['last_height_farmed']}") print(f"Blocks since last farmed: {blocks_since_last_farm}") - print(f"Time since last farmed: {format_minutes(int((blocks_since_last_farm * SECONDS_PER_BLOCK) / 60))}") + print( + f"Time since last farmed: {format_minutes(int((blocks_since_last_farm * SECONDS_PER_BLOCK) / 60))}" + ) else: print(f"Block rewards: {(amounts['farmer_reward_amount'] + amounts['pool_reward_amount']) / units['chia']}") print(f"Last height farmed: {amounts['last_height_farmed']}") diff --git a/chia/wallet/wallet_rpc_api.py b/chia/wallet/wallet_rpc_api.py index cfa7c272c2bf..d8fa30022417 100644 --- a/chia/wallet/wallet_rpc_api.py +++ b/chia/wallet/wallet_rpc_api.py @@ -3671,7 +3671,10 @@ async def get_farmed_amount(self, request: dict[str, Any]) -> EndpointResult: if record.wallet_id not in self.service.wallet_state_manager.wallets: continue if record.type == TransactionType.COINBASE_REWARD.value: - if not include_pool_rewards and self.service.wallet_state_manager.wallets[record.wallet_id].type() == WalletType.POOLING_WALLET: + if ( + not include_pool_rewards + and self.service.wallet_state_manager.wallets[record.wallet_id].type() == WalletType.POOLING_WALLET + ): # Don't add pool rewards for pool wallets unless explicitly requested continue pool_reward_amount += record.amount From d86e4fdac6e40ff359179e4464d3d204e29b0b23 Mon Sep 17 00:00:00 2001 From: William Allen Date: Thu, 8 May 2025 10:18:08 -0500 Subject: [PATCH 11/15] Update test_farm_cmd.py --- chia/_tests/cmds/test_farm_cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chia/_tests/cmds/test_farm_cmd.py b/chia/_tests/cmds/test_farm_cmd.py index 3ce3ee9ca4b6..70f19bd6d9d0 100644 --- a/chia/_tests/cmds/test_farm_cmd.py +++ b/chia/_tests/cmds/test_farm_cmd.py @@ -51,7 +51,7 @@ async def receiver_available() -> bool: wallet_rpc_port=wallet_rpc_port, harvester_rpc_port=None, farmer_rpc_port=farmer_rpc_port, - include_pool_rewards=False, + include_pool_rewards=True, root_path=bt.root_path, ) From e526d84993d3d986e87e5f04fb93123d6391ba39 Mon Sep 17 00:00:00 2001 From: wallentx Date: Sat, 12 Jul 2025 03:09:13 -0500 Subject: [PATCH 12/15] revert test bool --- chia/_tests/cmds/test_farm_cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chia/_tests/cmds/test_farm_cmd.py b/chia/_tests/cmds/test_farm_cmd.py index 70f19bd6d9d0..3ce3ee9ca4b6 100644 --- a/chia/_tests/cmds/test_farm_cmd.py +++ b/chia/_tests/cmds/test_farm_cmd.py @@ -51,7 +51,7 @@ async def receiver_available() -> bool: wallet_rpc_port=wallet_rpc_port, harvester_rpc_port=None, farmer_rpc_port=farmer_rpc_port, - include_pool_rewards=True, + include_pool_rewards=False, root_path=bt.root_path, ) From c8770e46a20f3a10d42051117ccbe4727714f394 Mon Sep 17 00:00:00 2001 From: wallentx Date: Sat, 12 Jul 2025 05:29:56 -0500 Subject: [PATCH 13/15] Passing tests --- chia/_tests/cmds/test_farm_cmd.py | 51 +++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/chia/_tests/cmds/test_farm_cmd.py b/chia/_tests/cmds/test_farm_cmd.py index 3ce3ee9ca4b6..fcca35030f32 100644 --- a/chia/_tests/cmds/test_farm_cmd.py +++ b/chia/_tests/cmds/test_farm_cmd.py @@ -56,18 +56,43 @@ async def receiver_available() -> bool: ) captured = capsys.readouterr() - match = re.search(r"^.+(Farming status:.+)$", captured.out, re.DOTALL) + match = re.search(r"(Farming status:.*)", captured.out, re.DOTALL) assert match is not None - lines = match.group(1).split("\n") + output = match.group(1) - assert lines[0] == "Farming status: Not synced or not connected to peers" - assert "Total chia farmed:" in lines[1] - assert "User transaction fees:" in lines[2] - assert "Block rewards:" in lines[3] - assert "Last height farmed:" in lines[4] - assert lines[5] == "Local Harvester" - assert "e (effective)" in lines[6] - assert "Plot count for all harvesters:" in lines[7] - assert "e (effective)" in lines[8] - assert "Estimated network space:" in lines[9] - assert "Expected time to win:" in lines[10] + assert "Farming status:" in output + assert "Total chia farmed:" in output + assert "User transaction fees:" in output + assert "Block rewards:" in output + assert "Last height farmed:" in output + assert "Local Harvester" in output + assert "e (effective)" in output + assert "Plot count for all harvesters:" in output + assert "Estimated network space:" in output + assert "Expected time to win:" in output + + await summary( + rpc_port=full_node_rpc_port, + wallet_rpc_port=wallet_rpc_port, + harvester_rpc_port=None, + farmer_rpc_port=farmer_rpc_port, + include_pool_rewards=True, + root_path=bt.root_path, + ) + + captured = capsys.readouterr() + match = re.search(r"(Farming status:.*)", captured.out, re.DOTALL) + assert match is not None + output = match.group(1) + + assert "Farming status:" in output + assert "Total chia farmed:" in output + assert "User transaction fees:" in output + assert "Farmer rewards:" in output + assert "Pool rewards:" in output + assert "Total rewards:" in output + assert "Local Harvester" in output + assert "e (effective)" in output + assert "Plot count for all harvesters:" in output + assert "Estimated network space:" in output + assert "Expected time to win:" in output From 13ed3a6d0d810d456bfbadf8f76410d51f7b1ecc Mon Sep 17 00:00:00 2001 From: wallentx Date: Sat, 12 Jul 2025 06:40:30 -0500 Subject: [PATCH 14/15] Added test for 'include_pool_rewards=True' --- chia/_tests/cmds/test_farm_cmd.py | 77 ++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/chia/_tests/cmds/test_farm_cmd.py b/chia/_tests/cmds/test_farm_cmd.py index fcca35030f32..5365e2871499 100644 --- a/chia/_tests/cmds/test_farm_cmd.py +++ b/chia/_tests/cmds/test_farm_cmd.py @@ -46,6 +46,7 @@ async def receiver_available() -> bool: wallet_rpc_port = wallet_service.rpc_server.webserver.listen_port farmer_rpc_port = farmer_service.rpc_server.webserver.listen_port + # Test with include_pool_rewards=False (original test) await summary( rpc_port=full_node_rpc_port, wallet_rpc_port=wallet_rpc_port, @@ -56,21 +57,23 @@ async def receiver_available() -> bool: ) captured = capsys.readouterr() - match = re.search(r"(Farming status:.*)", captured.out, re.DOTALL) + match = re.search(r"^.+(Farming status:.+)$", captured.out, re.DOTALL) assert match is not None - output = match.group(1) - - assert "Farming status:" in output - assert "Total chia farmed:" in output - assert "User transaction fees:" in output - assert "Block rewards:" in output - assert "Last height farmed:" in output - assert "Local Harvester" in output - assert "e (effective)" in output - assert "Plot count for all harvesters:" in output - assert "Estimated network space:" in output - assert "Expected time to win:" in output + lines = match.group(1).split("\n") + assert lines[0] == "Farming status: Not synced or not connected to peers" + assert "Total chia farmed:" in lines[1] + assert "User transaction fees:" in lines[2] + assert "Block rewards:" in lines[3] + assert "Last height farmed:" in lines[4] + assert lines[5] == "Local Harvester" + assert "e (effective)" in lines[6] + assert "Plot count for all harvesters:" in lines[7] + assert "e (effective)" in lines[8] + assert "Estimated network space:" in lines[9] + assert "Expected time to win:" in lines[10] + + # Test with include_pool_rewards=True await summary( rpc_port=full_node_rpc_port, wallet_rpc_port=wallet_rpc_port, @@ -81,18 +84,36 @@ async def receiver_available() -> bool: ) captured = capsys.readouterr() - match = re.search(r"(Farming status:.*)", captured.out, re.DOTALL) - assert match is not None - output = match.group(1) - - assert "Farming status:" in output - assert "Total chia farmed:" in output - assert "User transaction fees:" in output - assert "Farmer rewards:" in output - assert "Pool rewards:" in output - assert "Total rewards:" in output - assert "Local Harvester" in output - assert "e (effective)" in output - assert "Plot count for all harvesters:" in output - assert "Estimated network space:" in output - assert "Expected time to win:" in output + # grab the output + match = re.search(r"Farming status:.*", captured.out, re.DOTALL) + assert match, "no 'Farming status:' line" + output = match.group(0).strip() + lines = [l.strip() for l in output.splitlines()] + + # always check these first six lines + assert lines[0].startswith("Farming status:") + assert lines[1].startswith("Total chia farmed:") + assert lines[2].startswith("User transaction fees:") + assert lines[3].startswith("Farmer rewards:") + assert lines[4].startswith("Pool rewards:") + assert lines[5].startswith("Total rewards:") + + # decide where the harvester section starts + if "Current/Last height farmed:" in output: + # we saw the height‐farmed block, so it occupies lines[6–8] + assert lines[6].startswith("Current/Last height farmed:") + assert lines[7].startswith("Blocks since last farmed:") + assert lines[8].startswith("Time since last farmed:") + harvester_idx = 9 + else: + # no height block, so harvester begins at line 6 + harvester_idx = 6 + + # now the harvester lines + assert lines[harvester_idx] == "Local Harvester" + assert "plots of size" in lines[harvester_idx + 1] + assert lines[harvester_idx + 2].startswith("Plot count for all harvesters:") + assert lines[harvester_idx + 3].startswith("Total size of plots:") + assert lines[harvester_idx + 4].startswith("Estimated network space:") + assert lines[harvester_idx + 5].startswith("Expected time to win:") + assert lines[harvester_idx + 6].startswith("Note:") From 2ebdfdccf8055fc85b3f8aff311fecc544e575b9 Mon Sep 17 00:00:00 2001 From: wallentx Date: Sat, 12 Jul 2025 11:48:43 -0500 Subject: [PATCH 15/15] Address linting errors --- chia/_tests/cmds/test_farm_cmd.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/chia/_tests/cmds/test_farm_cmd.py b/chia/_tests/cmds/test_farm_cmd.py index 5365e2871499..65fee50e68e3 100644 --- a/chia/_tests/cmds/test_farm_cmd.py +++ b/chia/_tests/cmds/test_farm_cmd.py @@ -84,11 +84,10 @@ async def receiver_available() -> bool: ) captured = capsys.readouterr() - # grab the output match = re.search(r"Farming status:.*", captured.out, re.DOTALL) assert match, "no 'Farming status:' line" output = match.group(0).strip() - lines = [l.strip() for l in output.splitlines()] + lines = [line.strip() for line in output.splitlines()] # always check these first six lines assert lines[0].startswith("Farming status:") @@ -100,7 +99,7 @@ async def receiver_available() -> bool: # decide where the harvester section starts if "Current/Last height farmed:" in output: - # we saw the height‐farmed block, so it occupies lines[6–8] + # we saw the height-farmed block, so it occupies lines[6-8] assert lines[6].startswith("Current/Last height farmed:") assert lines[7].startswith("Blocks since last farmed:") assert lines[8].startswith("Time since last farmed:")