diff --git a/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java b/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java index 6190ae18..5e14e76b 100644 --- a/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java +++ b/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java @@ -183,8 +183,7 @@ public class BlockChainTest { assertTrue(testNetChain.add(getBlock1())); Block b2 = getBlock2(); assertTrue(testNetChain.add(b2)); - NetworkParameters params2 = NetworkParameters.testNet(); - Block bad = new Block(params2); + Block bad = new Block(testNet); // Merkle root can be anything here, doesn't matter. bad.setMerkleRoot(new Sha256Hash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); // Nonce was just some number that made the hash < difficulty limit set below, it can be anything. @@ -205,7 +204,8 @@ public class BlockChainTest { } // Accept any level of difficulty now. - params2.proofOfWorkLimit = new BigInteger + BigInteger oldVal = testNet.proofOfWorkLimit; + testNet.proofOfWorkLimit = new BigInteger ("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16); try { testNetChain.add(bad); @@ -214,6 +214,7 @@ public class BlockChainTest { } catch (VerificationException e) { assertTrue(e.getMessage(), e.getCause().getMessage().indexOf("Unexpected change in difficulty") >= 0); } + testNet.proofOfWorkLimit = oldVal; // TODO: Test difficulty change is not out of range when a transition period becomes valid. } 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 1ddcec9b..33ef4ef4 100644 --- a/core/src/test/java/com/google/bitcoin/core/FullPrunedBlockChainTest.java +++ b/core/src/test/java/com/google/bitcoin/core/FullPrunedBlockChainTest.java @@ -21,6 +21,7 @@ import com.google.bitcoin.core.Transaction.SigHash; import com.google.bitcoin.store.FullPrunedBlockStore; import com.google.bitcoin.store.MemoryFullPrunedBlockStore; import com.google.bitcoin.utils.BriefLogFormatter; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; @@ -48,15 +49,23 @@ public class FullPrunedBlockChainTest { private FullPrunedBlockChain chain; private FullPrunedBlockStore store; + private int oldInterval; + @Before public void setUp() throws Exception { BriefLogFormatter.init(); unitTestParams = NetworkParameters.unitTests(); + oldInterval = unitTestParams.interval; unitTestParams.interval = 10000; store = new MemoryFullPrunedBlockStore(unitTestParams, UNDOABLE_BLOCKS_STORED); chain = new FullPrunedBlockChain(unitTestParams, store); } + + @After + public void tearDown() { + unitTestParams.interval = oldInterval; + } @Test public void testGeneratedChain() throws Exception {