From 331b52cc4c7c0c4cafd0614f0fb618e08ddaa64d Mon Sep 17 00:00:00 2001 From: z-bowen Date: Wed, 5 Sep 2018 10:36:44 +0200 Subject: [PATCH] Problem: Schema still refers to `ValidatorElectionVote` instead of `Vote` Solution: Renamed `TX_SCHEMA_VALIDATOR_ELECTION_VOTE` as `TX_SCHEMA_VOTE` --- bigchaindb/common/election.py | 2 +- bigchaindb/common/schema/__init__.py | 3 +-- ...r_election_vote_v2.0.yaml => transaction_vote_v2.0.yaml} | 2 +- bigchaindb/common/vote.py | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) rename bigchaindb/common/schema/{transaction_validator_election_vote_v2.0.yaml => transaction_vote_v2.0.yaml} (97%) diff --git a/bigchaindb/common/election.py b/bigchaindb/common/election.py index ed7bfa92..f43b743f 100644 --- a/bigchaindb/common/election.py +++ b/bigchaindb/common/election.py @@ -162,7 +162,7 @@ class Election(Transaction): def count_votes(cls, election_pk, transactions, getter=getattr): votes = 0 for txn in transactions: - if getter(txn, 'operation') == cls.VOTE_TYPE: + if getter(txn, 'operation') == cls.VOTE_TYPE.VOTE: for output in getter(txn, 'outputs'): # NOTE: We enforce that a valid vote to election id will have only # election_pk in the output public keys, including any other public key diff --git a/bigchaindb/common/schema/__init__.py b/bigchaindb/common/schema/__init__.py index 914e5196..25943675 100644 --- a/bigchaindb/common/schema/__init__.py +++ b/bigchaindb/common/schema/__init__.py @@ -37,8 +37,7 @@ _, TX_SCHEMA_TRANSFER = _load_schema('transaction_transfer_' + _, TX_SCHEMA_VALIDATOR_ELECTION = _load_schema('transaction_validator_election_' + TX_SCHEMA_VERSION) -_, TX_SCHEMA_VALIDATOR_ELECTION_VOTE = _load_schema('transaction_validator_election_vote_' + - TX_SCHEMA_VERSION) +_, TX_SCHEMA_VOTE = _load_schema('transaction_vote_' + TX_SCHEMA_VERSION) def _validate_schema(schema, body): diff --git a/bigchaindb/common/schema/transaction_validator_election_vote_v2.0.yaml b/bigchaindb/common/schema/transaction_vote_v2.0.yaml similarity index 97% rename from bigchaindb/common/schema/transaction_validator_election_vote_v2.0.yaml rename to bigchaindb/common/schema/transaction_vote_v2.0.yaml index 5e7c4763..b2cf8d81 100644 --- a/bigchaindb/common/schema/transaction_validator_election_vote_v2.0.yaml +++ b/bigchaindb/common/schema/transaction_vote_v2.0.yaml @@ -12,7 +12,7 @@ required: properties: operation: type: string - value: "VOTE" + value: "OPERATION" outputs: type: array items: diff --git a/bigchaindb/common/vote.py b/bigchaindb/common/vote.py index 7b6230ba..67ed3444 100644 --- a/bigchaindb/common/vote.py +++ b/bigchaindb/common/vote.py @@ -6,7 +6,7 @@ from bigchaindb.common.transaction import Transaction from bigchaindb.common.schema import (_validate_schema, TX_SCHEMA_COMMON, TX_SCHEMA_TRANSFER, - TX_SCHEMA_VALIDATOR_ELECTION_VOTE) + TX_SCHEMA_VOTE) class Vote(Transaction): @@ -45,14 +45,14 @@ class Vote(Transaction): @classmethod def validate_schema(cls, tx, skip_id=False): - """Validate the validator election vote transaction. Since `VALIDATOR_ELECTION_VOTE` extends `TRANFER` + """Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER` transaction, all the validations for `CREATE` transaction should be inherited """ if not skip_id: cls.validate_id(tx) _validate_schema(TX_SCHEMA_COMMON, tx) _validate_schema(TX_SCHEMA_TRANSFER, tx) - _validate_schema(TX_SCHEMA_VALIDATOR_ELECTION_VOTE, tx) + _validate_schema(TX_SCHEMA_VOTE, tx) @classmethod def create(cls, tx_signers, recipients, metadata=None, asset=None):