Exemplo n.º 1
0
def test_lst_sertificate_return_max_3PC_key_of_quorumed_prepare(replica):
    """

    Prepare with key (0, 2) does not have quorum of prepare.
    Therefore, expected Max3PC key must be (0, 1), because of previous prepare has enough quorum
    """
    replica.isMaster = True
    replica.prepares.clear()
    prepare1 = create_prepare(
        req_key=(0, 1),
        state_root='8J7o1k3mDX2jtBvgVfFbijdy6NKbfeJ7SfY3K1nHLzQB')
    prepare1.voters = ('Alpha:0', 'Beta:0', 'Gamma:0', 'Delta:0')
    replica.prepares[(0, 1)] = prepare1
    prepare2 = create_prepare(
        req_key=(0, 1),
        state_root='EuDgqga9DNr4bjH57Rdq6BRtvCN1PV9UX5Mpnm9gbMAZ')
    prepare2.voters = ('Delta:0', )
    replica.prepares[(0, 2)] = prepare2
    assert replica.last_prepared_certificate_in_view() == (0, 1)
Exemplo n.º 2
0
def test_last_prepared_sertificate_return_max_3PC_key(replica):
    """

    All the prepares has enough quorum. Expected result is that last_prepared_sertificate
    must be Max3PCKey(all of prepare's keys) == (0, 2)
    """
    replica.isMaster = True
    replica.prepares.clear()
    prepare1 = create_prepare(
        req_key=(0, 1),
        state_root='8J7o1k3mDX2jtBvgVfFbijdy6NKbfeJ7SfY3K1nHLzQB')
    prepare1.voters = ('Alpha:0', 'Beta:0', 'Gamma:0', 'Delta:0')
    replica.prepares[(0, 1)] = prepare1
    prepare2 = create_prepare(
        req_key=(0, 1),
        state_root='EuDgqga9DNr4bjH57Rdq6BRtvCN1PV9UX5Mpnm9gbMAZ')
    prepare2.voters = ('Alpha:0', 'Beta:0', 'Gamma:0', 'Delta:0')
    replica.prepares[(0, 2)] = prepare2
    assert replica.last_prepared_certificate_in_view() == (0, 2)
Exemplo n.º 3
0
def test_process_prepare(bls_bft_replicas, state_root):
    for sender_bls_bft in bls_bft_replicas:
        prepare = create_prepare((0, 0), state_root)
        for verifier_bls_bft in bls_bft_replicas:
            verifier_bls_bft.process_prepare(prepare, sender_bls_bft.node_id)
Exemplo n.º 4
0
def test_validate_prepare(bls_bft_replicas, state_root):
    prepare = create_prepare((0, 0), state_root)
    for sender_bls_bft in bls_bft_replicas:
        for verifier_bls_bft in bls_bft_replicas:
            assert not verifier_bls_bft.validate_prepare(
                prepare, sender_bls_bft.node_id)
def test_process_prepare(bls_bft_replicas, state_root):
    for sender_bls_bft in bls_bft_replicas:
        prepare = create_prepare((0, 0), state_root)
        for verifier_bls_bft in bls_bft_replicas:
            verifier_bls_bft.process_prepare(prepare, sender_bls_bft.node_id)
def test_validate_prepare(bls_bft_replicas, state_root):
    prepare = create_prepare((0, 0), state_root)
    for sender_bls_bft in bls_bft_replicas:
        for verifier_bls_bft in bls_bft_replicas:
            assert not verifier_bls_bft.validate_prepare(prepare, sender_bls_bft.node_id)