<commit_before><commit_msg>[INDY-1385] test for last_prepared_sertificate<commit_after>import pytest

from plenum.test.delayers import pDelay, ppDelay
from plenum.test.helper import sdk_send_random_and_check


@pytest.fixture(scope="module")
def tconf(tconf):
    old_m = tconf.Max3PCBatchSize
    tconf.Max3PCBatchSize = 1
    yield tconf
    tconf.Max3PCBatchSize = old_m


def test_empty_lst_before_vc_if_no_prepare(looper,
                                           txnPoolNodeSet,
                                           sdk_pool_handle,
                                           sdk_wallet_steward):
    A, B, C, D = txnPoolNodeSet
    for n in [A, B, C]:
        D.nodeIbStasher.delay(pDelay(1000, 0, sender_filter=n.name))
        D.nodeIbStasher.delay(ppDelay(1000, 0, sender_filter=n.name))
    sdk_send_random_and_check(looper,
                              txnPoolNodeSet,
                              sdk_pool_handle,
                              sdk_wallet_steward,
                              5)
    assert len(D.master_replica.prepares) == 0

    assert D.master_replica.last_prepared_certificate_in_view() is None


def test_empty_lst_before_vc_if_no_qourum_of_prepare(looper,
                                                     txnPoolNodeSet,
                                                     sdk_pool_handle,
                                                     sdk_wallet_steward):
    A, B, C, D = txnPoolNodeSet
    for n in [A, B, C]:
        D.nodeIbStasher.delay(pDelay(1000, 0, sender_filter=n.name))
    sdk_send_random_and_check(looper,
                              txnPoolNodeSet,
                              sdk_pool_handle,
                              sdk_wallet_steward,
                              5)
    assert D.master_replica.prepares
    assert D.master_replica.last_prepared_certificate_in_view() is None
{'fraction_non_alphanumeric': 0.06337271750805586, 'fraction_numerical': 0.013963480128893663, 'mean_word_length': 1.5278154681139755, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4643352', 'n_tokens_mistral': 572, 'n_tokens_neox': 554, 'n_words': 89}