예제 #1
0
def test_tables_of_different_len(
    invalid_opened_data_one_table_longer: AuditTables,
    invalid_commitment_data_one_table_longer: TallyTables,
):
    assert (audit_tables(
        invalid_opened_data_one_table_longer,
        invalid_commitment_data_one_table_longer,
    ) is False)
예제 #2
0
def audit_elections(
    data_opened: str,
    data_pre_election: str,
    data_tally: str,
    bb: str,
    tally_all: str,
    group_id: Optional[str] = typer.Argument(None),
):
    data_pre_election = _load_pre_election(data_pre_election)
    data_tally = _load_tally_data(data_tally)

    print("Auditing pre_election - data_tally...")
    with click_spinner.spinner():
        valid = audit_pre_election_tables(data_pre_election, data_tally)
    print("valid" if valid else "not valid!")

    del data_pre_election
    data_opened = _load_opened_data(data_opened)

    print("Auditing data_tally - data_opened...")
    with click_spinner.spinner():
        valid = audit_tables(data_opened, data_tally)

    print("valid" if valid else "not valid")

    del data_tally

    bb = _load_bb(bb)
    if group_id is not None:
        print(
            f"Filtering bulletin board is enabled, only votes for group {group_id} will be taken into account"
        )
        bb_filtered = {}
        for vote_id, bb_entry in bb.items():
            if bb_entry.group_id == group_id:
                bb_filtered[vote_id] = bb_entry

        bb = bb_filtered

    print("Auditing data_opened - bb...")
    with click_spinner.spinner():
        valid = audit_bb(bb, data_opened)
    print("valid" if valid else "not valid")

    del bb

    tally_all = _load_tally(tally_all)

    print("Auditing data_opened - tally with all votes...")
    with click_spinner.spinner():
        valid = audit_tables_tally(tally_all, data_opened)
    print("valid" if valid else "not valid")
예제 #3
0
def test_successful_audit(opened_data: AuditTables,
                          commitment_data: TallyTables):
    assert audit_tables(opened_data, commitment_data) is True
예제 #4
0
def test_empty_data():
    assert audit_tables(dict(), dict()) is False
예제 #5
0
def test_invalid_commitment_audit(opened_data: AuditTables,
                                  invalid_commitment_data: TallyTables):
    assert audit_tables(opened_data, invalid_commitment_data) is False