public void BlockChainCatchup()
{
var tx1 = TestUtils.CreateFakeTx(_params, Utils.ToNanoCoins(1, 0), _myAddress);
var b1 = TestUtils.CreateFakeBlock(_params, _blockStore, tx1).StoredBlock;
_wallet.Receive(tx1, b1, BlockChain.NewBlockType.BestChain);
// Send 0.10 to somebody else.
var send1 = _wallet.CreateSend(new EcKey().ToAddress(_params), Utils.ToNanoCoins(0, 10), _myAddress);
// Pretend it makes it into the block chain, our wallet state is cleared but we still have the keys, and we
// want to get back to our previous state. We can do this by just not confirming the transaction as
// createSend is stateless.
var b2 = TestUtils.CreateFakeBlock(_params, _blockStore, send1).StoredBlock;
_wallet.Receive(send1, b2, BlockChain.NewBlockType.BestChain);
Assert.AreEqual(Utils.BitcoinValueToFriendlyString(_wallet.GetBalance()), "0.90");
// And we do it again after the catch-up.
var send2 = _wallet.CreateSend(new EcKey().ToAddress(_params), Utils.ToNanoCoins(0, 10), _myAddress);
// What we'd really like to do is prove the official client would accept it .... no such luck unfortunately.
_wallet.ConfirmSend(send2);
var b3 = TestUtils.CreateFakeBlock(_params, _blockStore, send2).StoredBlock;
_wallet.Receive(send2, b3, BlockChain.NewBlockType.BestChain);
Assert.AreEqual(Utils.BitcoinValueToFriendlyString(_wallet.GetBalance()), "0.80");
}