diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index c1cb7f26..af9c37a9 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -222,6 +222,8 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha public Wallet(NetworkParameters params, KeyChainGroup keyChainGroup) { this.params = checkNotNull(params); this.keychain = checkNotNull(keyChainGroup); + if (params == UnitTestParams.get()) + this.keychain.setLookaheadSize(5); // Cut down excess computation for unit tests. watchedScripts = Sets.newHashSet(); unspent = new HashMap(); spent = new HashMap(); diff --git a/core/src/main/java/com/google/bitcoin/testing/TestWithNetworkConnections.java b/core/src/main/java/com/google/bitcoin/testing/TestWithNetworkConnections.java index 840708ff..b0b99f83 100644 --- a/core/src/main/java/com/google/bitcoin/testing/TestWithNetworkConnections.java +++ b/core/src/main/java/com/google/bitcoin/testing/TestWithNetworkConnections.java @@ -85,7 +85,6 @@ public class TestWithNetworkConnections { Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO; this.blockStore = blockStore; wallet = new Wallet(unitTestParams); - wallet.setKeychainLookaheadSize(5); // Make tests faster by reducing the number of keys derived ahead of time. key = wallet.freshReceiveKey(); address = key.toAddress(unitTestParams); blockChain = new BlockChain(unitTestParams, wallet, blockStore); diff --git a/core/src/main/java/com/google/bitcoin/testing/TestWithWallet.java b/core/src/main/java/com/google/bitcoin/testing/TestWithWallet.java index 0da93cb0..ad784ac6 100644 --- a/core/src/main/java/com/google/bitcoin/testing/TestWithWallet.java +++ b/core/src/main/java/com/google/bitcoin/testing/TestWithWallet.java @@ -20,7 +20,6 @@ import com.google.bitcoin.core.*; import com.google.bitcoin.params.UnitTestParams; import com.google.bitcoin.store.BlockStore; import com.google.bitcoin.store.MemoryBlockStore; -import com.google.bitcoin.testing.FakeTxBuilder; import com.google.bitcoin.utils.BriefLogFormatter; import javax.annotation.Nullable; @@ -52,7 +51,6 @@ public class TestWithWallet { BriefLogFormatter.init(); Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO; wallet = new Wallet(params); - wallet.setKeychainLookaheadSize(5); myKey = wallet.currentReceiveKey(); myAddress = myKey.toAddress(params); blockStore = new MemoryBlockStore(params); diff --git a/core/src/test/java/com/google/bitcoin/core/ChainSplitTest.java b/core/src/test/java/com/google/bitcoin/core/ChainSplitTest.java index d6554090..28a0d2a1 100644 --- a/core/src/test/java/com/google/bitcoin/core/ChainSplitTest.java +++ b/core/src/test/java/com/google/bitcoin/core/ChainSplitTest.java @@ -56,7 +56,6 @@ public class ChainSplitTest { Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO; unitTestParams = UnitTestParams.get(); wallet = new Wallet(unitTestParams); - wallet.setKeychainLookaheadSize(5); // Make tests faster. ECKey key1 = wallet.freshReceiveKey(); ECKey key2 = wallet.freshReceiveKey(); blockStore = new MemoryBlockStore(unitTestParams); diff --git a/core/src/test/java/com/google/bitcoin/core/WalletTest.java b/core/src/test/java/com/google/bitcoin/core/WalletTest.java index 6e342da3..2bb87b83 100644 --- a/core/src/test/java/com/google/bitcoin/core/WalletTest.java +++ b/core/src/test/java/com/google/bitcoin/core/WalletTest.java @@ -81,7 +81,6 @@ public class WalletTest extends TestWithWallet { public void setUp() throws Exception { super.setUp(); encryptedWallet = new Wallet(params); - encryptedWallet.setKeychainLookaheadSize(5); // For speed. myEncryptedAddress = encryptedWallet.freshReceiveKey().toAddress(params); encryptedWallet.encrypt(PASSWORD1); keyCrypter = encryptedWallet.getKeyCrypter(); @@ -990,7 +989,6 @@ public class WalletTest extends TestWithWallet { @Test public void keyCreationTime() throws Exception { wallet = new Wallet(params); - wallet.setKeychainLookaheadSize(5); // For speed. Utils.setMockClock(); long now = Utils.currentTimeSeconds(); // No keys returns current time. @@ -1006,7 +1004,6 @@ public class WalletTest extends TestWithWallet { @Test public void scriptCreationTime() throws Exception { wallet = new Wallet(params); - wallet.setKeychainLookaheadSize(5); // For speed. Utils.setMockClock(); long now = Utils.currentTimeSeconds(); // No keys returns current time. @@ -2373,7 +2370,6 @@ public class WalletTest extends TestWithWallet { keys.addAll(k); } }, Threading.SAME_THREAD); - wallet.setKeychainLookaheadSize(5); wallet.freshReceiveKey(); assertEquals(6, keys.size()); } diff --git a/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java b/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java index 0a939dd3..29f0a51a 100644 --- a/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java +++ b/core/src/test/java/com/google/bitcoin/protocols/channels/ChannelConnectionTest.java @@ -69,7 +69,6 @@ public class ChannelConnectionTest extends TestWithWallet { sendMoneyToWallet(Utils.COIN, AbstractBlockChain.NewBlockType.BEST_CHAIN); wallet.addExtension(new StoredPaymentChannelClientStates(wallet, failBroadcaster)); serverWallet = new Wallet(params); - serverWallet.setKeychainLookaheadSize(5); serverWallet.addExtension(new StoredPaymentChannelServerStates(serverWallet, failBroadcaster)); serverWallet.freshReceiveKey(); serverChain = new BlockChain(params, serverWallet, blockStore); @@ -544,7 +543,6 @@ public class ChannelConnectionTest extends TestWithWallet { @Test public void testEmptyWallet() throws Exception { Wallet emptyWallet = new Wallet(params); - emptyWallet.setKeychainLookaheadSize(5); emptyWallet.freshReceiveKey(); ChannelTestUtils.RecordingPair pair = ChannelTestUtils.makeRecorders(serverWallet, mockBroadcaster); PaymentChannelServer server = pair.server;