    @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());
        // We expect two peers to receive a tx message, and at least one of the others must announce for the future to
        // complete successfully.
        Message[] messages = {
                (Message) outbound(channels[0]),
                (Message) outbound(channels[1]),
                (Message) outbound(channels[2]),
                (Message) outbound(channels[3])
        };
        // 0 and 3 are randomly selected to receive the broadcast.
        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());
    }