@ -19,6 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail ;
import static org.assertj.core.api.Fail.fail ;
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier ;
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier ;
import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage ;
import org.hyperledger.besu.consensus.common.bft.payload.Payload ;
import org.hyperledger.besu.consensus.common.bft.payload.Payload ;
import org.hyperledger.besu.consensus.common.bft.payload.SignedData ;
import org.hyperledger.besu.consensus.common.bft.payload.SignedData ;
import org.hyperledger.besu.consensus.ibft.messagedata.CommitMessageData ;
import org.hyperledger.besu.consensus.ibft.messagedata.CommitMessageData ;
@ -26,7 +27,6 @@ import org.hyperledger.besu.consensus.ibft.messagedata.IbftV2;
import org.hyperledger.besu.consensus.ibft.messagedata.PrepareMessageData ;
import org.hyperledger.besu.consensus.ibft.messagedata.PrepareMessageData ;
import org.hyperledger.besu.consensus.ibft.messagedata.ProposalMessageData ;
import org.hyperledger.besu.consensus.ibft.messagedata.ProposalMessageData ;
import org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData ;
import org.hyperledger.besu.consensus.ibft.messagedata.RoundChangeMessageData ;
import org.hyperledger.besu.consensus.ibft.messagewrappers.IbftMessage ;
import org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange ;
import org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange ;
import org.hyperledger.besu.consensus.ibft.payload.PreparePayload ;
import org.hyperledger.besu.consensus.ibft.payload.PreparePayload ;
import org.hyperledger.besu.consensus.ibft.payload.RoundChangePayload ;
import org.hyperledger.besu.consensus.ibft.payload.RoundChangePayload ;
@ -151,35 +151,35 @@ public class RoundSpecificPeers {
}
}
@SafeVarargs
@SafeVarargs
public final void verifyMessagesReceivedProposer ( final Ib ftMessage< ? extends Payload > . . . msgs ) {
public final void verifyMessagesReceivedProposer ( final B ftMessage< ? extends Payload > . . . msgs ) {
verifyMessagesReceived ( ImmutableList . of ( proposer ) , msgs ) ;
verifyMessagesReceived ( ImmutableList . of ( proposer ) , msgs ) ;
}
}
@SafeVarargs
@SafeVarargs
public final void verifyMessagesReceivedNonPropsingExcluding (
public final void verifyMessagesReceivedNonPropsingExcluding (
final ValidatorPeer exclude , final Ib ftMessage< ? extends Payload > . . . msgs ) {
final ValidatorPeer exclude , final B ftMessage< ? extends Payload > . . . msgs ) {
final Collection < ValidatorPeer > candidates = Lists . newArrayList ( nonProposingPeers ) ;
final Collection < ValidatorPeer > candidates = Lists . newArrayList ( nonProposingPeers ) ;
candidates . remove ( exclude ) ;
candidates . remove ( exclude ) ;
verifyMessagesReceived ( candidates , msgs ) ;
verifyMessagesReceived ( candidates , msgs ) ;
}
}
public final void verifyMessagesReceivedNonPropsing ( final Ib ftMessage< ? > . . . msgs ) {
public final void verifyMessagesReceivedNonPropsing ( final B ftMessage< ? > . . . msgs ) {
verifyMessagesReceived ( nonProposingPeers , msgs ) ;
verifyMessagesReceived ( nonProposingPeers , msgs ) ;
}
}
public final void verifyMessagesReceived ( final Ib ftMessage< ? > . . . msgs ) {
public final void verifyMessagesReceived ( final B ftMessage< ? > . . . msgs ) {
verifyMessagesReceived ( peers , msgs ) ;
verifyMessagesReceived ( peers , msgs ) ;
}
}
private void verifyMessagesReceived (
private void verifyMessagesReceived (
final Collection < ValidatorPeer > candidates , final Ib ftMessage< ? > . . . msgs ) {
final Collection < ValidatorPeer > candidates , final B ftMessage< ? > . . . msgs ) {
candidates . forEach ( n - > assertThat ( n . getReceivedMessages ( ) . size ( ) ) . isEqualTo ( msgs . length ) ) ;
candidates . forEach ( n - > assertThat ( n . getReceivedMessages ( ) . size ( ) ) . isEqualTo ( msgs . length ) ) ;
List < Ib ftMessage< ? extends Payload > > msgList = Arrays . asList ( msgs ) ;
List < B ftMessage< ? extends Payload > > msgList = Arrays . asList ( msgs ) ;
for ( int i = 0 ; i < msgList . size ( ) ; i + + ) {
for ( int i = 0 ; i < msgList . size ( ) ; i + + ) {
final int index = i ;
final int index = i ;
final Ib ftMessage< ? extends Payload > msg = msgList . get ( index ) ;
final B ftMessage< ? extends Payload > msg = msgList . get ( index ) ;
candidates . forEach (
candidates . forEach (
n - > {
n - > {
final List < MessageData > rxMsgs = n . getReceivedMessages ( ) ;
final List < MessageData > rxMsgs = n . getReceivedMessages ( ) ;
@ -190,8 +190,8 @@ public class RoundSpecificPeers {
candidates . forEach ( ValidatorPeer : : clearReceivedMessages ) ;
candidates . forEach ( ValidatorPeer : : clearReceivedMessages ) ;
}
}
private void verifyMessage ( final MessageData actual , final Ib ftMessage< ? > expectedMessage ) {
private void verifyMessage ( final MessageData actual , final B ftMessage< ? > expectedMessage ) {
Ib ftMessage< ? > actualSignedPayload = null ;
B ftMessage< ? > actualSignedPayload = null ;
switch ( expectedMessage . getMessageType ( ) ) {
switch ( expectedMessage . getMessageType ( ) ) {
case IbftV2 . PROPOSAL :
case IbftV2 . PROPOSAL :