### Question:
TransactionBroadcast { public void setProgressCallback(ProgressCallback callback) { setProgressCallback(callback, Threading.USER_THREAD); } TransactionBroadcast(PeerGroup peerGroup, Transaction tx); private  TransactionBroadcast(Transaction tx); @VisibleForTesting static TransactionBroadcast createMockBroadcast(Transaction tx, final SettableFuture<Transaction> future); ListenableFuture<Transaction> future(); void setMinConnections(int minConnections); ListenableFuture<Transaction> broadcast(); void setProgressCallback(ProgressCallback callback); void setProgressCallback(ProgressCallback callback, @Nullable Executor executor); @VisibleForTesting
    static Random random; }### Answer:
@Test public void lateProgressCallback() throws Exception { InboundMessageQueuer[] channels = { connectPeer(1), connectPeer(2), connectPeer(3), connectPeer(4) }; Transaction tx = FakeTxBuilder.createFakeTx(UNITTEST, CENT, address); tx.getConfidence().setSource(TransactionConfidence.Source.SELF); TransactionBroadcast broadcast = peerGroup.broadcastTransaction(tx); inbound(channels[1], InventoryMessage.with(tx)); pingAndWait(channels[1]); final AtomicDouble p = new AtomicDouble(); broadcast.setProgressCallback(new TransactionBroadcast.ProgressCallback() { @Override public void onBroadcastProgress(double progress) { p.set(progress); } }, Threading.SAME_THREAD); assertEquals(1.0, p.get(), 0.01); }
@Test public void lateProgressCallback() throws Exception { InboundMessageQueuer[] channels = {connectPeer(1), connectPeer(2), connectPeer(3), connectPeer(4)}; Transaction tx = FakeTxBuilder.createFakeTx(UNITTEST, CENT, address); tx.getConfidence().setSource(TransactionConfidence.Source.SELF); TransactionBroadcast broadcast = peerGroup.broadcastTransaction(tx); inbound(channels[1], InventoryMessage.with(tx)); pingAndWait(channels[1]); final AtomicDouble p = new AtomicDouble(); broadcast.setProgressCallback(new TransactionBroadcast.ProgressCallback() { @Override public void onBroadcastProgress(double progress) { p.set(progress); } }, Threading.SAME_THREAD); assertEquals(1.0, p.get(), 0.01); }
@Test public void lateProgressCallback() throws Exception { InboundMessageQueuer[] channels = { connectPeer(1), connectPeer(2), connectPeer(3), connectPeer(4) }; Transaction tx = FakeTxBuilder.createFakeTx(PARAMS, CENT, address); tx.getConfidence().setSource(TransactionConfidence.Source.SELF); TransactionBroadcast broadcast = peerGroup.broadcastTransaction(tx); inbound(channels[1], InventoryMessage.with(tx)); pingAndWait(channels[1]); final AtomicDouble p = new AtomicDouble(); broadcast.setProgressCallback(new TransactionBroadcast.ProgressCallback() { @Override public void onBroadcastProgress(double progress) { p.set(progress); } }, Threading.SAME_THREAD); assertEquals(1.0, p.get(), 0.01); }