def test_chain_migration_election_show_shows_concluded(b): validators = generate_validators([1] * 4) b.store_validator_set(1, [v['storage'] for v in validators]) public_key = validators[0]['public_key'] private_key = validators[0]['private_key'] voter_keys = [v['private_key'] for v in validators] election, votes = generate_election(b, ChainMigrationElection, public_key, private_key, {}, voter_keys) assert not run_election_show(Namespace(election_id=election.id), b) b.store_bulk_transactions([election]) Election.process_block(b, 1, [election]) assert run_election_show(Namespace(election_id=election.id), b) == \ 'status=ongoing' b.store_abci_chain(1, 'chain-X') b.store_block( Block(height=1, transactions=[v.id for v in votes], app_hash='last_app_hash')._asdict()) Election.process_block(b, 2, votes) assert run_election_show(Namespace(election_id=election.id), b) == \ f'''status=concluded
def test_chain_migration_election_show_shows_inconclusive(b): validators = generate_validators([1] * 4) b.store_validator_set(1, [v['storage'] for v in validators]) public_key = validators[0]['public_key'] private_key = validators[0]['private_key'] voter_keys = [v['private_key'] for v in validators] election, votes = generate_election(b, ChainMigrationElection, public_key, private_key, {}, voter_keys) assert not run_election_show(Namespace(election_id=election.id), b) Election.process_block(b, 1, [election]) b.store_bulk_transactions([election]) assert run_election_show(Namespace(election_id=election.id), b) == \ 'status=ongoing' b.store_block(Block(height=1, transactions=[], app_hash='')._asdict()) b.store_validator_set(2, [v['storage'] for v in validators]) assert run_election_show(Namespace(election_id=election.id), b) == \ 'status=ongoing' b.store_block(Block(height=2, transactions=[], app_hash='')._asdict()) # TODO insert yet another block here when upgrading to Tendermint 0.22.4. assert run_election_show(Namespace(election_id=election.id), b) == \ 'status=inconclusive'
def test_chain_migration_election_show_shows_concluded(b): validators = generate_validators([1] * 4) b.store_validator_set(1, [v['storage'] for v in validators]) public_key = validators[0]['public_key'] private_key = validators[0]['private_key'] voter_keys = [v['private_key'] for v in validators] election, votes = generate_election(b, ChainMigrationElection, public_key, private_key, {}, voter_keys) assert not run_election_show(Namespace(election_id=election.id), b) b.store_bulk_transactions([election]) Election.process_block(b, 1, [election]) assert run_election_show(Namespace(election_id=election.id), b) == \ 'status=ongoing' b.store_abci_chain(1, 'chain-X') b.store_block(Block(height=1, transactions=[v.id for v in votes], app_hash='last_app_hash')._asdict()) Election.process_block(b, 2, votes) assert run_election_show(Namespace(election_id=election.id), b) == \ f'''status=concluded
def test_upsert_validator_show(caplog, ongoing_validator_election, b): from bigchaindb.commands.bigchaindb import run_election_show election_id = ongoing_validator_election.id public_key = public_key_to_base64( ongoing_validator_election.asset['data']['public_key']['value']) power = ongoing_validator_election.asset['data']['power'] node_id = ongoing_validator_election.asset['data']['node_id'] status = ValidatorElection.ONGOING show_args = Namespace(action='show', election_id=election_id) msg = run_election_show(show_args, b) assert msg == f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}'
def test_upsert_validator_show(caplog, ongoing_election, b): from bigchaindb.commands.bigchaindb import run_election_show election_id = ongoing_election.id public_key = public_key_to_base64(ongoing_election.asset['data']['public_key']['value']) power = ongoing_election.asset['data']['power'] node_id = ongoing_election.asset['data']['node_id'] status = ValidatorElection.ONGOING show_args = Namespace(action='show', election_id=election_id) msg = run_election_show(show_args, b) assert msg == f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}'