From a2cd253515cc80d0eff9d22ebfef3e8e7ea6f050 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 14 Nov 2026 10:22:59 -0600 Subject: [PATCH] Add VoteParty pending preparation regression test --- .../VotePartyStoredRecipientFailureTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/specialrewards/VotePartyStoredRecipientFailureTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/specialrewards/VotePartyStoredRecipientFailureTest.java index 00762ff9f..f371e95a0 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/specialrewards/VotePartyStoredRecipientFailureTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/specialrewards/VotePartyStoredRecipientFailureTest.java @@ -554,4 +554,32 @@ class VotePartyStoredRecipientFailureTest { assertEquals(reset ? 0 : 8, party.getTotalVotes()); } + + @Test + void votesAccumulatedDuringStoredPreparationTriggerNextPartyWithoutAnotherVote() { + when(mysql.getRowsQuery()).thenReturn(new ArrayList<>()); + + // The first threshold starts asynchronous stored-recipient preparation. + party.check(user, false); + assertEquals(1, storage.size()); + + // Three more votes arrive while the first party is still preparing. + // Each vote performs the normal threshold check, but those checks are + // suppressed while storedPreparation is active. + for (int i = 0; i < 3; i++) { + party.addTotal(user); + party.check(user, false); + } + assertEquals(6, party.getTotalVotes()); + + // Completing the first party must retain responsibility for the three + // accumulated votes and start the second party without a seventh vote. + drain(); + + assertEquals(0, party.getTotalVotes(), + "remaining eligible votes must be rechecked when stored preparation finishes"); + verify(serverData, times(2)).updateLastVoteParty(); + } + + }