This commit is contained in:
almog 2020-12-09 16:16:43 +02:00 committed by Yostra
parent 16670452c4
commit aa69a3c2b7
1 changed files with 15 additions and 4 deletions

View File

@ -255,9 +255,20 @@ class TestWeightProof:
sub_epochs = 2
blocks = default_10000_blocks
header_cache, height_to_hash, sub_blocks = await load_blocks_dont_validate(blocks)
sub_epoch_end, _ = get_prev_ses_block(sub_blocks, blocks[-1].header_hash)
sub_epoch_end, num_of_blocks = get_prev_ses_block(sub_blocks, blocks[-1].header_hash)
print("num of blocks to first ses: ", num_of_blocks)
sub_epochs_left = sub_epochs
curr = sub_epoch_end
num_of_blocks = 200
while True:
if curr.sub_epoch_summary_included is not None:
print(f"ses at {curr.sub_block_height}")
sub_epochs_left -= 1
if sub_epochs_left <= 0:
break
# next sub block
curr = sub_blocks[curr.prev_hash]
num_of_blocks += 1
num_of_blocks += 1
curr = sub_blocks[curr.prev_hash]
print(f"fork point is {curr.sub_block_height} (not included)")
print(f"num of blocks in proof: {num_of_blocks}")
@ -265,10 +276,10 @@ class TestWeightProof:
wpf = WeightProofHandler(test_constants, BlockCacheMock(sub_blocks, height_to_hash, header_cache))
wpf.log.setLevel(logging.INFO)
initialize_logging("", {"log_stdout": True}, DEFAULT_ROOT_PATH)
wp = wpf.create_proof_of_weight(uint32(len(header_cache)), uint32(num_of_blocks), blocks[-1].header_hash)
wp = wpf.create_proof_of_weight(uint32(300), uint32(num_of_blocks), blocks[-1].header_hash)
assert wp is not None
assert len(wp.sub_epochs) == sub_epochs
# todo for each sampled sub epoch, validate number of segments
ses_block, _ = get_prev_ses_block(sub_blocks, curr.header_hash)
assert wpf.validate_weight_proof(wp, curr)
assert wpf.validate_weight_proof(wp, ses_block)