Пример #1
0
def test_chunk_root_calculation():
    with pytest.raises(ValueError):
        calc_chunk_root(b"\x00" * (COLLATION_SIZE - 1))
    with pytest.raises(ValueError):
        calc_chunk_root(b"\x00" * (COLLATION_SIZE + 1))
    with pytest.raises(ValueError):
        calc_chunk_root(b"\x00" * (COLLATION_SIZE - CHUNK_SIZE))
    with pytest.raises(ValueError):
        calc_chunk_root(b"\x00" * (COLLATION_SIZE + CHUNK_SIZE))

    chunk_number = COLLATION_SIZE // CHUNK_SIZE
    chunks = [b"\x00" * CHUNK_SIZE] * chunk_number
    body = b"".join(chunks)

    assert calc_chunk_root(body) == calc_merkle_root(chunks)
Пример #2
0
def test_invalid_merkle_root_calculation(leave_number):
    with pytest.raises(ValueError):
        calc_merkle_root([b""] * leave_number)
Пример #3
0
def test_merkle_root_calculation(leaves, root):
    assert calc_merkle_root(leaves) == root