Add a getValueSentFromMe() to complement getValueSentToMe() and some unit tests.

BUG=2
This commit is contained in:
Mike Hearn
2011-03-12 17:57:37 +00:00
parent 99d155e0fe
commit 29e60a460d
4 changed files with 73 additions and 15 deletions

View File

@@ -138,4 +138,17 @@ public class WalletTest {
wallet.confirmSend(send2);
assertEquals(bitcoinValueToFriendlyString(wallet.getBalance()), "0.80");
}
@Test
public void testBalances() throws Exception {
BigInteger nanos = Utils.toNanoCoins(1, 0);
Transaction tx1 = createFakeTx(nanos, myAddress);
wallet.receive(tx1);
assertEquals(nanos, tx1.getValueSentToMe(wallet));
// Send 0.10 to somebody else.
Transaction send1 = wallet.createSend(new ECKey().toAddress(params), toNanoCoins(0, 10), myAddress);
// Reserialize.
Transaction send2 = new Transaction(params, send1.bitcoinSerialize());
assertEquals(nanos, send2.getValueSentFromMe(wallet));
}
}