Ejemplo n.º 1
0
def test_generate_block_candidates_2(tmp_path):
    index = BlockIndex(tmp_path, RegTest(), Logger(debug=True))
    chain = generate_random_header_chain(2000, RegTest().genesis.hash)
    fork = generate_random_header_chain(200, chain[-10 - 1].hash)
    index.add_headers(chain)
    index.add_headers(fork)
    for x in fork:
        block_info = index.get_block_info(x.hash)
        block_info.status = BlockStatus.invalid
        index.insert_block_info(block_info)
    index.db.close()
    new_index = BlockIndex(tmp_path, RegTest(), Logger(debug=True))
    assert len(new_index.block_candidates) == 2000
Ejemplo n.º 2
0
def test_block_candidates_3(tmp_path):
    index = BlockIndex(tmp_path, RegTest(), Logger(debug=True))
    chain = generate_random_header_chain(2000, RegTest().genesis.hash)
    fork = generate_random_header_chain(200, chain[-10 - 1].hash)
    index.add_headers(chain)
    index.add_headers(fork)
    for x in chain:
        block_info = index.get_block_info(x.hash)
        block_info.status = BlockStatus.in_active_chain
        index.insert_block_info(block_info)
    index.db.close()
    new_index = BlockIndex(tmp_path, RegTest(), Logger(debug=True))
    assert new_index.get_download_candidates() == [x.hash for x in fork]