mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 14:54:15 +00:00
Wallet: set lookahead size to 5 when using unit test params instead of scattering calls all over the test code.
This commit is contained in:
parent
fc83deb8fd
commit
1e4f930b70
@ -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<Sha256Hash, Transaction>();
|
||||
spent = new HashMap<Sha256Hash, Transaction>();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user