From 98bee183b6ba17086a5b9a35b5e21e89d56e2d58 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 24 Mar 2016 19:58:06 +0100 Subject: [PATCH] WalletTest: Remove paranoid test preconditions. --- .../test/java/org/bitcoinj/core/WalletTest.java | 16 +--------------- .../org/bitcoinj/testing/TestWithWallet.java | 8 +++----- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/core/src/test/java/org/bitcoinj/core/WalletTest.java b/core/src/test/java/org/bitcoinj/core/WalletTest.java index d0f608d5..e73d34be 100644 --- a/core/src/test/java/org/bitcoinj/core/WalletTest.java +++ b/core/src/test/java/org/bitcoinj/core/WalletTest.java @@ -80,8 +80,7 @@ public class WalletTest extends TestWithWallet { private SecureRandom secureRandom = new SecureRandom(); - private final ECKey OTHER_KEY = new ECKey(); - private final Address OTHER_ADDRESS = OTHER_KEY.toAddress(PARAMS); + private final Address OTHER_ADDRESS = new ECKey().toAddress(PARAMS); @Before @Override @@ -2272,9 +2271,6 @@ public class WalletTest extends TestWithWallet { @Test public void feeSolverAndCoinSelectionTest_dustySendRequested() throws Exception { - // Make sure TestWithWallet isnt doing anything crazy. - assertEquals(0, wallet.getTransactions(true).size()); - // Generate a few outputs to us that are far too small to spend reasonably StoredBlock block = new StoredBlock(makeSolvedTestBlock(blockStore, OTHER_ADDRESS), BigInteger.ONE, 1); Transaction tx1 = createFakeTx(PARAMS, SATOSHI, myAddress); @@ -2700,8 +2696,6 @@ public class WalletTest extends TestWithWallet { @Test public void basicCategoryStepTest() throws Exception { // Creates spends that step through the possible fee solver categories - // Make sure TestWithWallet isnt doing anything crazy. - assertEquals(0, wallet.getTransactions(true).size()); // Generate a ton of small outputs StoredBlock block = new StoredBlock(makeSolvedTestBlock(blockStore, OTHER_ADDRESS), BigInteger.ONE, 1); @@ -2785,9 +2779,6 @@ public class WalletTest extends TestWithWallet { public void testCategory2WithChange() throws Exception { // Specifically target case 2 with significant change - // Make sure TestWithWallet isnt doing anything crazy. - assertEquals(0, wallet.getTransactions(true).size()); - // Generate a ton of small outputs StoredBlock block = new StoredBlock(makeSolvedTestBlock(blockStore, OTHER_ADDRESS), BigInteger.ONE, 1); int i = 0; @@ -2861,9 +2852,6 @@ public class WalletTest extends TestWithWallet { public void feePerKbCategoryJumpTest() throws Exception { // Simple test of boundary condition on fee per kb in category fee solver - // Make sure TestWithWallet isnt doing anything crazy. - assertEquals(0, wallet.getTransactions(true).size()); - // Generate a ton of small outputs StoredBlock block = new StoredBlock(makeSolvedTestBlock(blockStore, OTHER_ADDRESS), BigInteger.ONE, 1); Transaction tx = createFakeTx(PARAMS, COIN, myAddress); @@ -2908,8 +2896,6 @@ public class WalletTest extends TestWithWallet { @Test public void testCompleteTxWithExistingInputs() throws Exception { // Tests calling completeTx with a SendRequest that already has a few inputs in it - // Make sure TestWithWallet isnt doing anything crazy. - assertEquals(0, wallet.getTransactions(true).size()); // Generate a few outputs to us StoredBlock block = new StoredBlock(makeSolvedTestBlock(blockStore, OTHER_ADDRESS), BigInteger.ONE, 1); diff --git a/core/src/test/java/org/bitcoinj/testing/TestWithWallet.java b/core/src/test/java/org/bitcoinj/testing/TestWithWallet.java index 3072f4f4..50c5c267 100644 --- a/core/src/test/java/org/bitcoinj/testing/TestWithWallet.java +++ b/core/src/test/java/org/bitcoinj/testing/TestWithWallet.java @@ -30,12 +30,10 @@ import static org.bitcoinj.testing.FakeTxBuilder.createFakeTx; // TODO: This needs to be somewhat rewritten - the "sendMoneyToWallet" methods aren't sending via the block chain object /** - * A utility class that you can derive from in your unit tests. TestWithWallet sets up a wallet with a key, - * an in memory block store and a block chain object. It also provides helper methods for filling the wallet + * A utility class that you can derive from in your unit tests. TestWithWallet sets up an empty wallet, + * an in-memory block store and a block chain object. It also provides helper methods for filling the wallet * with money in whatever ways you wish. Note that for simplicity with amounts, this class sets the default - * fee per kilobyte to zero in setUp and back to normal in tearDown. If you are wanting to test your behaviour - * with fees (a good idea!) make sure you set the {@link Wallet.SendRequest#DEFAULT_FEE_PER_KB} value to - * {@link Transaction#REFERENCE_DEFAULT_MIN_TX_FEE} before doing so. + * fee per kilobyte to zero in setUp. */ public class TestWithWallet { protected static final NetworkParameters PARAMS = UnitTestParams.get();