Skip to content

Commit

Permalink
Fix a breaking change in get_puzzle_and_solution RPC (#13519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quexington authored Oct 6, 2022
1 parent 2b2a1e8 commit eb6aeb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions chia/rpc/full_node_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion tests/core/test_full_node_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb6aeb6

Please sign in to comment.