Search in sources :

Example 1 with BftReceivedMessageEvent

use of org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent in project besu by hyperledger.

the class QbftControllerTest method proposalForCurrentHeightIsPassedToBlockHeightManager.

@Test
public void proposalForCurrentHeightIsPassedToBlockHeightManager() {
    setupProposal(roundIdentifier, validator);
    constructQbftController();
    qbftController.start();
    qbftController.handleMessageEvent(new BftReceivedMessageEvent(proposalMessage));
    verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
    verify(blockHeightManager).handleProposalPayload(proposal);
    verify(qbftGossip).send(proposalMessage);
    verify(blockHeightManager, atLeastOnce()).getChainHeight();
    verifyNoMoreInteractions(blockHeightManager);
}
Also used : BftReceivedMessageEvent(org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent) Test(org.junit.Test)

Example 2 with BftReceivedMessageEvent

use of org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent in project besu by hyperledger.

the class QbftControllerTest method roundChangeForUnknownValidatorIsDiscarded.

@Test
public void roundChangeForUnknownValidatorIsDiscarded() {
    setupRoundChange(roundIdentifier, unknownValidator);
    verifyNotHandledAndNoFutureMsgs(new BftReceivedMessageEvent(roundChangeMessage));
}
Also used : BftReceivedMessageEvent(org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent) Test(org.junit.Test)

Example 3 with BftReceivedMessageEvent

use of org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent in project besu by hyperledger.

the class QbftControllerTest method roundChangeForPastHeightIsDiscarded.

@Test
public void roundChangeForPastHeightIsDiscarded() {
    setupRoundChange(pastRoundIdentifier, validator);
    verifyNotHandledAndNoFutureMsgs(new BftReceivedMessageEvent(roundChangeMessage));
}
Also used : BftReceivedMessageEvent(org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent) Test(org.junit.Test)

Example 4 with BftReceivedMessageEvent

use of org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent in project besu by hyperledger.

the class QbftControllerTest method messagesWhichAreAboveHeightManagerButBelowBlockChainLengthAreDiscarded.

@Test
public void messagesWhichAreAboveHeightManagerButBelowBlockChainLengthAreDiscarded() {
    // NOTE: for this to occur, the system would need to be synchronising - i.e. blockchain is
    // moving up faster than qbft loop is handling NewBlock messages
    final long blockchainLength = 10L;
    final long blockHeightManagerTargettingBlock = 6L;
    final long messageHeight = 8L;
    setupProposal(new ConsensusRoundIdentifier(messageHeight, 0), validator);
    when(blockChain.getChainHeadHeader()).thenReturn(chainHeadBlockHeader);
    when(blockChain.getChainHeadBlockNumber()).thenReturn(blockchainLength);
    when(blockHeightManagerFactory.create(any())).thenReturn(blockHeightManager);
    when(blockHeightManager.getChainHeight()).thenReturn(blockHeightManagerTargettingBlock);
    constructQbftController();
    qbftController.start();
    qbftController.handleMessageEvent(new BftReceivedMessageEvent(proposalMessage));
    verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
    verify(blockHeightManager, never()).handleProposalPayload(any());
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) BftReceivedMessageEvent(org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent) Test(org.junit.Test)

Example 5 with BftReceivedMessageEvent

use of org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent in project besu by hyperledger.

the class QbftControllerTest method roundChangeForCurrentHeightIsPassedToBlockHeightManager.

@Test
public void roundChangeForCurrentHeightIsPassedToBlockHeightManager() {
    setupRoundChange(roundIdentifier, validator);
    constructQbftController();
    qbftController.start();
    qbftController.handleMessageEvent(new BftReceivedMessageEvent(roundChangeMessage));
    verify(futureMessageBuffer, never()).addMessage(anyLong(), any());
    verify(blockHeightManager).handleRoundChangePayload(roundChange);
    verify(qbftGossip).send(roundChangeMessage);
    verify(blockHeightManager, atLeastOnce()).getChainHeight();
    verifyNoMoreInteractions(blockHeightManager);
}
Also used : BftReceivedMessageEvent(org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent) Test(org.junit.Test)

Aggregations

BftReceivedMessageEvent (org.hyperledger.besu.consensus.common.bft.events.BftReceivedMessageEvent)33 Test (org.junit.Test)30 ConsensusRoundIdentifier (org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier)2 BlockTimerExpiry (org.hyperledger.besu.consensus.common.bft.events.BlockTimerExpiry)1 NewChainHead (org.hyperledger.besu.consensus.common.bft.events.NewChainHead)1 RoundExpiry (org.hyperledger.besu.consensus.common.bft.events.RoundExpiry)1