From 8162aa0ed11b69d90269d4318323eb99ba347641 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Thu, 6 Sep 2012 12:37:00 +0200 Subject: [PATCH] Use current time as unit test chain genesis block time. Resolves a weird issue where the unit tests suddenly broke as the previous unit test genesis time was equal to testnet genesis time. --- .../main/java/com/google/bitcoin/core/NetworkParameters.java | 3 ++- core/src/test/java/com/google/bitcoin/core/BlockChainTest.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java b/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java index db28496b..e8accf5d 100644 --- a/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java +++ b/core/src/main/java/com/google/bitcoin/core/NetworkParameters.java @@ -200,8 +200,9 @@ public class NetworkParameters implements Serializable { NetworkParameters n = new NetworkParameters(); n = createTestNet(n); n.proofOfWorkLimit = new BigInteger("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16); - n.genesisBlock.setNonce(2); // Make this pass the difficulty test + n.genesisBlock.setTime(System.currentTimeMillis() / 1000); n.genesisBlock.setDifficultyTarget(Block.EASIEST_DIFFICULTY_TARGET); + n.genesisBlock.solve(); n.interval = 10; n.targetTimespan = 200000000; // 6 years. Just a very big number. n.setSpendableCoinbaseDepth(5); 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 afe38492..308c332a 100644 --- a/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java +++ b/core/src/test/java/com/google/bitcoin/core/BlockChainTest.java @@ -164,7 +164,7 @@ public class BlockChainTest { } // Now add another block that has no difficulty adjustment, it should be rejected. try { - chain.add(prev.createNextBlock(coinbaseTo)); + chain.add(prev.createNextBlock(coinbaseTo, Block.fakeClock)); fail(); } catch (VerificationException e) { }