3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 18:55:52 +00:00

Wallet: Fix not removing unspent transaction outputs when clearing transactions.

Adds very basic unit test for resetting wallets.
This commit is contained in:
Andreas Schildbach 2015-07-28 20:30:12 +02:00
parent bee75f8d36
commit b7c24c6196
2 changed files with 13 additions and 0 deletions

View File

@ -2590,6 +2590,7 @@ public class Wallet extends BaseTaggableObject implements BlockChainListener, Pe
pending.clear();
dead.clear();
transactions.clear();
myUnspents.clear();
}
/**

View File

@ -3151,4 +3151,16 @@ public class WalletTest extends TestWithWallet {
String seed = wallet.getKeyChainSeed().toHexString();
assertEquals("5ca8cd6c01aa004d3c5396c628b78a4a89462f412f460a845b594ac42eceaa264b0e14dcd4fe73d4ed08ce06f4c28facfa85042d26d784ab2798a870bb7af556", seed);
}
@Test
public void reset() {
sendMoneyToWallet(wallet, COIN, myAddress, AbstractBlockChain.NewBlockType.BEST_CHAIN);
assertNotEquals(Coin.ZERO, wallet.getBalance(Wallet.BalanceType.ESTIMATED));
assertNotEquals(0, wallet.getTransactions(false).size());
assertNotEquals(0, wallet.getUnspents().size());
wallet.reset();
assertEquals(Coin.ZERO, wallet.getBalance(Wallet.BalanceType.ESTIMATED));
assertEquals(0, wallet.getTransactions(false).size());
assertEquals(0, wallet.getUnspents().size());
}
}