#!/usr/bin/env python3
from __future__ import annotations

import pathlib

KIB = 2**10
MIB = 2**20
GIB = 2**30

BUF = b'A' * MIB

SIZES = [
    # 0 layers, Merkle root hash is all NUL
    0,
    # 1 layer,  0 B < N <= 4096 bytes, Markle root hash is hash of only block
    1, 100, 1000, 4095, 4096,
    # 2 layers, 4 kiB < N <= 512 kiB
    4097, 8191, 8192, 8193, 524287, 524288,
    # 3 layers, 512 kiB < N <= 64 MiB
    524289, 1234567, 64 * MIB - 1, 64 * MIB,
    # 4 layers, 64 MiB < N <= 8 GiB
    64 * MIB + 1, 123456789, 8 * GIB,
]

dest_dir = pathlib.Path('tests/data/A')
dest_dir.mkdir(parents=True, exist_ok=True)

for size in SIZES:
    with open(dest_dir / f'{size:012_}_bytes', 'wb') as f:
        while size > 0:
            f.write(BUF[:size])
            size -= len(BUF)
