Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINOR] switch QBFT tests to Junit5 #5525

Merged
merged 3 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consensus/qbft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ dependencies {
testImplementation project(':metrics:core')
testImplementation project(':testutil')

testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import java.util.Optional;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class MutableQbftConfigOptionsTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.List;
import java.util.Optional;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class QbftBlockHeaderValidationRulesetFactoryTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import com.google.common.base.Suppliers;
import com.google.common.collect.Lists;
import org.apache.tuweni.bytes.Bytes;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class QbftExtraDataCodecTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import java.util.List;
import java.util.Optional;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class QbftProtocolScheduleTest {
private final BftExtraDataCodec bftExtraDataCodec = mock(BftExtraDataCodec.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import java.util.Collections;

import org.apache.tuweni.bytes.Bytes;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class PkiQbftBlockCreatorTest {

Expand All @@ -54,7 +54,7 @@ public class PkiQbftBlockCreatorTest {
private PkiQbftBlockCreator pkiQbftBlockCreator;
private BlockHeaderTestFixture blockHeaderBuilder;

@Before
@BeforeEach
public void before() {
blockCreator = mock(BlockCreator.class);
cmsCreator = mock(CmsCreator.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
import java.util.Optional;

import org.apache.tuweni.bytes.Bytes;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class QbftBlockCreatorFactoryTest {
private final QbftExtraDataCodec extraDataCodec = new QbftExtraDataCodec();
private QbftBlockCreatorFactory qbftBlockCreatorFactory;

@Before
@BeforeEach
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
final MiningParameters miningParams = mock(MiningParameters.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Optional;

import com.google.common.collect.Lists;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class QbftValidatorsValidationRuleTest {
private final BftExtraData bftExtraData = mock(BftExtraData.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

import java.util.Optional;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class QbftDiscardValidatorVoteTest {
private final ValidatorProvider validatorProvider = mock(ValidatorProvider.class);
Expand All @@ -43,7 +43,7 @@ public class QbftDiscardValidatorVoteTest {
private final String JSON_RPC_VERSION = "2.0";
private QbftDiscardValidatorVote method;

@Before
@BeforeEach
public void setup() {
method = new QbftDiscardValidatorVote(validatorProvider);
when(validatorProvider.getVoteProviderAtHead()).thenReturn(Optional.of(voteProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import java.util.Optional;
import java.util.stream.LongStream;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class QbftGetSignerMetricsTest {

Expand All @@ -58,7 +58,7 @@ public class QbftGetSignerMetricsTest {
private BlockchainQueries blockchainQueries;
private BlockInterface blockInterface;

@Before
@BeforeEach
public void setup() {
validatorProvider = mock(ValidatorProvider.class);
blockchainQueries = mock(BlockchainQueries.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
import java.util.Optional;

import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class QbftGetValidatorsByBlockHashTest {

private static final String ETH_METHOD = "qbft_getValidatorsByBlockHash";
Expand All @@ -51,7 +51,7 @@ public class QbftGetValidatorsByBlockHashTest {

private QbftGetValidatorsByBlockHash method;

@Before
@BeforeEach
public void setUp() {
method = new QbftGetValidatorsByBlockHash(blockchain, validatorProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import java.util.List;
import java.util.Optional;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class QbftGetValidatorsByBlockNumberTest {

@Mock private BlockchainQueries blockchainQueries;
Expand All @@ -46,7 +46,7 @@ public class QbftGetValidatorsByBlockNumberTest {

private QbftGetValidatorsByBlockNumber method;

@Before
@BeforeEach
public void setUp() {
method = new QbftGetValidatorsByBlockNumber(blockchainQueries, validatorProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

import java.util.Optional;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class QbftProposeValidatorVoteTest {
private final ValidatorProvider validatorProvider = mock(ValidatorProvider.class);
Expand All @@ -43,7 +43,7 @@ public class QbftProposeValidatorVoteTest {
private final String JSON_RPC_VERSION = "2.0";
private QbftProposeValidatorVote method;

@Before
@BeforeEach
public void setup() {
method = new QbftProposeValidatorVote(validatorProvider);
when(validatorProvider.getVoteProviderAtHead()).thenReturn(Optional.of(voteProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import java.math.BigInteger;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class CommitTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.Util;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class PrepareTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import java.util.Optional;

import org.apache.tuweni.bytes.Bytes32;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ProposalTest {
private static final BftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Optional;

import org.apache.tuweni.bytes.Bytes32;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class RoundChangeTest {
private static final BftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class QbftPayloadTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

import java.nio.file.Path;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class DefaultKeyStoreWrapperProviderTest {

@Mock private HardwareKeyStoreWrapperProvider hardwareKeyStoreWrapperProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

import java.nio.file.Path;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PkiBlockCreationConfigurationProviderTest {

@Mock KeyStoreWrapperProvider keyStoreWrapperProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;

import org.apache.tuweni.bytes.Bytes;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class PkiQbftBlockHashingTest {

private PkiQbftExtraDataCodec pkiExtraDataCodec = new PkiQbftExtraDataCodec();
private PkiQbftBlockHashing pkiQbftBlockHashing;

@Before
@BeforeEach
public void before() {
pkiExtraDataCodec = spy(new PkiQbftExtraDataCodec());
pkiQbftBlockHashing = new PkiQbftBlockHashing(pkiExtraDataCodec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import com.google.common.base.Suppliers;
import org.apache.tuweni.bytes.Bytes;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class PkiQbftExtraDataCodecTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class Istanbul100SubProtocolTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@
import com.google.common.collect.Lists;
import org.apache.tuweni.bytes.Bytes;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class QbftBlockHeightManagerTest {

private final NodeKey nodeKey = NodeKeyUtils.generate();
Expand Down Expand Up @@ -126,7 +129,7 @@ private void buildCreatedBlock() {
createdBlock = new Block(header, new BlockBody(emptyList(), emptyList()));
}

@Before
@BeforeEach
public void setup() {
for (int i = 0; i < 3; i++) {
final NodeKey nodeKey = NodeKeyUtils.generate();
Expand Down
Loading