mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge pull request #1532 from bigchaindb/feat/1531/consistent-naming
Consistent naming of `transaction_id`
This commit is contained in:
commit
dda6517451
@ -157,7 +157,7 @@ def get_spent(conn, transaction_id, output):
|
||||
{'$match': {
|
||||
'block.transactions.inputs': {
|
||||
'$elemMatch': {
|
||||
'fulfills.txid': transaction_id,
|
||||
'fulfills.transaction_id': transaction_id,
|
||||
'fulfills.output': output,
|
||||
},
|
||||
},
|
||||
@ -166,7 +166,7 @@ def get_spent(conn, transaction_id, output):
|
||||
{'$match': {
|
||||
'block.transactions.inputs': {
|
||||
'$elemMatch': {
|
||||
'fulfills.txid': transaction_id,
|
||||
'fulfills.transaction_id': transaction_id,
|
||||
'fulfills.output': output,
|
||||
},
|
||||
},
|
||||
|
@ -68,10 +68,10 @@ def create_bigchain_secondary_index(conn, dbname):
|
||||
.create_index('block.transactions.outputs.public_keys',
|
||||
name='outputs')
|
||||
|
||||
# secondary index on inputs/transaction links (txid, output)
|
||||
# secondary index on inputs/transaction links (transaction_id, output)
|
||||
conn.conn[dbname]['bigchain']\
|
||||
.create_index([
|
||||
('block.transactions.inputs.fulfills.txid', ASCENDING),
|
||||
('block.transactions.inputs.fulfills.transaction_id', ASCENDING),
|
||||
('block.transactions.inputs.fulfills.output', ASCENDING),
|
||||
], name='inputs')
|
||||
|
||||
|
@ -122,7 +122,8 @@ def get_spent(connection, transaction_id, output):
|
||||
.get_all([transaction_id, output], index='inputs')
|
||||
.concat_map(lambda doc: doc['block']['transactions'])
|
||||
.filter(lambda transaction: transaction['inputs'].contains(
|
||||
lambda input_: input_['fulfills'] == {'txid': transaction_id, 'output': output})))
|
||||
lambda input_: input_['fulfills'] == {
|
||||
'transaction_id': transaction_id, 'output': output})))
|
||||
|
||||
|
||||
@register_query(RethinkDBConnection)
|
||||
@ -286,7 +287,8 @@ def unwind_block_transactions(block):
|
||||
def get_spending_transactions(connection, links):
|
||||
query = (
|
||||
r.table('bigchain')
|
||||
.get_all(*[(l['txid'], l['output']) for l in links], index='inputs')
|
||||
.get_all(*[(l['transaction_id'], l['output']) for l in links],
|
||||
index='inputs')
|
||||
.concat_map(unwind_block_transactions)
|
||||
# filter transactions spending output
|
||||
.filter(lambda doc: r.expr(links).set_intersection(
|
||||
|
@ -79,15 +79,15 @@ def create_bigchain_secondary_index(connection, dbname):
|
||||
.concat_map(lambda tx: tx['outputs']['public_keys'])
|
||||
.reduce(lambda l, r: l + r), multi=True))
|
||||
|
||||
# secondary index on inputs/transaction links (txid, output)
|
||||
# secondary index on inputs/transaction links (transaction_id, output)
|
||||
connection.run(
|
||||
r.db(dbname)
|
||||
.table('bigchain')
|
||||
.index_create('inputs',
|
||||
r.row['block']['transactions']
|
||||
.concat_map(lambda tx: tx['inputs']['fulfills'])
|
||||
.with_fields('txid', 'output')
|
||||
.map(lambda fulfills: [fulfills['txid'],
|
||||
.with_fields('transaction_id', 'output')
|
||||
.map(lambda fulfills: [fulfills['transaction_id'],
|
||||
fulfills['output']]),
|
||||
multi=True))
|
||||
|
||||
|
@ -204,13 +204,13 @@ definitions:
|
||||
additionalProperties: false
|
||||
required:
|
||||
- output
|
||||
- txid
|
||||
- transaction_id
|
||||
properties:
|
||||
output:
|
||||
"$ref": "#/definitions/offset"
|
||||
description: |
|
||||
Index of the output containing the condition being fulfilled
|
||||
txid:
|
||||
transaction_id:
|
||||
"$ref": "#/definitions/sha3_hexdigest"
|
||||
description: |
|
||||
Transaction ID containing the output to spend
|
||||
|
@ -175,7 +175,7 @@ class TransactionLink(object):
|
||||
:class:`~bigchaindb.common.transaction.TransactionLink`
|
||||
"""
|
||||
try:
|
||||
return cls(link['txid'], link['output'])
|
||||
return cls(link['transaction_id'], link['output'])
|
||||
except TypeError:
|
||||
return cls()
|
||||
|
||||
@ -189,7 +189,7 @@ class TransactionLink(object):
|
||||
return None
|
||||
else:
|
||||
return {
|
||||
'txid': self.txid,
|
||||
'transaction_id': self.txid,
|
||||
'output': self.output,
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ class BlockListApi(Resource):
|
||||
"valid", "invalid", "undecided".
|
||||
"""
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('tx_id', type=str, required=True)
|
||||
parser.add_argument('transaction_id', type=str, required=True)
|
||||
parser.add_argument('status', type=str, case_sensitive=False,
|
||||
choices=[Bigchain.BLOCK_VALID, Bigchain.BLOCK_INVALID, Bigchain.BLOCK_UNDECIDED])
|
||||
|
||||
args = parser.parse_args(strict=True)
|
||||
tx_id = args['tx_id']
|
||||
tx_id = args['transaction_id']
|
||||
status = args['status']
|
||||
|
||||
pool = current_app.config['bigchain_pool']
|
||||
|
@ -17,11 +17,11 @@ class StatusApi(Resource):
|
||||
``<status>`` is one of "valid", "invalid", "undecided", "backlog".
|
||||
"""
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('tx_id', type=str)
|
||||
parser.add_argument('transaction_id', type=str)
|
||||
parser.add_argument('block_id', type=str)
|
||||
|
||||
args = parser.parse_args(strict=True)
|
||||
tx_id = args['tx_id']
|
||||
tx_id = args['transaction_id']
|
||||
block_id = args['block_id']
|
||||
|
||||
# logical xor - exactly one query argument required
|
||||
|
@ -26,7 +26,7 @@ from bigchaindb.events import EventTypes
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
POISON_PILL = 'POISON_PILL'
|
||||
EVENTS_ENDPOINT = '/api/v1/streams/valid_tx'
|
||||
EVENTS_ENDPOINT = '/api/v1/streams/valid_transactions'
|
||||
|
||||
|
||||
def _multiprocessing_to_asyncio(in_queue, out_queue, loop):
|
||||
@ -91,7 +91,7 @@ class Dispatcher:
|
||||
asset_id = tx['id'] if tx['operation'] == 'CREATE' else tx['asset']['id']
|
||||
data = {'block_id': block['id'],
|
||||
'asset_id': asset_id,
|
||||
'tx_id': tx['id']}
|
||||
'transaction_id': tx['id']}
|
||||
str_buffer.append(json.dumps(data))
|
||||
|
||||
for _, websocket in self.subscribers.items():
|
||||
|
@ -76,7 +76,7 @@ Content-Type: application/json
|
||||
|
||||
|
||||
TPLS['get-statuses-tx-request'] = """\
|
||||
GET /statuses?tx_id=%(txid)s HTTP/1.1
|
||||
GET /statuses?transaction_id=%(txid)s HTTP/1.1
|
||||
Host: example.com
|
||||
|
||||
"""
|
||||
@ -151,7 +151,7 @@ Content-Type: application/json
|
||||
|
||||
|
||||
TPLS['get-block-txid-request'] = """\
|
||||
GET /api/v1/blocks?tx_id=%(txid)s HTTP/1.1
|
||||
GET /api/v1/blocks?transaction_id=%(txid)s HTTP/1.1
|
||||
Host: example.com
|
||||
|
||||
"""
|
||||
|
@ -133,7 +133,7 @@ If there is only one *current owner*, the fulfillment will be a simple signature
|
||||
"fulfillment": "cf:4:RxFzIE679tFBk8zwEgizhmTuciAylvTUwy6EL6ehddHFJOhK5F4IjwQ1xLu2oQK9iyRCZJdfWAefZVjTt3DeG5j2exqxpGliOPYseNkRAWEakqJ_UrCwgnj92dnFRAEE",
|
||||
"fulfills": {
|
||||
"output": 0,
|
||||
"txid": "11b3e7d893cc5fdfcf1a1706809c7def290a3b10b0bef6525d10b024649c42d3"
|
||||
"transaction_id": "11b3e7d893cc5fdfcf1a1706809c7def290a3b10b0bef6525d10b024649c42d3"
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ If there are multiple *current owners*, the fulfillment will be a little differe
|
||||
"fulfillment": "cf:2:AQIBAgEBYwAEYEv6O5HjHGl7OWo2Tu5mWcWQcL_OGrFuUjyej-dK3LM99TbZsRd8c9luQhU30xCH5AdNaupxg-pLHuk8DoSaDA1MHQGXUZ80a_cV-4UaaaCpdey8K0CEcJxre0X96hTHCwABAWMABGBnsuHExhuSj5Mdm-q0KoPgX4nAt0s00k1WTMCzuUpQIp6aStLoTSMlsvS4fmDtOSv9gubekKLuHTMAk-LQFSKF1JdzwaVWAA2UOv0v_OS2gY3A-r0kRq8HtzjYdcmVswUA",
|
||||
"fulfills": {
|
||||
"output": 0,
|
||||
"txid": "e4805f1bfc999d6409b38e3a4c3b2fafad7c1280eb0d441da7083e945dd89eb8"
|
||||
"transaction_id": "e4805f1bfc999d6409b38e3a4c3b2fafad7c1280eb0d441da7083e945dd89eb8"
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,4 +161,4 @@ If there are multiple *current owners*, the fulfillment will be a little differe
|
||||
- ``fulfillment``: A crypto-conditions URI that encodes the cryptographic fulfillments like signatures and others;'cf' indicates this is a fulfillment, '2' indicates the condition type is THRESHOLD-SHA-256 (while '4' in `One Current Owner`_ indicates its condition type is ED25519).
|
||||
- ``fulfills``: Pointer to an output from a previous transaction that is being spent
|
||||
- ``output``: The index of the output in a previous transaction
|
||||
- ``txid``: ID of the transaction
|
||||
- ``transaction_id``: ID of the transaction
|
||||
|
@ -42,9 +42,9 @@ that allows you to discover the BigchainDB API endpoints:
|
||||
Transactions
|
||||
-------------------
|
||||
|
||||
.. http:get:: /api/v1/transactions/{tx_id}
|
||||
.. http:get:: /api/v1/transactions/{transaction_id}
|
||||
|
||||
Get the transaction with the ID ``tx_id``.
|
||||
Get the transaction with the ID ``transaction_id``.
|
||||
|
||||
This endpoint returns a transaction if it was included in a ``VALID`` block.
|
||||
All instances of a transaction in invalid/undecided blocks or the backlog
|
||||
@ -53,8 +53,8 @@ Transactions
|
||||
invalid/undecided blocks or the backlog, then the response will be ``404 Not
|
||||
Found``.
|
||||
|
||||
:param tx_id: transaction ID
|
||||
:type tx_id: hex string
|
||||
:param transaction_id: transaction ID
|
||||
:type transaction_id: hex string
|
||||
|
||||
**Example request**:
|
||||
|
||||
@ -215,19 +215,19 @@ Statuses
|
||||
A link to the resource is also provided in the returned payload under
|
||||
``_links``.
|
||||
|
||||
:query string tx_id: transaction ID
|
||||
:query string transaction_id: transaction ID
|
||||
:query string block_id: block ID
|
||||
|
||||
.. note::
|
||||
|
||||
Exactly one of the ``tx_id`` or ``block_id`` query parameters must be
|
||||
Exactly one of the ``transaction_id`` or ``block_id`` query parameters must be
|
||||
used together with this endpoint (see below for getting `transaction
|
||||
statuses <#get--statuses?tx_id=tx_id>`_ and `block statuses
|
||||
<#get--statuses?block_id=block_id>`_).
|
||||
|
||||
.. _get_status_of_transaction:
|
||||
|
||||
.. http:get:: /api/v1/statuses?tx_id={tx_id}
|
||||
.. http:get:: /api/v1/statuses?transaction_id={transaction_id}
|
||||
|
||||
Get the status of a transaction.
|
||||
|
||||
@ -298,8 +298,8 @@ Assets
|
||||
|
||||
.. http:get:: /api/v1/assets?search={text_search}
|
||||
|
||||
Return all assets that match a given text search. The asset is returned
|
||||
with the ``id`` of the transaction that created the asset.
|
||||
Return all assets that match a given text search. The ``id`` of the asset
|
||||
is the same ``id`` of the transaction that created the asset.
|
||||
|
||||
If no assets match the text search it returns an empty list.
|
||||
|
||||
@ -398,12 +398,12 @@ Advanced Usage
|
||||
The following endpoints are more advanced and meant for debugging and transparency purposes.
|
||||
|
||||
More precisely, the `blocks endpoint <#blocks>`_ allows you to retrieve a block by ``block_id`` as well the list of blocks that
|
||||
a certain transaction with ``tx_id`` occured in (a transaction can occur in multiple ``invalid`` blocks until it
|
||||
a certain transaction with ``transaction_id`` occured in (a transaction can occur in multiple ``invalid`` blocks until it
|
||||
either gets rejected or validated by the system). This endpoint gives the ability to drill down on the lifecycle of a
|
||||
transaction
|
||||
|
||||
The `votes endpoint <#votes>`_ contains all the voting information for a specific block. So after retrieving the
|
||||
``block_id`` for a given ``tx_id``, one can now simply inspect the votes that happened at a specific time on that block.
|
||||
``block_id`` for a given ``transaction_id``, one can now simply inspect the votes that happened at a specific time on that block.
|
||||
|
||||
|
||||
Blocks
|
||||
@ -439,8 +439,8 @@ Blocks
|
||||
.. http:get:: /api/v1/blocks
|
||||
|
||||
The unfiltered ``/blocks`` endpoint without any query parameters returns a `400` status code.
|
||||
The list endpoint should be filtered with a ``tx_id`` query parameter,
|
||||
see the ``/blocks?tx_id={tx_id}&status={UNDECIDED|VALID|INVALID}``
|
||||
The list endpoint should be filtered with a ``transaction_id`` query parameter,
|
||||
see the ``/blocks?transaction_id={transaction_id}&status={UNDECIDED|VALID|INVALID}``
|
||||
`endpoint <#get--blocks?tx_id=tx_id&status=UNDECIDED|VALID|INVALID>`_.
|
||||
|
||||
|
||||
@ -459,9 +459,9 @@ Blocks
|
||||
|
||||
:statuscode 400: The request wasn't understood by the server, e.g. just requesting ``/blocks`` without the ``block_id``.
|
||||
|
||||
.. http:get:: /api/v1/blocks?tx_id={tx_id}&status={UNDECIDED|VALID|INVALID}
|
||||
.. http:get:: /api/v1/blocks?transaction_id={transaction_id}&status={UNDECIDED|VALID|INVALID}
|
||||
|
||||
Retrieve a list of ``block_id`` with their corresponding status that contain a transaction with the ID ``tx_id``.
|
||||
Retrieve a list of ``block_id`` with their corresponding status that contain a transaction with the ID ``transaction_id``.
|
||||
|
||||
Any blocks, be they ``UNDECIDED``, ``VALID`` or ``INVALID`` will be
|
||||
returned if no status filter is provided.
|
||||
@ -470,7 +470,7 @@ Blocks
|
||||
In case no block was found, an empty list and an HTTP status code
|
||||
``200 OK`` is returned, as the request was still successful.
|
||||
|
||||
:query string tx_id: transaction ID *(required)*
|
||||
:query string transaction_id: transaction ID *(required)*
|
||||
:query string status: Filter blocks by their status. One of ``VALID``, ``UNDECIDED`` or ``INVALID``.
|
||||
|
||||
**Example request**:
|
||||
@ -485,8 +485,8 @@ Blocks
|
||||
|
||||
:resheader Content-Type: ``application/json``
|
||||
|
||||
:statuscode 200: A list of blocks containing a transaction with ID ``tx_id`` was found and returned.
|
||||
:statuscode 400: The request wasn't understood by the server, e.g. just requesting ``/blocks``, without defining ``tx_id``.
|
||||
:statuscode 200: A list of blocks containing a transaction with ID ``transaction_id`` was found and returned.
|
||||
:statuscode 400: The request wasn't understood by the server, e.g. just requesting ``/blocks``, without defining ``transaction_id``.
|
||||
|
||||
|
||||
Votes
|
||||
|
@ -32,7 +32,7 @@ response contains a ``streams`` property:
|
||||
|
||||
{
|
||||
...,
|
||||
"streams": "ws://example.com:9985/api/v1/streams/valid_tx",
|
||||
"streams": "ws://example.com:9985/api/v1/streams/valid_transactions",
|
||||
...
|
||||
}
|
||||
|
||||
@ -56,8 +56,8 @@ BigchainDB node will be ignored.
|
||||
Streams will always be under the WebSocket protocol (so ``ws://`` or
|
||||
``wss://``) and accessible as extensions to the ``/api/v<version>/streams/``
|
||||
API root URL (for example, `validated transactions <#valid-transactions>`_
|
||||
would be accessible under ``/api/v1/streams/valid_tx``). If you're running your
|
||||
own BigchainDB instance and need help determining its root URL,
|
||||
would be accessible under ``/api/v1/streams/valid_transactions``). If you're
|
||||
running your own BigchainDB instance and need help determining its root URL,
|
||||
then see the page titled :ref:`Determining the API Root URL`.
|
||||
|
||||
All messages sent in a stream are in the JSON format.
|
||||
@ -77,7 +77,7 @@ All messages sent in a stream are in the JSON format.
|
||||
Valid Transactions
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``/valid_tx``
|
||||
``/valid_transactions``
|
||||
|
||||
Streams an event for any newly validated transactions. Message bodies contain
|
||||
the transaction's ID, associated asset ID, and containing block's ID.
|
||||
@ -87,7 +87,7 @@ Example message:
|
||||
.. code:: JSON
|
||||
|
||||
{
|
||||
"tx_id": "<sha3-256 hash>",
|
||||
"transaction_id": "<sha3-256 hash>",
|
||||
"asset_id": "<sha3-256 hash>",
|
||||
"block_id": "<sha3-256 hash>"
|
||||
}
|
||||
@ -98,6 +98,6 @@ Example message:
|
||||
Transactions in BigchainDB are validated in batches ("blocks") and will,
|
||||
therefore, be streamed in batches. Each block can contain up to a 1000
|
||||
transactions, ordered by the time at which they were included in the block.
|
||||
The ``/valid_tx`` stream will send these transactions in the same order
|
||||
that the block stored them in, but this does **NOT** guarantee that you
|
||||
will recieve the events in that same order.
|
||||
The ``/valid_transactions`` stream will send these transactions in the same
|
||||
order that the block stored them in, but this does **NOT** guarantee that
|
||||
you will recieve the events in that same order.
|
||||
|
@ -363,7 +363,7 @@ def test_transaction_link_serialization():
|
||||
|
||||
tx_id = 'a transaction id'
|
||||
expected = {
|
||||
'txid': tx_id,
|
||||
'transaction_id': tx_id,
|
||||
'output': 0,
|
||||
}
|
||||
tx_link = TransactionLink(tx_id, 0)
|
||||
@ -386,7 +386,7 @@ def test_transaction_link_deserialization():
|
||||
tx_id = 'a transaction id'
|
||||
expected = TransactionLink(tx_id, 0)
|
||||
tx_link = {
|
||||
'txid': tx_id,
|
||||
'transaction_id': tx_id,
|
||||
'output': 0,
|
||||
}
|
||||
tx_link = TransactionLink.from_dict(tx_link)
|
||||
@ -845,7 +845,7 @@ def test_create_transfer_transaction_single_io(tx, user_pub, user2_pub,
|
||||
],
|
||||
'fulfillment': None,
|
||||
'fulfills': {
|
||||
'txid': tx.id,
|
||||
'transaction_id': tx.id,
|
||||
'output': 0
|
||||
}
|
||||
}
|
||||
@ -894,7 +894,7 @@ def test_create_transfer_transaction_multiple_io(user_pub, user_priv,
|
||||
],
|
||||
'fulfillment': None,
|
||||
'fulfills': {
|
||||
'txid': tx.id,
|
||||
'transaction_id': tx.id,
|
||||
'output': 0
|
||||
}
|
||||
}, {
|
||||
@ -903,7 +903,7 @@ def test_create_transfer_transaction_multiple_io(user_pub, user_priv,
|
||||
],
|
||||
'fulfillment': None,
|
||||
'fulfills': {
|
||||
'txid': tx.id,
|
||||
'transaction_id': tx.id,
|
||||
'output': 1
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
|
||||
block_invalid = b.create_block([tx])
|
||||
b.write_block(block_invalid)
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
|
||||
# test if block is retrieved as undecided
|
||||
assert res.status_code == 200
|
||||
assert block_invalid.id in res.json
|
||||
@ -51,7 +51,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
|
||||
vote = b.vote(block_invalid.id, b.get_last_voted_block().id, False)
|
||||
b.write_vote(vote)
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
|
||||
# test if block is retrieved as invalid
|
||||
assert res.status_code == 200
|
||||
assert block_invalid.id in res.json
|
||||
@ -61,7 +61,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
|
||||
block_valid = b.create_block([tx, tx2])
|
||||
b.write_block(block_valid)
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
|
||||
# test if block is retrieved as undecided
|
||||
assert res.status_code == 200
|
||||
assert block_valid.id in res.json
|
||||
@ -71,7 +71,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
|
||||
vote = b.vote(block_valid.id, block_invalid.id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
|
||||
# test if block is retrieved as valid
|
||||
assert res.status_code == 200
|
||||
assert block_valid.id in res.json
|
||||
@ -96,19 +96,19 @@ def test_get_blocks_by_txid_and_status_endpoint(b, client):
|
||||
block_valid = b.create_block([tx, tx2])
|
||||
b.write_block(block_valid)
|
||||
|
||||
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_INVALID))
|
||||
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_INVALID))
|
||||
# test if no blocks are retrieved as invalid
|
||||
assert res.status_code == 200
|
||||
assert len(res.json) == 0
|
||||
|
||||
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
|
||||
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
|
||||
# test if both blocks are retrieved as undecided
|
||||
assert res.status_code == 200
|
||||
assert block_valid.id in res.json
|
||||
assert block_invalid.id in res.json
|
||||
assert len(res.json) == 2
|
||||
|
||||
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
|
||||
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
|
||||
# test if no blocks are retrieved as valid
|
||||
assert res.status_code == 200
|
||||
assert len(res.json) == 0
|
||||
@ -121,18 +121,18 @@ def test_get_blocks_by_txid_and_status_endpoint(b, client):
|
||||
vote = b.vote(block_valid.id, block_invalid.id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_INVALID))
|
||||
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_INVALID))
|
||||
# test if the invalid block is retrieved as invalid
|
||||
assert res.status_code == 200
|
||||
assert block_invalid.id in res.json
|
||||
assert len(res.json) == 1
|
||||
|
||||
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
|
||||
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
|
||||
# test if no blocks are retrieved as undecided
|
||||
assert res.status_code == 200
|
||||
assert len(res.json) == 0
|
||||
|
||||
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
|
||||
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
|
||||
# test if the valid block is retrieved as valid
|
||||
assert res.status_code == 200
|
||||
assert block_valid.id in res.json
|
||||
@ -141,11 +141,11 @@ def test_get_blocks_by_txid_and_status_endpoint(b, client):
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_blocks_by_txid_endpoint_returns_empty_list_not_found(client):
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=')
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=')
|
||||
assert res.status_code == 200
|
||||
assert len(res.json) == 0
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=123')
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123')
|
||||
assert res.status_code == 200
|
||||
assert len(res.json) == 0
|
||||
|
||||
@ -159,17 +159,17 @@ def test_get_blocks_by_txid_endpoint_returns_400_bad_query_params(client):
|
||||
assert res.status_code == 400
|
||||
assert res.json == {
|
||||
'message': {
|
||||
'tx_id': 'Missing required parameter in the JSON body or the post body or the query string'
|
||||
'transaction_id': 'Missing required parameter in the JSON body or the post body or the query string'
|
||||
}
|
||||
}
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=123&foo=123')
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&foo=123')
|
||||
assert res.status_code == 400
|
||||
assert res.json == {
|
||||
'message': 'Unknown arguments: foo'
|
||||
}
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?tx_id=123&status=123')
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&status=123')
|
||||
assert res.status_code == 400
|
||||
assert res.json == {
|
||||
'message': {
|
||||
|
@ -14,7 +14,7 @@ def api_v1_info():
|
||||
'statuses': 'http://localhost/api/v1/statuses/',
|
||||
'assets': 'http://localhost/api/v1/assets/',
|
||||
'outputs': 'http://localhost/api/v1/outputs/',
|
||||
'streams': 'ws://localhost:9985/api/v1/streams/valid_tx',
|
||||
'streams': 'ws://localhost:9985/api/v1/streams/valid_transactions',
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ STATUSES_ENDPOINT = '/api/v1/statuses'
|
||||
def test_get_transaction_status_endpoint(b, client, user_pk):
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
tx, status = b.get_transaction(input_tx.txid, include_status=True)
|
||||
res = client.get(STATUSES_ENDPOINT + '?tx_id=' + input_tx.txid)
|
||||
res = client.get(STATUSES_ENDPOINT + '?transaction_id=' + input_tx.txid)
|
||||
assert status == res.json['status']
|
||||
assert res.json['_links']['tx'] == '/transactions/{}'.format(input_tx.txid)
|
||||
assert res.status_code == 200
|
||||
@ -18,7 +18,7 @@ def test_get_transaction_status_endpoint(b, client, user_pk):
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_transaction_status_endpoint_returns_404_if_not_found(client):
|
||||
res = client.get(STATUSES_ENDPOINT + '?tx_id=123')
|
||||
res = client.get(STATUSES_ENDPOINT + '?transaction_id=123')
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
@ -94,5 +94,5 @@ def test_get_status_endpoint_returns_400_bad_query_params(client):
|
||||
res = client.get(STATUSES_ENDPOINT + '?ts_id=123')
|
||||
assert res.status_code == 400
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?tx_id=123&block_id=123')
|
||||
res = client.get(STATUSES_ENDPOINT + '?transaction_id=123&block_id=123')
|
||||
assert res.status_code == 400
|
||||
|
@ -132,7 +132,7 @@ def test_websocket_block_event(b, _block, test_client, loop):
|
||||
for tx in block['block']['transactions']:
|
||||
result = yield from ws.receive()
|
||||
json_result = json.loads(result.data)
|
||||
assert json_result['tx_id'] == tx['id']
|
||||
assert json_result['transaction_id'] == tx['id']
|
||||
# Since the transactions are all CREATEs, asset id == transaction id
|
||||
assert json_result['asset_id'] == tx['id']
|
||||
assert json_result['block_id'] == block['id']
|
||||
@ -184,4 +184,4 @@ def test_integration_from_webapi_to_websocket(monkeypatch, client, loop):
|
||||
|
||||
result = loop.run_until_complete(ws.receive())
|
||||
json_result = json.loads(result.data)
|
||||
assert json_result['tx_id'] == tx.id
|
||||
assert json_result['transaction_id'] == tx.id
|
||||
|
Loading…
x
Reference in New Issue
Block a user