@ -224,19 +224,20 @@ public class PeerDiscoveryAgentTest {
final IncomingPacket neighborsPacket = incomingPackets . get ( 0 ) ;
assertThat ( neighborsPacket . fromAgent ) . isEqualTo ( agent ) ;
// Assert that we only received 16 items.
// Assert that we only received 13 items.
assertThat ( neighborsPacket . packet . getPacketData ( NeighborsPacketData . class ) . isPresent ( ) )
. isTrue ( ) ;
final NeighborsPacketData neighbors =
neighborsPacket . packet . getPacketData ( NeighborsPacketData . class ) . get ( ) ;
assertThat ( neighbors ) . isNotNull ( ) ;
assertThat ( neighbors . getNodes ( ) ) . hasSize ( 16 ) ;
assertThat ( neighbors . getNodes ( ) ) . hasSize ( 13 ) ;
assertThat ( neighborsPacket . packet . encode ( ) . length ( ) ) . isLessThanOrEqualTo ( 1280 ) ; // under max MTU
// Assert that after removing those 16 items we're left with either 4 or 5 .
// If we are left with 5 , the test peer was returned as an item, assert that this is the case.
// Assert that after removing those 13 items we're left with either 7 or 8 .
// If we are left with 8 , the test peer was returned as an item, assert that this is the case.
otherPeers . removeAll ( neighbors . getNodes ( ) ) ;
assertThat ( otherPeers . size ( ) ) . isBetween ( 4 , 5 ) ;
if ( otherPeers . size ( ) = = 5 ) {
assertThat ( otherPeers . size ( ) ) . isBetween ( 7 , 8 ) ;
if ( otherPeers . size ( ) = = 8 ) {
assertThat ( testAgent . getAdvertisedPeer ( ) . isPresent ( ) ) . isTrue ( ) ;
assertThat ( neighbors . getNodes ( ) ) . contains ( testAgent . getAdvertisedPeer ( ) . get ( ) ) ;
}