@Test
public void pledgeImperfectSize() throws Exception {

    // Form a pledge that requires a new output to be created by the wallet (the dependency), so we have a correctly
    // sized stub output.
    WalletTestObjects objects = new WalletTestObjects(() -> new PledgingWallet(UnitTestParams.get()));
    PledgingWallet wallet = (PledgingWallet) objects.wallet;
    objects.sendAmounts(1_000_000, 2_000_000);
    Project project = new Project(makeProject(wallet, 3_000_000));
    PledgingWallet.PendingPledge pledge = wallet.createPledge(project, 2_500_000, null);
    assertNotNull(pledge.dependency);
    assertNotNull(pledge.pledge);
    assertEquals(2, pledge.dependency.getOutputs().size());
    assertTrue(2_500_000 == pledge.dependency.getOutput(0).getValue().longValue() ||
               2_500_000 == pledge.dependency.getOutput(1).getValue().longValue());
    pledge.commit(true);
    // Do a second one. We have a 490k output available.
    PledgingWallet.PendingPledge pledge2 = wallet.createPledge(project, 400_000, null);
    assertNotNull(pledge2.dependency);
    assertNotNull(pledge2.pledge);
    assertEquals(2, pledge2.dependency.getOutputs().size());
    assertTrue(400_000 == pledge2.dependency.getOutput(0).getValue().longValue() ||
               400_000 == pledge2.dependency.getOutput(1).getValue().longValue());
    // Check that the dependency of this pledge spends the change of the prior dependency.
    assertEquals(pledge2.dependency.getInput(0).getOutpoint().getHash(),
            pledge.dependency.getHash());
    pledge2.commit(true);
    System.out.println(roundTrip(wallet));
}