mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
schema validates that create txes only have 1 input and that it has no fulfills
This commit is contained in:
parent
5b2d22efd4
commit
dbf24a6065
@ -1,17 +1,28 @@
|
|||||||
---
|
---
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
title: Transaction Schema - CREATE/GENESIS specific properties
|
title: Transaction Schema - CREATE/GENESIS specific constraints
|
||||||
required:
|
required:
|
||||||
- asset
|
- asset
|
||||||
|
- inputs
|
||||||
properties:
|
properties:
|
||||||
asset:
|
asset:
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
data:
|
data:
|
||||||
description: |
|
|
||||||
User provided metadata associated with the asset. May also be ``null``.
|
|
||||||
anyOf:
|
anyOf:
|
||||||
- type: object
|
- type: object
|
||||||
additionalProperties: true
|
additionalProperties: true
|
||||||
- type: 'null'
|
- type: 'null'
|
||||||
|
inputs:
|
||||||
|
type: array
|
||||||
|
title: "Transaction inputs"
|
||||||
|
maxItems: 1
|
||||||
|
minItems: 1
|
||||||
|
items:
|
||||||
|
type: "object"
|
||||||
|
required:
|
||||||
|
- fulfills
|
||||||
|
properties:
|
||||||
|
fulfills:
|
||||||
|
type: "null"
|
||||||
|
@ -32,8 +32,6 @@ def test_validate_fails_metadata_empty_dict(create_tx):
|
|||||||
|
|
||||||
|
|
||||||
def test_transfer_asset_schema(signed_transfer_tx):
|
def test_transfer_asset_schema(signed_transfer_tx):
|
||||||
from bigchaindb.common.schema import (SchemaValidationError,
|
|
||||||
validate_transaction_schema)
|
|
||||||
tx = signed_transfer_tx.to_dict()
|
tx = signed_transfer_tx.to_dict()
|
||||||
validate_transaction_schema(tx)
|
validate_transaction_schema(tx)
|
||||||
tx['asset']['data'] = {}
|
tx['asset']['data'] = {}
|
||||||
@ -43,3 +41,20 @@ def test_transfer_asset_schema(signed_transfer_tx):
|
|||||||
tx['asset']['id'] = 'b' * 63
|
tx['asset']['id'] = 'b' * 63
|
||||||
with raises(SchemaValidationError):
|
with raises(SchemaValidationError):
|
||||||
validate_transaction_schema(tx)
|
validate_transaction_schema(tx)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_single_input(create_tx):
|
||||||
|
tx = create_tx.to_dict()
|
||||||
|
tx['inputs'] += tx['inputs']
|
||||||
|
with raises(SchemaValidationError):
|
||||||
|
validate_transaction_schema(tx)
|
||||||
|
tx['inputs'] = []
|
||||||
|
with raises(SchemaValidationError):
|
||||||
|
validate_transaction_schema(tx)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_tx_no_fulfills(create_tx):
|
||||||
|
tx = create_tx.to_dict()
|
||||||
|
tx['inputs'][0]['fulfills'] = {'tx': 'a' * 64, 'output': 0}
|
||||||
|
with raises(SchemaValidationError):
|
||||||
|
validate_transaction_schema(tx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user