From eb6aeb64054fdb9466c30f47f4a558aaa7d44bbe Mon Sep 17 00:00:00 2001 From: Matt Hauff Date: Thu, 6 Oct 2022 09:05:23 -0700 Subject: [PATCH] Fix a breaking change in get_puzzle_and_solution RPC (#13519) --- chia/rpc/full_node_rpc_api.py | 8 ++++---- tests/core/test_full_node_rpc.py | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/chia/rpc/full_node_rpc_api.py b/chia/rpc/full_node_rpc_api.py index e35506fb68ec..e9b9834af344 100644 --- a/chia/rpc/full_node_rpc_api.py +++ b/chia/rpc/full_node_rpc_api.py @@ -12,7 +12,6 @@ from chia.rpc.rpc_server import Endpoint, EndpointResult from chia.server.outbound_message import NodeType from chia.types.blockchain_format.coin import Coin -from chia.types.blockchain_format.program import Program, SerializedProgram from chia.types.blockchain_format.sized_bytes import bytes32 from chia.types.coin_record import CoinRecord from chia.types.coin_spend import CoinSpend @@ -705,9 +704,10 @@ async def get_puzzle_and_solution(self, request: Dict) -> EndpointResult: if error is not None: raise ValueError(f"Error: {error}") - puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) - solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) - return {"coin_solution": CoinSpend(coin_record.coin, puzzle_ser, solution_ser)} + assert puzzle is not None + assert solution is not None + + return {"coin_solution": CoinSpend(coin_record.coin, puzzle, solution)} async def get_additions_and_removals(self, request: Dict) -> EndpointResult: if "header_hash" not in request: diff --git a/tests/core/test_full_node_rpc.py b/tests/core/test_full_node_rpc.py index d3debf8b933d..f3aee2252f16 100644 --- a/tests/core/test_full_node_rpc.py +++ b/tests/core/test_full_node_rpc.py @@ -157,7 +157,14 @@ async def test1(self, two_nodes_sim_and_wallets_services, self_hostname): await full_node_api_1.farm_new_transaction_block(FarmNewBlockProtocol(ph_2)) - assert (await client.get_coin_record_by_name(coin.name())).coin == coin + coin_record = await client.get_coin_record_by_name(coin.name()) + assert coin_record.coin == coin + assert ( + coin + in ( + await client.get_puzzle_and_solution(coin.parent_coin_info, coin_record.confirmed_block_index) + ).additions() + ) assert len(await client.get_coin_records_by_puzzle_hash(ph_receiver)) == 1 assert len(list(filter(lambda cr: not cr.spent, (await client.get_coin_records_by_puzzle_hash(ph))))) == 3