added get_coin_records_by_parent_ids to spend_sim (#9438)

* added get_coin_records_by_parent_ids to spend_sim

* fix linting errors
This commit is contained in:
Geoff Walmsley 2021-12-07 18:56:37 +01:00 committed by GitHub
parent 8db6ee540d
commit a085d26670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -218,6 +218,20 @@ class SimClient:
async def get_coin_record_by_name(self, name: bytes32) -> CoinRecord:
return await self.service.mempool_manager.coin_store.get_coin_record(name)
async def get_coin_records_by_parent_ids(
self,
parent_ids: List[bytes32],
start_height: Optional[int] = None,
end_height: Optional[int] = None,
include_spent_coins: bool = False,
) -> List[CoinRecord]:
kwargs: Dict[str, Any] = {"include_spent_coins": include_spent_coins, "parent_ids": parent_ids}
if start_height is not None:
kwargs["start_height"] = start_height
if end_height is not None:
kwargs["end_height"] = end_height
return await self.service.mempool_manager.coin_store.get_coin_records_by_parent_ids(**kwargs)
async def get_coin_records_by_puzzle_hash(
self,
puzzle_hash: bytes32,

View File

@ -137,5 +137,11 @@ class TestSimClient:
# get_puzzle_and_solution
coin_solution = await sim_client.get_puzzle_and_solution(spendable_coin.name(), latest_block.height)
assert coin_solution
# get_coin_records_by_parent_ids
new_coin = next(x.coin for x in additions if x.coin.puzzle_hash == puzzle_hash)
coin_records = await sim_client.get_coin_records_by_parent_ids([spendable_coin.name()])
assert coin_records[0].coin.name() == new_coin.name()
finally:
await sim.close()