コード例 #1
0
def test_generate_aggregate_pubkeys(genesis_validators,
                                    sample_slashable_vote_data_params, data):
    max_value_for_list = len(genesis_validators) - 1
    (indices, some_index) = _list_and_index(data,
                                            elements=st.integers(
                                                min_value=0,
                                                max_value=max_value_for_list,
                                            ))
    proof_of_custody_0_indices = indices[:some_index]
    proof_of_custody_1_indices = indices[some_index:]

    key = "aggregate_signature_poc_0_indices"
    sample_slashable_vote_data_params[key] = proof_of_custody_0_indices
    key = "aggregate_signature_poc_1_indices"
    sample_slashable_vote_data_params[key] = proof_of_custody_1_indices

    votes = SlashableVoteData(**sample_slashable_vote_data_params)

    keys = generate_aggregate_pubkeys(genesis_validators, votes)
    assert len(keys) == 2

    (poc_0_key, poc_1_key) = keys

    poc_0_keys = get_pubkey_for_indices(genesis_validators,
                                        proof_of_custody_0_indices)
    poc_1_keys = get_pubkey_for_indices(genesis_validators,
                                        proof_of_custody_1_indices)

    assert bls.aggregate_pubkeys(poc_0_keys) == poc_0_key
    assert bls.aggregate_pubkeys(poc_1_keys) == poc_1_key
コード例 #2
0
def test_get_pubkey_for_indices(genesis_validators, data):
    max_value_for_list = len(genesis_validators) - 1
    indices = _generate_some_indices(data, max_value_for_list)
    pubkeys = get_pubkey_for_indices(genesis_validators, indices)

    assert len(indices) == len(pubkeys)

    for index, pubkey in enumerate(pubkeys):
        validator_index = indices[index]
        assert genesis_validators[validator_index].pubkey == pubkey