tx version break step with server version (#1574)

* tx version break step with server version
* fix regular expression for tx version
* restore docstring for Transaction version parameter
* add test for correct transaction version
This commit is contained in:
libscott
2017-06-22 07:50:42 -07:00
committed by GitHub
parent 9ceea89537
commit 074e783088
3 changed files with 8 additions and 14 deletions

View File

@@ -56,7 +56,7 @@ properties:
See: `Metadata`_.
version:
type: string
pattern: "^0\\."
pattern: "^1\\.0$"
description: |
BigchainDB transaction schema version.
definitions:

View File

@@ -11,7 +11,6 @@ from bigchaindb.common.exceptions import (KeypairMismatchException,
InvalidHash, InvalidSignature,
AmountError, AssetIdMismatch)
from bigchaindb.common.utils import serialize
import bigchaindb.version
class Input(object):
@@ -421,13 +420,13 @@ class Transaction(object):
``id`` property.
metadata (dict):
Metadata to be stored along with the Transaction.
version (int): Defines the version number of a Transaction.
version (string): Defines the version number of a Transaction.
"""
CREATE = 'CREATE'
TRANSFER = 'TRANSFER'
GENESIS = 'GENESIS'
ALLOWED_OPERATIONS = (CREATE, TRANSFER, GENESIS)
VERSION = '.'.join(bigchaindb.version.__short_version__.split('.')[:2])
VERSION = '1.0'
def __init__(self, operation, asset, inputs=None, outputs=None,
metadata=None, version=None):
@@ -447,7 +446,7 @@ class Transaction(object):
lock.
metadata (dict): Metadata to be stored along with the
Transaction.
version (int): Defines the version number of a Transaction.
version (string): Defines the version number of a Transaction.
"""
if operation not in Transaction.ALLOWED_OPERATIONS:
allowed_ops = ', '.join(self.__class__.ALLOWED_OPERATIONS)

View File

@@ -165,14 +165,9 @@ def test_high_amounts(create_tx):
# Version
def test_validate_version(create_tx):
import re
import bigchaindb.version
short_ver = bigchaindb.version.__short_version__
assert create_tx.version == re.match(r'^(.*\d)', short_ver).group(1)
create_tx.version = '1.0'
validate(create_tx)
# At version 1, transaction version will break step with server version.
create_tx.version = '1.0.0'
create_tx.version = '0.10'
validate_raises(create_tx)
create_tx.version = '110'
validate_raises(create_tx)