forked from hyperledger/indy-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INDY-1939] Add tests for demotes checking
Signed-off-by: Andrew Nikitin <[email protected]>
- Loading branch information
Andrew Nikitin
committed
Jan 16, 2019
1 parent
8466ed7
commit f0dfe57
Showing
6 changed files
with
204 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="function", params=[False, True]) | ||
def with_verkey(request): | ||
return request.param |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import pytest | ||
from indy import did | ||
|
||
from indy_common.constants import NETWORK_MONITOR | ||
from indy_node.test.validator_info.helper import sdk_get_validator_info | ||
from plenum.common.constants import STEWARD_STRING | ||
from plenum.common.exceptions import RequestRejectedException | ||
from plenum.test.helper import sdk_sign_and_submit_op, sdk_get_and_check_replies | ||
from plenum.test.pool_transactions.helper import sdk_add_new_nym | ||
|
||
|
||
def test_network_monitor_suspension_by_another_steward(looper, | ||
sdk_pool_handle, | ||
sdk_wallet_steward, | ||
sdk_wallet_trustee, | ||
sdk_wallet_handle, | ||
with_verkey): | ||
new_steward_did, new_steward_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_trustee[0], "{}")) | ||
new_network_monitor_did, new_network_monitor_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_steward[0], "{}")) | ||
"""Adding new steward""" | ||
sdk_add_new_nym(looper, sdk_pool_handle, | ||
sdk_wallet_trustee, 'newSteward', STEWARD_STRING, verkey=new_steward_verkey, dest=new_steward_did) | ||
"""Adding NETWORK_MONITOR role by first steward""" | ||
op = {'type': '1', | ||
'dest': new_network_monitor_did, | ||
'role': NETWORK_MONITOR, | ||
'verkey': new_network_monitor_verkey} | ||
req = sdk_sign_and_submit_op(looper, sdk_pool_handle, (sdk_wallet_handle, new_steward_did), op) | ||
sdk_get_and_check_replies(looper, [req]) | ||
"""Check that get_validator_info command works for NETWORK_MONITOR role""" | ||
sdk_get_validator_info(looper, (sdk_wallet_handle, new_network_monitor_did), sdk_pool_handle) | ||
op = {'type': '1', | ||
'dest': new_network_monitor_did, | ||
'role': None} | ||
if with_verkey: | ||
op['verkey'] = new_network_monitor_verkey | ||
"""Blacklisting network_monitor by new steward""" | ||
req = sdk_sign_and_submit_op(looper, sdk_pool_handle, (sdk_wallet_handle, new_steward_did), op) | ||
if with_verkey: | ||
with pytest.raises(RequestRejectedException): | ||
sdk_get_and_check_replies(looper, [req]) | ||
else: | ||
sdk_get_and_check_replies(looper, [req]) | ||
with pytest.raises(RequestRejectedException): | ||
sdk_get_validator_info(looper, (sdk_wallet_handle, new_network_monitor_did), sdk_pool_handle) | ||
|
||
|
||
def test_network_monitor_suspension_by_itself(looper, | ||
sdk_pool_handle, | ||
sdk_wallet_steward, | ||
sdk_wallet_handle, | ||
with_verkey): | ||
new_network_monitor_did, new_network_monitor_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_steward[0], "{}")) | ||
"""Adding NETWORK_MONITOR role by steward""" | ||
op = {'type': '1', | ||
'dest': new_network_monitor_did, | ||
'role': NETWORK_MONITOR, | ||
'verkey': new_network_monitor_verkey} | ||
req = sdk_sign_and_submit_op(looper, sdk_pool_handle, (sdk_wallet_handle, sdk_wallet_steward[1]), op) | ||
sdk_get_and_check_replies(looper, [req]) | ||
op = {'type': '1', | ||
'dest': new_network_monitor_did, | ||
'role': None} | ||
if with_verkey: | ||
op['verkey'] = new_network_monitor_verkey | ||
"""Blacklisting network_monitor by itself""" | ||
req = sdk_sign_and_submit_op(looper, sdk_pool_handle, (sdk_wallet_handle, new_network_monitor_did), op) | ||
with pytest.raises(RequestRejectedException): | ||
sdk_get_and_check_replies(looper, [req]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import pytest | ||
from indy import did | ||
|
||
from indy_common.constants import TRUST_ANCHOR_STRING | ||
from plenum.common.constants import TRUSTEE_STRING, STEWARD_STRING | ||
from plenum.common.exceptions import RequestRejectedException | ||
from plenum.test.helper import sdk_get_and_check_replies, sdk_sign_and_submit_op | ||
from plenum.test.pool_transactions.helper import sdk_add_new_nym | ||
|
||
|
||
def test_steward_suspension_by_another_trustee(looper, | ||
sdk_pool_handle, | ||
sdk_wallet_trustee, | ||
sdk_wallet_handle, | ||
with_verkey): | ||
new_trustee_did, new_trustee_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_trustee[0], "{}")) | ||
new_steward_did, new_steward_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_trustee[0], "{}")) | ||
"""Adding new steward""" | ||
sdk_add_new_nym(looper, sdk_pool_handle, | ||
sdk_wallet_trustee, 'newSteward', STEWARD_STRING, verkey=new_steward_verkey, dest=new_steward_did) | ||
"""Adding new trustee""" | ||
sdk_add_new_nym(looper, sdk_pool_handle, | ||
sdk_wallet_trustee, 'newTrustee', TRUSTEE_STRING, verkey=new_trustee_verkey, dest=new_trustee_did) | ||
op = {'type': '1', | ||
'dest': new_steward_did, | ||
'role': None} | ||
if with_verkey: | ||
op['verkey'] = new_steward_verkey | ||
"""Blacklisting new steward by new trustee""" | ||
req = sdk_sign_and_submit_op(looper, sdk_pool_handle, (sdk_wallet_handle, new_trustee_did), op) | ||
if with_verkey: | ||
with pytest.raises(RequestRejectedException): | ||
sdk_get_and_check_replies(looper, [req]) | ||
else: | ||
sdk_get_and_check_replies(looper, [req]) | ||
|
||
|
||
def test_steward_cannot_work_after_demote(looper, | ||
sdk_pool_handle, | ||
sdk_wallet_trustee, | ||
sdk_wallet_handle): | ||
new_steward_did, new_steward_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_trustee[0], "{}")) | ||
new_ta_did, new_ta_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_trustee[0], "{}")) | ||
new_ta_2_did, new_ta_2_verkey = looper.loop.run_until_complete( | ||
did.create_and_store_my_did(sdk_wallet_trustee[0], "{}")) | ||
"""Adding new steward""" | ||
sdk_add_new_nym(looper, sdk_pool_handle, | ||
sdk_wallet_trustee, | ||
'newSteward', | ||
STEWARD_STRING, | ||
verkey=new_steward_verkey, dest=new_steward_did) | ||
"""Adding new TA""" | ||
sdk_add_new_nym(looper, sdk_pool_handle, | ||
(sdk_wallet_handle, new_steward_did), | ||
'newSteward', | ||
TRUST_ANCHOR_STRING, | ||
verkey=new_ta_verkey, dest=new_ta_did) | ||
"""Demote new steward""" | ||
op = {'type': '1', | ||
'dest': new_steward_did, | ||
'role': None} | ||
"""Blacklisting new steward by trustee""" | ||
req = sdk_sign_and_submit_op(looper, sdk_pool_handle, sdk_wallet_trustee, op) | ||
sdk_get_and_check_replies(looper, [req]) | ||
|
||
"""Try to add new TA by previous demoted steward""" | ||
with pytest.raises(RequestRejectedException): | ||
sdk_add_new_nym(looper, sdk_pool_handle, | ||
(sdk_wallet_handle, new_steward_did), | ||
'newSteward', | ||
TRUST_ANCHOR_STRING, | ||
verkey=new_ta_2_verkey, dest=new_ta_2_did) | ||
|