public void Bounce()
{
// This test covers bug 64 (False double spends). Check that if we create a spend and it's immediately sent
// back to us, this isn't considered as a double spend.
var coin1 = Utils.ToNanoCoins(1, 0);
var coinHalf = Utils.ToNanoCoins(0, 50);
// Start by giving us 1 coin.
var inbound1 = TestUtils.CreateFakeTx(_params, coin1, _myAddress);
_wallet.Receive(inbound1, null, BlockChain.NewBlockType.BestChain);
// Send half to some other guy. Sending only half then waiting for a confirm is important to ensure the tx is
// in the unspent pool, not pending or spent.
Assert.AreEqual(1, _wallet.GetPoolSize(Wallet.Pool.Unspent));
Assert.AreEqual(1, _wallet.GetPoolSize(Wallet.Pool.All));
var someOtherGuy = new EcKey().ToAddress(_params);
var outbound1 = _wallet.CreateSend(someOtherGuy, coinHalf);
_wallet.ConfirmSend(outbound1);
_wallet.Receive(outbound1, null, BlockChain.NewBlockType.BestChain);
// That other guy gives us the coins right back.
var inbound2 = new Transaction(_params);
inbound2.AddOutput(new TransactionOutput(_params, inbound2, coinHalf, _myAddress));
inbound2.AddInput(outbound1.Outputs[0]);
_wallet.Receive(inbound2, null, BlockChain.NewBlockType.BestChain);
Assert.AreEqual(coin1, _wallet.GetBalance());
}