Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Riley <derek.riley@swirldslabs.com>
  • Loading branch information
derektriley committed Oct 23, 2024
1 parent 0363d63 commit 4fc3543
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void handleReturnsWhenDuplicateVoteExists() throws HandleException {
void hasReachedThresholdReturnsFalseWhenThresholdIsNotMet() {
// Setup in-memory data
final RosterEntry rosterEntry1 = new RosterEntry(1L, 1L, null, null, List.of());
final RosterEntry rosterEntry2 = new RosterEntry(2L, 2L, null, null, List.of());
final RosterEntry rosterEntry2 = new RosterEntry(2L, 3L, null, null, List.of());
final Roster roster = new Roster(List.of(rosterEntry1, rosterEntry2));
final TssVoteTransactionBody voteTransactionBody =
new TssVoteTransactionBody(Bytes.EMPTY, Bytes.EMPTY, Bytes.EMPTY, Bytes.EMPTY, Bytes.EMPTY);
Expand All @@ -167,15 +167,16 @@ void hasReachedThresholdReturnsFalseWhenThresholdIsNotMet() {
when(tssBaseStore.getVote(any(TssVoteMapKey.class)))
.thenAnswer(invocation -> voteStore.get(invocation.getArgument(0)));

final boolean result = TssVoteHandler.hasReachedThreshold(voteTransactionBody, handleContext, 2L);
final boolean result = TssVoteHandler.hasReachedThreshold(
voteTransactionBody, handleContext, TssVoteHandler.CONSENSUS_VOTE_THRESHOLD_ONE_THIRD);

assertFalse(result, "Threshold should not be met");
}

@Test
void hasReachedThresholdReturnsFalseWhenThresholdIsMet() {
void hasReachedThresholdReturnsTrueWhenThresholdIsMet() {
// Setup in-memory data
final RosterEntry rosterEntry1 = new RosterEntry(1L, 2L, null, null, List.of());
final RosterEntry rosterEntry1 = new RosterEntry(1L, 1L, null, null, List.of());
final RosterEntry rosterEntry2 = new RosterEntry(2L, 2L, null, null, List.of());
final Roster roster = new Roster(List.of(rosterEntry1, rosterEntry2));
final TssVoteTransactionBody voteTransactionBody =
Expand All @@ -198,7 +199,8 @@ void hasReachedThresholdReturnsFalseWhenThresholdIsMet() {
when(tssBaseStore.getVote(any(TssVoteMapKey.class)))
.thenAnswer(invocation -> voteStore.get(invocation.getArgument(0)));

boolean result = TssVoteHandler.hasReachedThreshold(voteTransactionBody, handleContext, 2L);
boolean result = TssVoteHandler.hasReachedThreshold(
voteTransactionBody, handleContext, TssVoteHandler.CONSENSUS_VOTE_THRESHOLD_ONE_THIRD);

assertTrue(result, "Threshold should be met");
}
Expand Down

0 comments on commit 4fc3543

Please sign in to comment.