@Test
public void invDownloadTx() throws Exception {

    connect();
    peer.setDownloadData(true);
    // Make a transaction and tell the peer we have it.
    Coin value = COIN;
    Transaction tx = createFakeTx(PARAMS, value, address);
    InventoryMessage inv = new InventoryMessage(PARAMS);
    InventoryItem item = new InventoryItem(InventoryItem.Type.Transaction, tx.getHash());
    inv.addItem(item);
    inbound(writeTarget, inv);
    // Peer hasn't seen it before, so will ask for it.
    GetDataMessage getdata = (GetDataMessage) outbound(writeTarget);
    assertEquals(1, getdata.getItems().size());
    assertEquals(tx.getHash(), getdata.getItems().get(0).hash);
    inbound(writeTarget, tx);
    // Ask for the dependency, it's not in the mempool (in chain).
    getdata = (GetDataMessage) outbound(writeTarget);
    inbound(writeTarget, new NotFoundMessage(PARAMS, getdata.getItems()));
    pingAndWait(writeTarget);
    assertEquals(value, wallet.getBalance(Wallet.BalanceType.ESTIMATED));
}