From 9f97b8267d78704c17e3e018146241b953fca679 Mon Sep 17 00:00:00 2001 From: michelleblom Date: Sun, 23 Jun 2024 17:11:03 +1000 Subject: [PATCH 1/3] Fixed issues identified in review. Abstracted some common code in NEN/NEB Assertion Tests. --- .../corla/model/IRVComparisonAudit.java | 4 +- .../corla/model/assertion/AssertionTests.java | 24 ++ .../model/assertion/NEBAssertionTests.java | 239 +++-------------- .../model/assertion/NENAssertionTests.java | 242 +++--------------- 4 files changed, 110 insertions(+), 399 deletions(-) diff --git a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java index 9bcfd089..b996d523 100644 --- a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java +++ b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java @@ -185,7 +185,7 @@ prefix, contestName, auditStatus(), auditReason(), diluted_margin, assertions.si @Override protected void recalculateSamplesToAudit() { if(assertions == null){ - // We have not associated assertions with this audit yet. When an IRVComparisonAudit + // We have not associated assertions with this audit yet. When an IRVComparisonAudit is // constructed, we call the base class constructor first. The ComparisonAudit constructor // calls sample size computation methods. So, this method may end up being called before // the IRVComparisonAudit constructor has completed its setup (retrieving assertions from @@ -530,7 +530,7 @@ public void recordDiscrepancy(final CVRAuditInfo theRecord, final int theType) { // and the flag for indicating that a sample size recalculation is needed, *if* we did // record a discrepancy against at least one of this audit's assertions. if(recorded) { - super.removeDiscrepancy(theRecord, theType); + super.recordDiscrepancy(theRecord, theType); } LOGGER.debug(String.format("%s total number of overstatements (%f), optimistic sample " + "recalculate needed (%s), estimated sample recalculate needed (%s),", prefix, diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java index e9ea6c00..b72c8b8c 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java @@ -483,4 +483,28 @@ public static void checkComputeDiscrepancy(CastVoteRecord cvr, CastVoteRecord au assertEquals(cvrDiscrepancies, a.cvrDiscrepancy); } } + + + /** + * Checks that the discrepancy counts in the given assertion 'a' are equal to the given + * parameters. + * @param a Assertion to check. + * @param oneOver Expected number of one vote overstatements. + * @param oneUnder Expected number of one vote understatements. + * @param twoOver Expected number of two vote overstatements. + * @param twoUnder Expected number of two vote understatements. + * @param other Expected number of other discrepancies. + * @param cvrDiscrepancy Expected internal map of CVR ID to discrepancy type. + */ + public static void checkCountsDiscrepancyMap(final Assertion a, int oneOver, int oneUnder, + int twoOver, int twoUnder, int other, final Map cvrDiscrepancy){ + + assertEquals(a.oneVoteOverCount.intValue(), oneOver); + assertEquals(a.oneVoteUnderCount.intValue(), oneUnder); + assertEquals(a.twoVoteOverCount.intValue(), twoOver); + assertEquals(a.twoVoteUnderCount.intValue(), twoUnder); + assertEquals(a.otherCount.intValue(), other); + + assertEquals(a.cvrDiscrepancy, cvrDiscrepancy); + } } diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java index 602b4b4c..bd3010cd 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java @@ -23,6 +23,7 @@ import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.TC; import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.checkComputeDiscrepancy; +import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.checkCountsDiscrepancyMap; import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.countsEqual; import static au.org.democracydevelopers.corla.util.testUtils.log; import static org.mockito.Mockito.when; @@ -229,14 +230,7 @@ public void testNEBRecordNoMatch1(){ 8, Map.of(), 0, 0, 0, 0, 0); assertFalse(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of()); } /** @@ -255,14 +249,8 @@ public void testNEBRecordNoMatch2(){ 0, 0, 0); assertFalse(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(2L, -1, 3L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 0, 0, + Map.of(2L, -1, 3L, 1)); } /** @@ -279,14 +267,7 @@ public void testNEBRecordOneVoteOverstatement1(){ 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 0, 0, Map.of(1L, 1)); } /** @@ -303,14 +284,7 @@ public void testNEBRecordOneVoteUnderstatement1(){ 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 1, 0, 0, 0, Map.of(1L, -1)); } /** @@ -327,14 +301,7 @@ public void testNEBRecordTwoVoteOverstatement1(){ 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(1, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 1, 0, 0, Map.of(1L, 2)); } /** @@ -351,14 +318,7 @@ public void testNEBRecordTwoVoteUnderstatement1(){ 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 1, 0, Map.of(1L, -2)); } /** @@ -375,14 +335,7 @@ public void testNEBRecordOther1(){ 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 1, Map.of(1L, 0)); } /** @@ -400,14 +353,8 @@ public void testNEBRecordOneVoteOverstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(2, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 2, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1)); } /** @@ -425,14 +372,8 @@ public void testNEBRecordOneVoteUnderstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -1)); } /** @@ -450,14 +391,8 @@ public void testNEBRecordTwoVoteOverstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(1, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 1, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 2)); } /** @@ -475,14 +410,8 @@ public void testNEBRecordTwoVoteUnderstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(2, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 2, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2)); } /** @@ -500,14 +429,8 @@ public void testNEBRecordOther2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(2, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 2, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0)); } /** @@ -529,14 +452,7 @@ public void testNEBRemoveNoMatch1(){ 8, Map.of(), 0, 0, 0, 0, 0); assertFalse(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of()); } /** @@ -555,14 +471,8 @@ public void testNEBRemoveNoMatch2(){ 0, 0, 0); assertFalse(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(2L, -1, 3L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 0, 0, + Map.of(2L, -1, 3L, 1)); } /** @@ -579,14 +489,7 @@ public void testNEBRemoveOneVoteOverstatement1(){ 0, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L,1)); } /** @@ -603,14 +506,7 @@ public void testNEBRemoveOneVoteUnderstatement1(){ 0, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L,-1)); } /** @@ -627,14 +523,7 @@ public void testNEBRemoveTwoVoteOverstatement1(){ 0, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L,2)); } /** @@ -651,14 +540,7 @@ public void testNEBRemoveTwoVoteUnderstatement1(){ 1, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L,-2)); } /** @@ -675,14 +557,7 @@ public void testNEBRemoveOther1(){ 0, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L,0)); } /** @@ -700,14 +575,8 @@ public void testNEBRemoveOneVoteOverstatement2(){ 2, 0, 0, 1, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1)); } /** @@ -725,14 +594,8 @@ public void testNEBRemoveOneVoteUnderstatement2(){ 1, 2, 0, 0, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -1, 4L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 0, 1, + Map.of(1L, 0, 2L, 1, 3L, -1, 4L, -1)); } /** @@ -750,14 +613,8 @@ public void testNEBRemoveTwoVoteOverstatement2(){ 1, 0, 2, 1, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(1, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 2, 2L, 1, 3L, -2, 4L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 1, 1, 0, + Map.of(1L, 2, 2L, 1, 3L, -2, 4L, 2)); } /** @@ -775,14 +632,8 @@ public void testNEBRemoveTwoVoteUnderstatement2(){ 1, 0, 0, 2, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2)); } /** @@ -800,14 +651,8 @@ public void testNEBRemoveOther2(){ 1, 0, 0, 1, 2); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0)); } /** @@ -1841,7 +1686,7 @@ public void testNEBReauditBallot3(){ * Test the re-auditing of a ballot where a prior discrepancy is recorded against the * associated CVR (a two vote overstatement). The existing discrepancies associated with the * 'n' copies of the CVR in the sample are removed, but removeDiscrepancy() is called n+1 times - * in error. The n+1'th call the removeDiscrepancy should throw an exception. + * in error. The n+1'th call to the removeDiscrepancy should throw an exception. */ @Test(expectedExceptions = RuntimeException.class) public void testNEBExcessRemovalCausesErrorTwoVoteOver(){ @@ -1865,7 +1710,7 @@ public void testNEBExcessRemovalCausesErrorTwoVoteOver(){ * Test the re-auditing of a ballot where a prior discrepancy is recorded against the * associated CVR (a two vote understatement). The existing discrepancies associated with the * 'n' copies of the CVR in the sample are removed, but removeDiscrepancy() is called n+1 times - * in error. The n+1'th call the removeDiscrepancy should throw an exception. + * in error. The n+1'th call to the removeDiscrepancy should throw an exception. */ @Test(expectedExceptions = RuntimeException.class) public void testNEBExcessRemovalCausesErrorTwoVoteUnder(){ @@ -1889,7 +1734,7 @@ public void testNEBExcessRemovalCausesErrorTwoVoteUnder(){ * Test the re-auditing of a ballot where a prior discrepancy is recorded against the * associated CVR (a one vote understatement). The existing discrepancies associated with the * 'n' copies of the CVR in the sample are removed, but removeDiscrepancy() is called n+1 times - * in error. The n+1'th call the removeDiscrepancy should throw an exception. + * in error. The n+1'th call to the removeDiscrepancy should throw an exception. */ @Test(expectedExceptions = RuntimeException.class) public void testNEBExcessRemovalCausesErrorOneVoteUnder(){ @@ -1913,7 +1758,7 @@ public void testNEBExcessRemovalCausesErrorOneVoteUnder(){ * Test the re-auditing of a ballot where a prior discrepancy is recorded against the * associated CVR (a one vote overstatement). The existing discrepancies associated with the * 'n' copies of the CVR in the sample are removed, but removeDiscrepancy() is called n+1 times - * in error. The n+1'th call the removeDiscrepancy should throw an exception. + * in error. The n+1'th call to the removeDiscrepancy should throw an exception. */ @Test(expectedExceptions = RuntimeException.class) public void testNEBExcessRemovalCausesErrorOneVoteOver(){ @@ -1937,7 +1782,7 @@ public void testNEBExcessRemovalCausesErrorOneVoteOver(){ * Test the re-auditing of a ballot where a prior discrepancy is recorded against the * associated CVR (a one vote overstatement). The existing discrepancies associated with the * 'n' copies of the CVR in the sample are removed, but removeDiscrepancy() is called n+1 times - * in error. The n+1'th call the removeDiscrepancy should throw an exception. + * in error. The n+1'th call to the removeDiscrepancy should throw an exception. */ @Test(expectedExceptions = RuntimeException.class) public void testNEBExcessRemovalCausesErrorOther(){ diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java index a0e7e580..591b20e5 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java @@ -23,6 +23,7 @@ import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.TC; import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.checkComputeDiscrepancy; +import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.checkCountsDiscrepancyMap; import static au.org.democracydevelopers.corla.model.assertion.AssertionTests.countsEqual; import static au.org.democracydevelopers.corla.util.testUtils.log; import static org.mockito.Mockito.when; @@ -252,16 +253,10 @@ public void testNENRecordNoMatch1(){ 0, 0); assertFalse(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of()); } + /** * Test Assertion::recordDiscrepancy(CVRAuditInfo) in the context where no discrepancy has * been computed for the given CVR-ACVR pair, and the assertion has some discrepancies recorded @@ -278,14 +273,8 @@ public void testNENRecordNoMatch2(){ 1, 0, 0, 0); assertFalse(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(2L, -1, 3L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 0, 0, + Map.of(2L, -1, 3L, 1)); } /** @@ -303,14 +292,7 @@ public void testNENRecordOneVoteOverstatement1(){ 0, 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 0, 0, Map.of(1L, 1)); } /** @@ -328,14 +310,7 @@ public void testNENRecordOneVoteUnderstatement1(){ 0, 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 1, 0, 0, 0, Map.of(1L, -1)); } /** @@ -353,14 +328,7 @@ public void testNENRecordTwoVoteOverstatement1(){ 0, 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(1, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 1, 0, 0, Map.of(1L, 2)); } /** @@ -378,14 +346,7 @@ public void testNENRecordTwoVoteUnderstatement1(){ 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 1, 0, Map.of(1L, -2)); } /** @@ -403,14 +364,7 @@ public void testNENRecordOther1(){ 0, 0); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 1, Map.of(1L, 0)); } /** @@ -428,14 +382,8 @@ public void testNENRecordOneVoteOverstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(2, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 2, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1)); } /** @@ -453,14 +401,8 @@ public void testNENRecordOneVoteUnderstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -1)); } /** @@ -478,14 +420,8 @@ public void testNENRecordTwoVoteOverstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(1, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 1, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 2)); } /** @@ -503,14 +439,8 @@ public void testNENRecordTwoVoteUnderstatement2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(2, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 2, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2)); } /** @@ -528,14 +458,8 @@ public void testNENRecordOther2(){ 1, 0, 0, 1, 1); assertTrue(a.recordDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(2, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 2, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0)); } @@ -560,14 +484,7 @@ public void testNENRemoveNoMatch1(){ 0, 0, 0); assertFalse(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of()); } /** @@ -586,14 +503,8 @@ public void testNENRemoveNoMatch2(){ 1, 1, 0, 0, 0); assertFalse(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(2L, -1, 3L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 0, 0, + Map.of(2L, -1, 3L, 1)); } /** @@ -610,14 +521,7 @@ public void testNENRemoveOneVoteOverstatement1(){ 0, 0, 0, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L, 1)); } /** @@ -634,14 +538,7 @@ public void testNENRemoveOneVoteUnderstatement1(){ 1, 0, 0, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L, -1)); } /** @@ -658,14 +555,7 @@ public void testNENRemoveTwoVoteOverstatement1(){ 0, 1, 0, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L, 2)); } /** @@ -682,14 +572,7 @@ public void testNENRemoveTwoVoteUnderstatement1(){ 0, 0, 1, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L, -2)); } /** @@ -706,14 +589,7 @@ public void testNENRemoveOther1(){ 0, 0, 0, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(0, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 0, 0, 0, 0, 0, Map.of(1L, 0)); } /** @@ -731,14 +607,8 @@ public void testNENRemoveOneVoteOverstatement2(){ 4L, 1), 2, 0, 0, 1, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 1)); } /** @@ -756,14 +626,8 @@ public void testNENRemoveOneVoteUnderstatement2(){ 4L, -1), 1, 2, 0, 0, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(1, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(0, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -1, 4L, -1), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 1, 0, 0, 1, + Map.of(1L, 0, 2L, 1, 3L, -1, 4L, -1)); } /** @@ -781,14 +645,8 @@ public void testNENRemoveTwoVoteOverstatement2(){ 4L, 2), 1, 0, 2, 1, 0); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(1, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(0, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 2, 2L, 1, 3L, -2, 4L, 2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 1, 1, 0, + Map.of(1L, 2, 2L, 1, 3L, -2, 4L, 2)); } /** @@ -806,14 +664,8 @@ public void testNENRemoveTwoVoteUnderstatement2(){ 4L, -2), 1, 0, 0, 2, 1); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, -2)); } /** @@ -831,14 +683,8 @@ public void testNENRemoveOther2(){ 4L, 0), 1, 0, 0, 1, 2); assertTrue(a.removeDiscrepancy(info)); - - assertEquals(1, a.oneVoteOverCount.intValue()); - assertEquals(0, a.oneVoteUnderCount.intValue()); - assertEquals(0, a.twoVoteOverCount.intValue()); - assertEquals(1, a.twoVoteUnderCount.intValue()); - assertEquals(1, a.otherCount.intValue()); - - assertEquals(Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0), a.cvrDiscrepancy); + checkCountsDiscrepancyMap(a, 1, 0, 0, 1, 1, + Map.of(1L, 0, 2L, 1, 3L, -2, 4L, 0)); } @@ -1050,14 +896,10 @@ public void testNENComputeDiscrepancyNone(CVRContestInfo info, RecordType audite // None of the above calls to computeDiscrepancy should have produced a discrepancy. assert(d1.isEmpty() && d2.isEmpty() && d3.isEmpty() && d4.isEmpty()); - assert(countsEqual(a1, 0, 0, 0, 0, 0)); - assertEquals(Map.of(), a1.cvrDiscrepancy); - assert(countsEqual(a2, 0, 0, 0, 0, 0)); - assertEquals(Map.of(), a2.cvrDiscrepancy); - assert(countsEqual(a3, 0, 1, 0, 0, 0)); - assertEquals(Map.of(2L, 2), a3.cvrDiscrepancy); - assert(countsEqual(a4, 1, 0, 0, 0, 0)); - assertEquals(Map.of(2L, 1), a4.cvrDiscrepancy); + checkCountsDiscrepancyMap(a1, 0, 0, 0, 0, 0, Map.of()); + checkCountsDiscrepancyMap(a2, 0, 0, 0, 0, 0, Map.of()); + checkCountsDiscrepancyMap(a3, 0, 0, 1, 0, 0, Map.of(2L,2)); + checkCountsDiscrepancyMap(a4, 1, 0, 0, 0, 0, Map.of(2L,1)); } /** From 009905a0e6b0bb45ed41d758fc040e9a36d5392f Mon Sep 17 00:00:00 2001 From: michelleblom Date: Sun, 23 Jun 2024 17:24:44 +1000 Subject: [PATCH 2/3] Added method to allow computation of initial samples to audit at any time during audit. --- .../corla/model/IRVComparisonAudit.java | 21 +++++++-------- .../corla/model/assertion/Assertion.java | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java index b996d523..47ee04f3 100644 --- a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java +++ b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/IRVComparisonAudit.java @@ -255,13 +255,10 @@ protected void recalculateSamplesToAudit() { } /** - * This method is currently not being used in the base class. However, if it starts being used - * in the future, we need an IRV version for IRV audits. Consequently, we provide the IRV - * version here. This method computes and returns the initial (optimistic) sample size - * for the audit. This is computed by calling the optimistic sample size computation method - * of each of the audit's assertions, and returning the maximum of these. A RuntimeException is - * thrown if an unexpected error arises in computing optimistic sample sizes for each assertion. - * @return the optimistic sample size for the audit. + * This method computes and returns the initial (optimistic) sample size for the audit. This is + * computed by calling an initial sample size computation method in each assertion, and returning + * the maximum of the returned values. + * @return the initial (optimistic) sample size for the audit. */ @Override public int initialSamplesToAudit() { @@ -277,19 +274,19 @@ public int initialSamplesToAudit() { final String contestName = getContestName(); try { - LOGGER.debug(String.format("%s computing the initial samples to audit for the IRV contest %s.", - prefix, contestName)); + LOGGER.debug(String.format("%s computing the initial optimistic samples to audit for the " + + "IRV contest %s.", prefix, contestName)); if (assertions.isEmpty()) { LOGGER.debug(String.format("%s No assertions for contest %s; returning an initial sample " + "size of 0.", prefix, contestName)); return 0; } else { - LOGGER.debug(String.format("%s calling computeOptimisticSamplesToAudit() for each " + + LOGGER.debug(String.format("%s calling computeInitialOptimisticSamplesToAudit() for each " + "assertion in contest %s given risk limit %f.", prefix, contestName, getRiskLimit())); final int samples = max(assertions.stream().map(a -> - a.computeOptimisticSamplesToAudit(getRiskLimit())).toList()); - LOGGER.debug(String.format("%s optimistic sample size of %d computed for contest %s.", + a.computeInitialOptimisticSamplesToAudit(getRiskLimit())).toList()); + LOGGER.debug(String.format("%s initial optimistic sample size of %d computed for contest %s.", prefix, samples, contestName)); return samples; } diff --git a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/Assertion.java b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/Assertion.java index 8157f22b..64c59b62 100644 --- a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/Assertion.java +++ b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/Assertion.java @@ -319,6 +319,32 @@ public Integer computeOptimisticSamplesToAudit(BigDecimal riskLimit) { return optimisticSamplesToAudit; } + /** + * For the given risk limit, compute the expected initial (optimistic) number of samples to audit + * for this assertion. This calculation calls Audit::optimistic() with zero's for each discrepancy + * count. This method does not change any of this assertion's internal sample size attributes. + * + * @param riskLimit The risk limit of the audit. + * @return The initial (optimistic) number of samples we expect we will need to sample to + * audit this assertion. + */ + public Integer computeInitialOptimisticSamplesToAudit(BigDecimal riskLimit){ + final String prefix = "[computeInitialOptimisticSamplesToAudit]"; + + LOGGER.debug(String.format("%s Calling Audit::optimistic() with parameters: risk limit " + + "%f; diluted margin %f; gamma %f; two vote under count 0; one vote under count 0; " + + "one vote over count 0; two vote over count 0.", prefix, riskLimit, dilutedMargin, Audit.GAMMA)); + + // Call the colorado-rla audit math; update optimistic_samples_to_audit and return new value. + final int initialOptimistic = Audit.optimistic(riskLimit, dilutedMargin, Audit.GAMMA, + 0, 0, 0, 0).intValue(); + + LOGGER.debug(String.format("%s Computed initial optimistic samples to audit for Assertion %d" + + " of %s ballots.", prefix, id, initialOptimistic)); + + return initialOptimistic; + } + /** * Compute and return the estimated number of samples to audit for this assertion, given the * number of ballots audited thus far and number of observed overstatements. This method takes From 513034f6e2d4d863ed075b45915fc9eddb602856 Mon Sep 17 00:00:00 2001 From: Vanessa Teague Date: Sun, 23 Jun 2024 21:53:21 +1000 Subject: [PATCH 3/3] Update maven.yml --- .github/workflows/maven.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 2c54d038..0d1372e1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -35,3 +35,6 @@ jobs: - name: Classic Tests run: cd server/eclipse-project; mvn -Dtest='us.freeandfair.corla.**' test + + - name: IRV Tests + run: cd server/eclipse-project; mvn -Dtest='au.org.democracydevelopers.corla.**' test