Пример #1
0
def text_search_assets(api_root, transactions_api_full_url, alice_pubkey,
                       alice_privkey):
    # check if the fixture was already executed
    response = requests.get(api_root + '/assets',
                            params={'search': 'bigchaindb'})
    response = response.json()
    if len(response) == 3:
        assets = {}
        for asset in response:
            assets[asset['id']] = asset['data']
        return assets

    # define the assets that will be used by text_search tests
    assets = [
        {'msg': 'Hello BigchainDB 1!'},
        {'msg': 'Hello BigchainDB 2!'},
        {'msg': 'Hello BigchainDB 3!'}
    ]

    # write the assets to BigchainDB
    assets_by_txid = {}
    for asset in assets:
        tx = Transaction.create(
            tx_signers=[alice_pubkey],
            recipients=[([alice_pubkey], 1)],
            asset=asset,
            metadata={'But here\'s my number': 'So call me maybe'},
        )
        tx_signed = tx.sign([alice_privkey])
        requests.post(transactions_api_full_url, json=tx_signed.to_dict())
        assets_by_txid[tx_signed.id] = asset

    # return the assets indexed with the txid that created the asset
    return assets_by_txid
Пример #2
0
def alice_transaction_obj(alice_pubkey):
    serial_number = b64encode(urandom(10), altchars=b'-_').decode()
    return Transaction.create(
        tx_signers=[alice_pubkey],
        recipients=[([alice_pubkey], 1)],
        asset={'serial_number': serial_number},
    )
Пример #3
0
def persisted_random_transaction(alice_pubkey, alice_privkey):
    from uuid import uuid4
    from bigchaindb_driver.common.transaction import Transaction
    asset = {'data': {'x': str(uuid4())}}
    tx = Transaction.create(
        tx_signers=[alice_pubkey],
        recipients=[([alice_pubkey], 1)],
        asset=asset,
    )
    return tx.sign([alice_privkey]).to_dict()
Пример #4
0
def sent_persisted_random_transaction(alice_pubkey, alice_privkey,
                                      transactions_api_full_url):
    from uuid import uuid4
    from bigchaindb_driver.common.transaction import Transaction
    asset = {'data': {'x': str(uuid4())}}
    tx = Transaction.create(
        tx_signers=[alice_pubkey],
        recipients=[([alice_pubkey], 1)],
        asset=asset,
    )
    tx_signed = tx.sign([alice_privkey])
    response = requests.post(transactions_api_full_url,
                             json=tx_signed.to_dict())
    return response.json()