예제 #1
0
def test_api_get_block_by_hash():

    has_kb, has_mb = False, False
    while not has_kb or not has_mb:
        # the latest block could be both micro or key block
        latest_block = EPOCH_CLI.get_top_block()
        has_mb = latest_block.hash.startswith(
            "mh_") or has_mb  # check if is a microblock
        has_kb = latest_block.hash.startswith(
            "kh_") or has_kb  # check if is a keyblock
        print(has_kb, has_mb, latest_block.hash)
        # create a transaction so the top block is going to be an micro block
        if not has_mb:
            account = Account.generate().get_address()
            EPOCH_CLI.spend(ACCOUNT, account, 100)
        # wait for the next block
        # client.wait_for_next_block()
        block = EPOCH_CLI.get_block_by_hash(hash=latest_block.hash)
        # assert block.hash == latest_block.hash
        assert block.height == latest_block.height
예제 #2
0
def test_api_get_top_block():
    block = EPOCH_CLI.get_top_block()
    # assert type(block) == BlockWithTx
    assert block.height > 0