Example #1
0
    def run(self):

        b = BigchainDB()

        bicycle = {
            'data': {
                'pripid': '88273712778381',
                'reg_no': '88273712778381',
                'origin_entname': 'xxxxxxxxxxx'
            },
        }
        utctp = datetime.now().utcnow().timestamp()
        metadata = {'date': utctp}

        for i in range(self.transactions_per_thread):
            alice = generate_key_pair()

            prepared_creation_tx = Transaction.create(
                [alice.public_key],
                [([alice.public_key], 1)],
                metadata=metadata,
                asset=bicycle,
            ).sign([alice.private_key])

            res = b.write_transaction(prepared_creation_tx,
                                      f'broadcast_tx_{self.mode}')
            assert res[0] == 202
Example #2
0
def test_get_outputs_filtered(filter_spent, filter_unspent):
    from bigchaindb.common.transaction import TransactionLink
    from bigchaindb.tendermint.lib import BigchainDB

    go = 'bigchaindb.tendermint.fastquery.FastQuery.get_outputs_by_public_key'
    with patch(go) as get_outputs:
        get_outputs.return_value = [
            TransactionLink('a', 1),
            TransactionLink('b', 2)
        ]
        out = BigchainDB().get_outputs_filtered('abc')
    get_outputs.assert_called_once_with('abc')
    filter_spent.assert_not_called()
    filter_unspent.assert_not_called()
    assert out == get_outputs.return_value
Example #3
0
def test_get_outputs_filtered_only_unspent():
    from bigchaindb.common.transaction import TransactionLink
    from bigchaindb.tendermint.lib import BigchainDB

    go = 'bigchaindb.tendermint.fastquery.FastQuery.get_outputs_by_public_key'
    with patch(go) as get_outputs:
        get_outputs.return_value = [
            TransactionLink('a', 1),
            TransactionLink('b', 2)
        ]
        fs = 'bigchaindb.tendermint.fastquery.FastQuery.filter_spent_outputs'
        with patch(fs) as filter_spent:
            filter_spent.return_value = [TransactionLink('b', 2)]
            out = BigchainDB().get_outputs_filtered('abc', spent=False)
    get_outputs.assert_called_once_with('abc')
    assert out == [TransactionLink('b', 2)]
Example #4
0
def run_start(args):
    """Start the processes to run the node"""
    logger.info('BigchainDB Version %s', bigchaindb.__version__)

    run_recover(BigchainDB())

    try:
        if not args.skip_initialize_database:
            logger.info('Initializing database')
            _run_init()
    except DatabaseAlreadyExists:
        pass

    logger.info('Starting BigchainDB main process.')
    from bigchaindb.tendermint.commands import start
    start()