mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00

* Problem: We need a way to synchronize a halt to block production to allow for upgrades across breaking changes. * Solution: Created `MigrationElection`. * Problem: Need documentation for `migration` elections. * Solution: Updated the docs. * Problem: `MigrationElection` needs 'new' CLI method. * Solution: Updated the definition of `election` to include the new `migration` type. * Problem: The way `end_block` checks for concluded elections assumes there is only one type of election (so we can't conclude an `upsert-validator` and a `chain-migration` at the same height). * Solution: Re-engineered the code in `Elections` to conclude multiple elections in the same block. If more than one election change the validator set, only one of them is applied. * Problem: Tendermint change to store validator changes at height h+2 will break `Election.get_status`. * Solution: Reworked `get_validator_change` to look at only the latest block height or less.
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
# Copyright BigchainDB GmbH and BigchainDB contributors
|
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from bigchaindb.backend.localmongodb import query
|
|
from bigchaindb.upsert_validator import ValidatorElection
|
|
|
|
|
|
@pytest.fixture
|
|
def valid_upsert_validator_election_b(b, node_key, new_validator):
|
|
voters = ValidatorElection.recipients(b)
|
|
return ValidatorElection.generate([node_key.public_key],
|
|
voters,
|
|
new_validator, None).sign([node_key.private_key])
|
|
|
|
|
|
@pytest.fixture
|
|
@patch('bigchaindb.elections.election.uuid4', lambda: 'mock_uuid4')
|
|
def fixed_seed_election(b_mock, node_key, new_validator):
|
|
voters = ValidatorElection.recipients(b_mock)
|
|
return ValidatorElection.generate([node_key.public_key],
|
|
voters,
|
|
new_validator, None).sign([node_key.private_key])
|
|
|
|
|
|
@pytest.fixture
|
|
def concluded_election(b, ongoing_validator_election, ed25519_node_keys):
|
|
election_result = {'height': 2,
|
|
'election_id': ongoing_validator_election.id}
|
|
|
|
query.store_election_results(b.connection, election_result)
|
|
return ongoing_validator_election
|
|
|
|
|
|
@pytest.fixture
|
|
def inconclusive_election(b, ongoing_validator_election, new_validator):
|
|
validators = b.get_validators(height=1)
|
|
validators[0]['voting_power'] = 15
|
|
validator_update = {'validators': validators,
|
|
'height': 2,
|
|
'election_id': 'some_other_election'}
|
|
|
|
query.store_validator_set(b.connection, validator_update)
|
|
return ongoing_validator_election
|