Пример #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_cli_inspect_transaction_by_hash():
    # fill the account from genesys
    na = Account.generate()
    amount = random.randint(50, 150)
    _, _, tx_hash = EPOCH_CLI.spend(ACCOUNT, na.get_address(), amount)
    # now inspect the transaction
    j = call_aecli('inspect', tx_hash)
    assert j.get("hash") == tx_hash
    assert j.get("block_height") > 0
    assert j.get("tx", {}).get("recipient_id") == na.get_address()
    assert j.get("tx", {}).get("sender_id") == ACCOUNT.get_address()
    assert j.get("tx", {}).get("amount") == amount
Пример #3
0
def test_name_transfer_ownership():
    name = EPOCH_CLI.AEName(random_domain())
    name.full_claim_blocking(ACCOUNT)
    assert name.status == AEName.Status.CLAIMED
    name.update_status()
    assert name.pointers[0]['id'] == ACCOUNT.get_address()
    assert name.pointers[0]['key'] == "account_pubkey"

    new_key_pair = Account.generate()
    # put some coins into the account so the account is in the state tree
    # otherwise it couldn't become the owner of an address.
    EPOCH_CLI.spend(ACCOUNT, new_key_pair.get_address(), 100)
    # now transfer the name to the other account
    name.transfer_ownership(ACCOUNT, new_key_pair.get_address())
    assert name.status == AEName.Status.TRANSFERRED
    # try changing the target using that new account
    name.update_status()
    name.update(new_key_pair, new_key_pair.get_address())
    name.update_status()
    assert len(name.pointers) > 0, 'Pointers should not be empty'
    assert name.pointers[0]['id'] == new_key_pair.get_address()
    assert name.pointers[0]['key'] == "account_pubkey"
Пример #4
0
def test_epoch_spend():
    account = Account.generate().get_address()
    EPOCH_CLI.spend(ACCOUNT, account, 100)
    account = EPOCH_CLI.get_account_by_pubkey(pubkey=account)
    balance = account.balance
    assert balance > 0