async def _test_map_summaries(blocks, header_cache, height_to_hash, sub_blocks, summaries): curr = sub_blocks[blocks[-1].header_hash] orig_summaries: Dict[int, SubEpochSummary] = {} while curr.sub_block_height > 0: if curr.sub_epoch_summary_included is not None: orig_summaries[ curr.sub_block_height] = curr.sub_epoch_summary_included # next sub block curr = sub_blocks[curr.prev_hash] wpf = WeightProofHandler( test_constants, BlockCache(sub_blocks, height_to_hash, header_cache, summaries)) wp = await wpf.get_proof_of_weight(blocks[-1].header_hash) assert wp is not None # sub epoch summaries validate hashes summaries, sub_epoch_data_weight = _map_summaries( test_constants.SUB_EPOCH_SUB_BLOCKS, test_constants.GENESIS_SES_HASH, wp.sub_epochs, test_constants.DIFFICULTY_STARTING, ) assert len(summaries) == len(orig_summaries)
async def test_weight_proof_summaries_1000_blocks(self, default_1000_blocks): blocks = default_1000_blocks header_cache, height_to_hash, block_records, summaries = await load_blocks_dont_validate(blocks) wpf = WeightProofHandler(test_constants, BlockCache(block_records, header_cache, height_to_hash, summaries)) wp = await wpf.get_proof_of_weight(blocks[-1].header_hash) summaries, sub_epoch_data_weight = _map_summaries( wpf.constants.SUB_EPOCH_BLOCKS, wpf.constants.GENESIS_CHALLENGE, wp.sub_epochs, wpf.constants.DIFFICULTY_STARTING, ) assert wpf._validate_summaries_weight(sub_epoch_data_weight, summaries, wp)