### Question:
TransactionBroadcast { public ListenableFuture<Transaction> broadcast() { log.info("Waiting for {} peers required for broadcast ...", minConnections); ListenableFuture<PeerGroup> peerAvailabilityFuture = peerGroup.waitForPeers(minConnections); peerAvailabilityFuture.addListener(new EnoughAvailablePeers(), Threading.SAME_THREAD); return future; } TransactionBroadcast(PeerGroup peerGroup, Transaction tx); ListenableFuture<Transaction> future(); void setMinConnections(int minConnections); ListenableFuture<Transaction> broadcast();  }### Answer:
@Test public void fourPeers() throws Exception { InboundMessageQueuer[] channels = { connectPeer(1), connectPeer(2), connectPeer(3), connectPeer(4) }; Transaction tx = new Transaction(params); TransactionBroadcast broadcast = new TransactionBroadcast(peerGroup, tx); ListenableFuture<Transaction> future = broadcast.broadcast(); assertFalse(future.isDone()); Message[] messages = { (Message) outbound(channels[0]), (Message) outbound(channels[1]), (Message) outbound(channels[2]), (Message) outbound(channels[3]) }; assertEquals(tx, messages[0]); assertEquals(tx, messages[3]); assertNull(messages[1]); assertNull(messages[2]); Threading.waitForUserCode(); assertFalse(future.isDone()); inbound(channels[1], InventoryMessage.with(tx)); pingAndWait(channels[1]); Threading.waitForUserCode(); assertTrue(future.isDone()); }