mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: test_upsert_validator fails if run with the initial block height == 0
Solution: Added a little helper function to make sure there is at least one block in the chain when the test is executed
This commit is contained in:
parent
32459c6a75
commit
4a4cbc8de0
@ -10,7 +10,7 @@ from bigchaindb.upsert_validator import ValidatorElection, ValidatorElectionVote
|
||||
from bigchaindb.common.exceptions import AmountError
|
||||
from bigchaindb.common.crypto import generate_key_pair
|
||||
from bigchaindb.common.exceptions import ValidationError
|
||||
|
||||
from tests.utils import generate_block
|
||||
|
||||
pytestmark = [pytest.mark.execute]
|
||||
|
||||
@ -219,10 +219,13 @@ def test_valid_election_conclude(b_mock, valid_election, ed25519_node_keys):
|
||||
|
||||
|
||||
@pytest.mark.abci
|
||||
def test_upsert_validator(b, node_key, node_keys, new_validator, ed25519_node_keys):
|
||||
def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys):
|
||||
import time
|
||||
import requests
|
||||
|
||||
if b.get_latest_block()['height'] == 0:
|
||||
generate_block(b)
|
||||
|
||||
(node_pub, _) = list(node_keys.items())[0]
|
||||
|
||||
validators = [{'pub_key': {'type': 'ed25519',
|
||||
|
||||
@ -21,3 +21,19 @@ def flush_localmongo_db(connection, dbname):
|
||||
connection.conn[dbname].metadata.delete_many({})
|
||||
connection.conn[dbname].utxos.delete_many({})
|
||||
connection.conn[dbname].validators.delete_many({})
|
||||
|
||||
|
||||
def generate_block(bigchain):
|
||||
from bigchaindb.common.crypto import generate_key_pair
|
||||
from bigchaindb.models import Transaction
|
||||
import time
|
||||
|
||||
alice = generate_key_pair()
|
||||
tx = Transaction.create([alice.public_key],
|
||||
[([alice.public_key], 1)],
|
||||
asset=None)\
|
||||
.sign([alice.private_key])
|
||||
|
||||
code, message = bigchain.write_transaction(tx, 'broadcast_tx_commit')
|
||||
assert code == 202
|
||||
time.sleep(2)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user