@Test
public void waitForPeersOfVersion() throws Exception {

    final int baseVer = peerGroup.getMinRequiredProtocolVersion() + 3000;
    final int newVer = baseVer + 1000;
    ListenableFuture<List<Peer>> future = peerGroup.waitForPeersOfVersion(2, newVer);
    VersionMessage ver1 = new VersionMessage(UNITTEST, 10);
    ver1.clientVersion = baseVer;
    ver1.localServices = VersionMessage.NODE_NETWORK;
    VersionMessage ver2 = new VersionMessage(UNITTEST, 10);
    ver2.clientVersion = newVer;
    ver2.localServices = VersionMessage.NODE_NETWORK;
    peerGroup.start();
    assertFalse(future.isDone());
    connectPeer(1, ver1);
    assertFalse(future.isDone());
    connectPeer(2, ver2);
    assertFalse(future.isDone());
    assertTrue(peerGroup.waitForPeersOfVersion(1, newVer).isDone());   // Immediate completion.
    connectPeer(3, ver2);
    future.get();
    assertTrue(future.isDone());
}