Skip to content

Commit

Permalink
fixed sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr committed Jan 17, 2025
1 parent 23d716d commit 7013a20
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
12 changes: 3 additions & 9 deletions src/main/java/com/limechain/grandpa/state/GrandpaSetState.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,9 @@ public void handleGrandpaConsensusMessage(GrandpaConsensusMessage consensusMessa
currentBlockNumber
));
//TODO: Implement later
case GRANDPA_ON_DISABLED -> {
log.log(Level.SEVERE, "'ON DISABLED' grandpa message not implemented");
}
case GRANDPA_PAUSE -> {
log.log(Level.SEVERE, "'PAUSE' grandpa message not implemented");
}
case GRANDPA_RESUME -> {
log.log(Level.SEVERE, "'RESUME' grandpa message not implemented");
}
case GRANDPA_ON_DISABLED -> log.log(Level.SEVERE, "'ON DISABLED' grandpa message not implemented");
case GRANDPA_PAUSE -> log.log(Level.SEVERE, "'PAUSE' grandpa message not implemented");
case GRANDPA_RESUME -> log.log(Level.SEVERE, "'RESUME' grandpa message not implemented");
}

log.fine(String.format("Updated grandpa set config: %s", consensusMessage.getFormat().toString()));
Expand Down
10 changes: 0 additions & 10 deletions src/test/java/com/limechain/grandpa/GrandpaServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
import com.limechain.network.protocol.warp.dto.DigestType;
import com.limechain.network.protocol.warp.dto.HeaderDigest;
import com.limechain.storage.block.BlockState;
import com.limechain.utils.Ed25519Utils;
import io.emeraldpay.polkaj.types.Hash256;
import io.emeraldpay.polkaj.types.Hash512;
import io.libp2p.core.crypto.PubKey;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -366,10 +364,6 @@ void testGetDirectVotesForPrevotes() throws Exception {

@Test
void testGetDirectVotesWithMultipleVotesForSingleBlockForPrevotes() throws Exception {
// Prepare mock data
PubKey pubKey1 = Ed25519Utils.generateKeyPair().publicKey();
PubKey pubKey2 = Ed25519Utils.generateKeyPair().publicKey();

Vote firstVote = new Vote(new Hash256(ONES_ARRAY), BigInteger.valueOf(3));
Vote secondVote = new Vote(new Hash256(ONES_ARRAY), BigInteger.valueOf(3));
Hash256 firstVoteAuthorityHash = new Hash256(ONES_ARRAY);
Expand All @@ -395,9 +389,6 @@ void testGetDirectVotesWithMultipleVotesForSingleBlockForPrevotes() throws Excep

@Test
void testGetVotes() throws Exception {
// Prepare mock data
Ed25519Utils.generateKeyPair().publicKey();

Vote firstVote = new Vote(new Hash256(ONES_ARRAY), BigInteger.valueOf(3));
Hash256 firstVoteAuthorityHash = new Hash256(ONES_ARRAY);
SignedVote firstSignedVote = new SignedVote(firstVote, Hash512.empty(), firstVoteAuthorityHash);
Expand All @@ -419,7 +410,6 @@ void testGetVotes() throws Exception {

@Test
void testGetVotesWithMultipleVotes() throws Exception {

Vote firstVote = new Vote(new Hash256(ONES_ARRAY), BigInteger.valueOf(3));
Vote secondVote = new Vote(new Hash256(TWOS_ARRAY), BigInteger.valueOf(4));
Hash256 firstVoteAuthorityHash = new Hash256(ONES_ARRAY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,14 @@ void testDerivePrimary() {
grandpaSetState.setRoundCache(roundCache);

// 4 % voters.size = 1
// grandpaSetState.setRoundNumber();
when(roundCache.getLatestRoundNumber(BigInteger.ONE)).thenReturn(BigInteger.valueOf(4));
assertEquals(BigInteger.ONE, grandpaSetState.derivePrimary());

// 5 % voters.size = 2
// grandpaSetState.setRoundNumber(BigInteger.valueOf(5));
when(roundCache.getLatestRoundNumber(BigInteger.ONE)).thenReturn(BigInteger.valueOf(5));
assertEquals(BigInteger.TWO, grandpaSetState.derivePrimary());

// 6 % voters.size = 0
// grandpaSetState.setRoundNumber(BigInteger.valueOf(6));
when(roundCache.getLatestRoundNumber(BigInteger.ONE)).thenReturn(BigInteger.valueOf(6));
assertEquals(BigInteger.ZERO, grandpaSetState.derivePrimary());
}
Expand Down

0 comments on commit 7013a20

Please sign in to comment.