mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
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:
@@ -56,7 +56,7 @@ properties:
|
||||
See: `Metadata`_.
|
||||
version:
|
||||
type: string
|
||||
pattern: "^0\\."
|
||||
pattern: "^1\\.0$"
|
||||
description: |
|
||||
BigchainDB transaction schema version.
|
||||
definitions:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user