def test_multi_sig_saved_locally_for_ordered(bls_bft_replicas, pre_prepare_no_bls,
                                             state_root, quorums):
    key = (0, 0)
    process_commits_for_key(key, pre_prepare_no_bls, bls_bft_replicas)
    process_ordered(key, bls_bft_replicas, pre_prepare_no_bls, quorums)
    for bls_bft_replica in bls_bft_replicas:
        assert bls_bft_replica._bls_bft.bls_store.get(state_root)
Beispiel #2
0
def test_multi_sig_saved_locally_for_ordered(bls_bft_replicas,
                                             pre_prepare_no_bls, state_root,
                                             quorums):
    key = (0, 0)
    process_commits_for_key(key, pre_prepare_no_bls, bls_bft_replicas)
    process_ordered(key, bls_bft_replicas, pre_prepare_no_bls, quorums)
    for bls_bft_replica in bls_bft_replicas:
        assert bls_bft_replica._bls_bft.bls_store.get(state_root)
def test_update_pre_prepare_after_ordered(bls_bft_replicas, state_root, quorums):
    key = (0, 0)
    process_commits_for_key(key, state_root, bls_bft_replicas)
    process_ordered(key, bls_bft_replicas, state_root, quorums)
    params = create_pre_prepare_params(state_root)
    params_initial = copy(params)
    for bls_bft_replica in bls_bft_replicas:
        params = bls_bft_replica.update_pre_prepare(params, DOMAIN_LEDGER_ID)
        assert params != params_initial
Beispiel #4
0
def test_preprepare_multisig_replaces_saved(bls_bft_replicas, quorums,
                                            pre_prepare_no_bls,
                                            pre_prepare_with_bls):
    # have locally calculated multi-sigs
    key = (0, 0)
    state_root = pre_prepare_no_bls.stateRootHash
    for sender_bls_bft_replica in bls_bft_replicas:
        commit = create_commit_bls_sig(sender_bls_bft_replica, key,
                                       pre_prepare_no_bls)
        for verifier_bls_bft_replica in bls_bft_replicas:
            # use 3 of 4 commits only
            if verifier_bls_bft_replica != sender_bls_bft_replica:
                verifier_bls_bft_replica.process_commit(
                    commit, sender_bls_bft_replica.node_id)
    process_ordered(key, bls_bft_replicas, pre_prepare_no_bls, quorums)

    # get locally calculated multi-sigs
    local_multi_sigs = {}
    for bls_bft_replica in bls_bft_replicas:
        local_multi_sigs[
            bls_bft_replica.node_id] = bls_bft_replica._bls_bft.bls_store.get(
                state_root)

    # have multi-sig for PrePrepare (make it different from the local one by using al 4 nodes)
    # get multi-sigs get with PrePrepare and make sure they differ from local ones
    # the local ones must be overridden
    multi_sigs = []
    for bls_bft_replica in bls_bft_replicas:
        bls_bft_replica.process_pre_prepare(pre_prepare_with_bls,
                                            bls_bft_replicas[0].node_id)
        multi_sig = bls_bft_replica._bls_bft.bls_store.get(state_root)
        local_multi_sig = local_multi_sigs[bls_bft_replica.node_id]
        assert multi_sig
        assert local_multi_sig
        assert multi_sig != local_multi_sig
        multi_sigs.append(multi_sig)

    # all saved multi-sigs are equal
    assert all(x == multi_sigs[0] for x in multi_sigs)
def test_preprepare_multisig_replaces_saved(bls_bft_replicas, quorums,
                                            pre_prepare_no_bls, pre_prepare_with_bls):
    # have locally calculated multi-sigs
    key = (0, 0)
    state_root = pre_prepare_no_bls.stateRootHash
    for sender_bls_bft_replica in bls_bft_replicas:
        commit = create_commit_bls_sig(
            sender_bls_bft_replica,
            key,
            pre_prepare_no_bls)
        for verifier_bls_bft_replica in bls_bft_replicas:
            # use 3 of 4 commits only
            if verifier_bls_bft_replica != sender_bls_bft_replica:
                verifier_bls_bft_replica.process_commit(commit,
                                                        sender_bls_bft_replica.node_id)
    process_ordered(key, bls_bft_replicas, pre_prepare_no_bls, quorums)

    # get locally calculated multi-sigs
    local_multi_sigs = {}
    for bls_bft_replica in bls_bft_replicas:
        local_multi_sigs[bls_bft_replica.node_id] = bls_bft_replica._bls_bft.bls_store.get(state_root)

    # have multi-sig for PrePrepare (make it different from the local one by using al 4 nodes)
    # get multi-sigs get with PrePrepare and make sure they differ from local ones
    # the local ones must be overridden
    multi_sigs = []
    for bls_bft_replica in bls_bft_replicas:
        bls_bft_replica.process_pre_prepare(pre_prepare_with_bls, bls_bft_replicas[0].node_id)
        multi_sig = bls_bft_replica._bls_bft.bls_store.get(state_root)
        local_multi_sig = local_multi_sigs[bls_bft_replica.node_id]
        assert multi_sig
        assert local_multi_sig
        assert multi_sig != local_multi_sig
        multi_sigs.append(multi_sig)

    # all saved multi-sigs are equal
    assert all(x == multi_sigs[0] for x in multi_sigs)