Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigorov-Georgi committed Jan 2, 2025
1 parent 4fd4822 commit 2fa850f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/limechain/grandpa/GrandpaService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.limechain.grandpa;

import com.limechain.exception.global.ExecutionFailedException;
import com.limechain.exception.storage.BlockStorageGenericException;
import com.limechain.grandpa.state.GrandpaState;
import com.limechain.grandpa.state.Subround;
Expand Down Expand Up @@ -41,8 +42,7 @@ public Vote getGrandpaGHOST() {
Map<Hash256, BigInteger> blocks = getPossibleSelectedBlocks(threshold, Subround.PRE_VOTE);

if (blocks.isEmpty() || threshold.equals(BigInteger.ZERO)) {
log.warning("GHOST not found");
return null;
throw new ExecutionFailedException("GHOST not found");
}

return selectBlockWithMostVotes(blocks);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/limechain/grandpa/GrandpaServiceTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.limechain.grandpa;

import com.limechain.exception.global.ExecutionFailedException;
import com.limechain.grandpa.state.GrandpaState;
import com.limechain.grandpa.state.Subround;
import com.limechain.network.protocol.grandpa.messages.catchup.res.SignedVote;
Expand All @@ -24,6 +25,7 @@
import static com.limechain.utils.TestUtils.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -54,9 +56,7 @@ void setUp() {
void testGetGrandpaGHOSTWhereNoBlocksPassThreshold() {
when(grandpaState.getThreshold()).thenReturn(BigInteger.valueOf(10));
when(grandpaState.getPrevotes()).thenReturn(Map.of());

var result = grandpaService.getGrandpaGHOST();
assertNull(result);
assertThrows(ExecutionFailedException.class, () -> grandpaService.getGrandpaGHOST());
}

@Test
Expand Down

0 comments on commit 2fa850f

Please sign in to comment.