From 0803b9e46d9d81dc33dc62aade9eb1bda45bab7d Mon Sep 17 00:00:00 2001 From: Vanshdeep Singh Date: Mon, 27 Aug 2018 13:07:35 +0200 Subject: [PATCH] Problem: Not test for invalid execution of upsert-validator 'new' Solution: Write tests to when invalid power or private key path has been supplied --- tests/commands/test_commands.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 049d3069..5b866a7d 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -405,6 +405,29 @@ def test_upsert_validator_new_without_tendermint(b, priv_validator_path, user_sk assert b.get_transaction(resp) +@pytest.mark.tendermint +@pytest.mark.bdb +def test_upsert_validator_new_invalid_election(b, priv_validator_path, user_sk): + from bigchaindb.commands.bigchaindb import run_upsert_validator_new + + b.get_validators = mock_get + args = Namespace(action='new', + public_key='CJxdItf4lz2PwEf4SmYNAu/c/VpmX39JEgC5YpH7fxg=', + power=10, + node_id='fb7140f03a4ffad899fabbbf655b97e0321add66', + sk=priv_validator_path, + config={}) + assert not run_upsert_validator_new(args, b) + + args = Namespace(action='new', + public_key='CJxdItf4lz2PwEf4SmYNAu/c/VpmX39JEgC5YpH7fxg=', + power=10, + node_id='fb7140f03a4ffad899fabbbf655b97e0321add66', + sk='/tmp/invalid/path/key.json', + config={}) + assert not run_upsert_validator_new(args, b) + + @pytest.mark.abci def test_upsert_validator_approve_with_tendermint(b, priv_validator_path, user_sk, validators): from bigchaindb.commands.bigchaindb import run_upsert_validator_new, \