1
0
mirror of https://github.com/bigchaindb/bigchaindb.git synced 2024-06-28 00:27:45 +02:00

Merge pull request #1853 from bigchaindb/rm-descriptions-from-yaml-files

Removed all 'description' keys & values from the YAML files
This commit is contained in:
Troy McConaghy 2017-11-16 18:22:52 +01:00 committed by GitHub
commit 5642050276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 173 deletions

View File

@ -13,24 +13,11 @@ from bigchaindb.common.exceptions import SchemaValidationError
logger = logging.getLogger(__name__)
def drop_schema_descriptions(node):
""" Drop descriptions from schema, since they clutter log output """
if 'description' in node:
del node['description']
for n in node.get('properties', {}).values():
drop_schema_descriptions(n)
for n in node.get('definitions', {}).values():
drop_schema_descriptions(n)
for n in node.get('anyOf', []):
drop_schema_descriptions(n)
def _load_schema(name):
""" Load a schema from disk """
path = os.path.join(os.path.dirname(__file__), name + '.yaml')
with open(path) as handle:
schema = yaml.safe_load(handle)
drop_schema_descriptions(schema)
fast_schema = rapidjson_schema.loads(rapidjson.dumps(schema))
return path, (schema, fast_schema)

View File

@ -4,8 +4,6 @@ id: "http://www.bigchaindb.com/schema/transaction.json"
type: object
additionalProperties: false
title: Transaction Schema
description: |
A transaction represents the creation or transfer of assets in BigchainDB.
required:
- id
- inputs
@ -17,48 +15,24 @@ required:
properties:
id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
A sha3 digest of the transaction. The ID is calculated by removing all
derived hashes and signatures from the transaction, serializing it to
JSON with keys in sorted order and then hashing the resulting string
with sha3.
operation:
"$ref": "#/definitions/operation"
asset:
"$ref": "#/definitions/asset"
description: |
Description of the asset being transacted.
See: `Asset`_.
inputs:
type: array
title: "Transaction inputs"
description: |
Array of the inputs of a transaction.
See: Input_.
items:
"$ref": "#/definitions/input"
outputs:
type: array
description: |
Array of outputs provided by this transaction.
See: Output_.
items:
"$ref": "#/definitions/output"
metadata:
"$ref": "#/definitions/metadata"
description: |
User provided transaction metadata. This field may be ``null`` or may
contain an id and an object with freeform metadata.
See: `Metadata`_.
version:
type: string
pattern: "^1\\.0$"
description: |
BigchainDB transaction schema version.
definitions:
offset:
type: integer
@ -78,53 +52,25 @@ definitions:
uuid4:
pattern: "[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}"
type: string
description: |
A `UUID <https://tools.ietf.org/html/rfc4122.html>`_
of type 4 (random).
operation:
type: string
description: |
Type of the transaction:
A ``CREATE`` transaction creates an asset in BigchainDB. This
transaction has outputs but no inputs, so a dummy input is created.
A ``TRANSFER`` transaction transfers ownership of an asset, by providing
an input that meets the conditions of an earlier transaction's outputs.
A ``GENESIS`` transaction is a special case transaction used as the
sole member of the first block in a BigchainDB ledger.
enum:
- CREATE
- TRANSFER
- GENESIS
asset:
type: object
description: |
Description of the asset being transacted. In the case of a ``TRANSFER``
transaction, this field contains only the ID of asset. In the case
of a ``CREATE`` transaction, this field contains only the user-defined
payload.
additionalProperties: false
properties:
id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID of the transaction that created the asset.
data:
description: |
User provided metadata associated with the asset. May also be ``null``.
anyOf:
- type: object
additionalProperties: true
- type: 'null'
output:
type: object
description: |
A transaction output. Describes the quantity of an asset and the
requirements that must be met to spend the output.
See also: Input_.
additionalProperties: false
required:
- amount
@ -134,15 +80,7 @@ definitions:
amount:
type: string
pattern: "^[0-9]{1,20}$"
description: |
Integral amount of the asset represented by this output.
In the case of a non divisible asset, this will always be 1.
condition:
description: |
Describes the condition that needs to be met to spend the output. Has the properties:
- **details**: Details of the condition.
- **uri**: Condition encoded as an ASCII string.
type: object
additionalProperties: false
required:
@ -158,13 +96,8 @@ definitions:
subtypes=ed25519-sha-256(&)?){2,3}$"
public_keys:
"$ref": "#/definitions/public_keys"
description: |
List of public keys associated with the conditions on an output.
input:
type: "object"
description:
An input spends a previous output, by providing one or more fulfillments
that fulfill the conditions of the previous output.
additionalProperties: false
required:
- owners_before
@ -172,13 +105,7 @@ definitions:
properties:
owners_before:
"$ref": "#/definitions/public_keys"
description: |
List of public keys of the previous owners of the asset.
fulfillment:
description: |
Fulfillment of an `Output.condition`_, or, put a different way, a payload
that satisfies the condition of a previous output to prove that the
creator(s) of this transaction have control over the listed asset.
anyOf:
- type: string
pattern: "^[a-zA-Z0-9_-]*$"
@ -186,8 +113,6 @@ definitions:
fulfills:
anyOf:
- type: 'object'
description: |
Reference to the output that is being spent.
additionalProperties: false
required:
- output_index
@ -195,26 +120,16 @@ definitions:
properties:
output_index:
"$ref": "#/definitions/offset"
description: |
Index of the output containing the condition being fulfilled
transaction_id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
Transaction ID containing the output to spend
- type: 'null'
metadata:
anyOf:
- type: object
description: |
User provided transaction metadata. This field may be ``null`` or may
contain an non empty object with freeform metadata.
additionalProperties: true
minProperties: 1
- type: 'null'
condition_details:
description: |
Details needed to reconstruct the condition associated with an output.
Currently, BigchainDB only supports ed25519 and threshold condition types.
anyOf:
- type: object
additionalProperties: false

View File

@ -10,8 +10,6 @@ properties:
properties:
id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID of the transaction that created the asset.
required:
- id
inputs:

View File

@ -4,13 +4,6 @@ id: "http://www.bigchaindb.com/schema/vote.json"
type: object
additionalProperties: false
title: Vote Schema
description: |
A Vote is an endorsement of a Block (identified by a hash) by
a node (identified by a public key).
The outer Vote object contains the details of the vote being made
as well as the signature and identifying information of the node
passing the vote.
required:
- node_pubkey
- signature
@ -19,18 +12,12 @@ properties:
node_pubkey:
type: "string"
pattern: "[1-9a-zA-Z^OIl]{43,44}"
description: |
Ed25519 public key identifying the voting node.
signature:
type: "string"
pattern: "[1-9a-zA-Z^OIl]{86,88}"
description:
Ed25519 signature of the `Vote Details`_ object.
vote:
type: "object"
additionalProperties: false
description: |
`Vote Details`_ to be signed.
required:
- invalid_reason
- is_block_valid
@ -40,33 +27,17 @@ properties:
properties:
previous_block:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID (SHA3 hash) of the block that precedes the block being voted on.
The notion of a "previous" block is subject to vote.
voting_for_block:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID (SHA3 hash) of the block being voted on.
is_block_valid:
type: "boolean"
description: |
This field is ``true`` if the block was deemed valid by the node.
invalid_reason:
anyOf:
- type: "string"
description: |
Reason the block is voted invalid, or ``null``.
.. container:: notice
**Note**: The invalid_reason was not being used and may be dropped in a future version of BigchainDB. See Issue `#217 <https://github.com/bigchaindb/bigchaindb/issues/217>`_ on GitHub.
- type: "null"
timestamp:
type: "string"
pattern: "[0-9]{10}"
description: |
Unix timestamp that the vote was created by the node, according
to the system time of the node.
definitions:
sha3_hexdigest:
pattern: "[0-9a-f]{64}"

View File

@ -11,7 +11,7 @@ from pytest import raises
from bigchaindb.common.exceptions import SchemaValidationError
from bigchaindb.common.schema import (
TX_SCHEMA_COMMON, VOTE_SCHEMA, drop_schema_descriptions,
TX_SCHEMA_COMMON, VOTE_SCHEMA,
validate_transaction_schema, validate_vote_schema)
SUPPORTED_CRYPTOCONDITION_TYPES = ('threshold-sha-256', 'ed25519-sha-256')
@ -46,49 +46,6 @@ def test_vote_schema_additionalproperties():
_test_additionalproperties(VOTE_SCHEMA)
def test_drop_descriptions():
node = {
'description': 'abc',
'properties': {
'description': {
'description': ('The property named "description" should stay'
'but description meta field goes'),
},
'properties': {
'description': 'this must go'
},
'any': {
'anyOf': [
{
'description': 'must go'
}
]
}
},
'definitions': {
'wat': {
'description': 'go'
}
}
}
expected = {
'properties': {
'description': {},
'properties': {},
'any': {
'anyOf': [
{}
]
}
},
'definitions': {
'wat': {},
}
}
drop_schema_descriptions(node)
assert node == expected
################################################################################
# Test call transaction schema