<commit_before>import json

from indy_client.test.cli.helper import createHalfKeyIdentifierAndAbbrevVerkey
from indy.ledger import sign_request, submit_request, build_nym_request
from indy.error import IndyError, ErrorCode
from plenum.common.constants import REPLY, REJECT


def test_nym_send_twice(looper, sdk_pool_handle, sdk_wallet_steward):
    idr, verkey = createHalfKeyIdentifierAndAbbrevVerkey()

    wallet_handle, identifier = sdk_wallet_steward

    for i in range(2):
        request = looper.loop.run_until_complete(build_nym_request(identifier, idr, verkey, None, None))
        req_signed = looper.loop.run_until_complete(sign_request(wallet_handle, identifier, request))

        if i == 0:
            result = json.loads(looper.loop.run_until_complete(submit_request(sdk_pool_handle, req_signed)))
            assert result['op'] == REPLY
        else:
            result = json.loads(looper.loop.run_until_complete(submit_request(sdk_pool_handle, req_signed)))
            assert result['op'] == REJECT


def test_nym_resend(looper, sdk_pool_handle, sdk_wallet_steward):
    idr, verkey = createHalfKeyIdentifierAndAbbrevVerkey()

    wallet_handle, identifier = sdk_wallet_steward

    request = looper.loop.run_until_complete(build_nym_request(identifier, idr, verkey, None, None))<commit_msg>Plenum version update. Test fix. (#594)<commit_after>import json

from indy_client.test.cli.helper import createHalfKeyIdentifierAndAbbrevVerkey
from indy.ledger import sign_request, submit_request, build_nym_request
from indy.error import IndyError, ErrorCode
from plenum.common.constants import REPLY, REJECT


def test_nym_send_twice(looper, sdk_pool_handle, sdk_wallet_steward):
    idr, verkey = createHalfKeyIdentifierAndAbbrevVerkey()

    wallet_handle, identifier = sdk_wallet_steward

    for i in range(2):
        request = looper.loop.run_until_complete(build_nym_request(identifier, idr, verkey, None, None))
        req_signed = looper.loop.run_until_complete(sign_request(wallet_handle, identifier, request))
        result = json.loads(looper.loop.run_until_complete(submit_request(sdk_pool_handle, req_signed)))

        if i == 0:
            assert result['op'] == REPLY
        else:
            assert result['op'] == REJECT


def test_nym_resend(looper, sdk_pool_handle, sdk_wallet_steward):
    idr, verkey = createHalfKeyIdentifierAndAbbrevVerkey()

    wallet_handle, identifier = sdk_wallet_steward

    request = looper.loop.run_until_complete(build_nym_request(identifier, idr, verkey, None, None))
{'fraction_non_alphanumeric': 0.08264462809917356, 'fraction_numerical': 0.0027548209366391185, 'mean_word_length': 4.925407925407925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '661127', 'n_tokens_mistral': 822, 'n_tokens_neox': 827, 'n_words': 157}