From 1dadb33c2895c6c5fe4af160570f477110bebf8e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 24 Apr 2013 11:48:18 -0400 Subject: [PATCH] Split expensive blocks into sigExpensive and largeReorg. --- .../com/google/bitcoin/core/BitcoindComparisonTool.java | 6 ++++-- .../com/google/bitcoin/core/FullBlockTestGenerator.java | 6 +++--- .../com/google/bitcoin/core/FullPrunedBlockChainTest.java | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/test/java/com/google/bitcoin/core/BitcoindComparisonTool.java b/core/src/test/java/com/google/bitcoin/core/BitcoindComparisonTool.java index 08902a3e..c2e32529 100644 --- a/core/src/test/java/com/google/bitcoin/core/BitcoindComparisonTool.java +++ b/core/src/test/java/com/google/bitcoin/core/BitcoindComparisonTool.java @@ -45,6 +45,8 @@ public class BitcoindComparisonTool { public static void main(String[] args) throws Exception { BriefLogFormatter.init(); + System.out.println("USAGE: runLargeReorgs(1/0)"); + boolean runLargeReorgs = Integer.parseInt(args[0]) == 1; params = NetworkParameters.testNet2(); /** @@ -53,7 +55,7 @@ public class BitcoindComparisonTool { * You can also opt to comment out these lines to use the default, however that will cause this tool to be * very significantly less efficient and useful (it will likely run forever trying to mine new blocks). * - * You could also simply use git apply to apply the "bitcoind-comparison.patch" file included with bitcoinj + * You could also simply use git apply to apply the test-patches included with bitcoind */ // bnProofOfWorkLimit set in main.cpp @@ -69,7 +71,7 @@ public class BitcoindComparisonTool { // Also set block.nTime = 1296688602; in the same block FullBlockTestGenerator generator = new FullBlockTestGenerator(params); - BlockAndValidityList blockList = generator.getBlocksToTest(true); + BlockAndValidityList blockList = generator.getBlocksToTest(true, runLargeReorgs); // Only needs to be set in bitcoinj params.allowEmptyPeerChains = true; diff --git a/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java b/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java index 18f39947..bf245d60 100644 --- a/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java +++ b/core/src/test/java/com/google/bitcoin/core/FullBlockTestGenerator.java @@ -75,7 +75,7 @@ public class FullBlockTestGenerator { Utils.rollMockClock(0); // Set a mock clock for timestamp tests } - public BlockAndValidityList getBlocksToTest(boolean addExpensiveBlocks) throws ScriptException, ProtocolException, IOException { + public BlockAndValidityList getBlocksToTest(boolean addSigExpensiveBlocks, boolean runLargeReorgs) throws ScriptException, ProtocolException, IOException { List blocks = new LinkedList(); BlockAndValidityList ret = new BlockAndValidityList(blocks, 10); @@ -730,7 +730,7 @@ public class FullBlockTestGenerator { blocks.add(new BlockAndValidity(blockToHeightMap, b40, false, true, b39.getHash(), chainHeadHeight + 12, "b40")); Block b41 = null; - if (addExpensiveBlocks) { + if (addSigExpensiveBlocks) { b41 = createNextBlock(b39, chainHeadHeight + 13, out12, null); { int sigOps = 0; @@ -1304,7 +1304,7 @@ public class FullBlockTestGenerator { b73.getTransactions().get(0).getOutputs().get(0).getValue(), b73.getTransactions().get(0).getOutputs().get(0).getScriptPubKey())); - if (addExpensiveBlocks) { + if (runLargeReorgs) { Block lastBlock = b73; int nextHeight = chainHeadHeight + 24; TransactionOutPoint lastOutput = new TransactionOutPoint(params, 2, b73.getTransactions().get(1).getHash()); diff --git a/core/src/test/java/com/google/bitcoin/core/FullPrunedBlockChainTest.java b/core/src/test/java/com/google/bitcoin/core/FullPrunedBlockChainTest.java index 8c0972cb..2c319400 100644 --- a/core/src/test/java/com/google/bitcoin/core/FullPrunedBlockChainTest.java +++ b/core/src/test/java/com/google/bitcoin/core/FullPrunedBlockChainTest.java @@ -65,7 +65,7 @@ public class FullPrunedBlockChainTest { public void testGeneratedChain() throws Exception { // Tests various test cases from FullBlockTestGenerator FullBlockTestGenerator generator = new FullBlockTestGenerator(unitTestParams); - BlockAndValidityList blockList = generator.getBlocksToTest(false); + BlockAndValidityList blockList = generator.getBlocksToTest(false, false); store = new MemoryFullPrunedBlockStore(unitTestParams, blockList.maximumReorgBlockCount); chain = new FullPrunedBlockChain(unitTestParams, store);