mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 02:35:52 +00:00
Fix a couple of ordering issues with the unit tests.
This commit is contained in:
parent
34f3d8b088
commit
018dcd345c
@ -183,8 +183,7 @@ public class BlockChainTest {
|
|||||||
assertTrue(testNetChain.add(getBlock1()));
|
assertTrue(testNetChain.add(getBlock1()));
|
||||||
Block b2 = getBlock2();
|
Block b2 = getBlock2();
|
||||||
assertTrue(testNetChain.add(b2));
|
assertTrue(testNetChain.add(b2));
|
||||||
NetworkParameters params2 = NetworkParameters.testNet();
|
Block bad = new Block(testNet);
|
||||||
Block bad = new Block(params2);
|
|
||||||
// Merkle root can be anything here, doesn't matter.
|
// Merkle root can be anything here, doesn't matter.
|
||||||
bad.setMerkleRoot(new Sha256Hash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
|
bad.setMerkleRoot(new Sha256Hash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
|
||||||
// Nonce was just some number that made the hash < difficulty limit set below, it can be anything.
|
// 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.
|
// Accept any level of difficulty now.
|
||||||
params2.proofOfWorkLimit = new BigInteger
|
BigInteger oldVal = testNet.proofOfWorkLimit;
|
||||||
|
testNet.proofOfWorkLimit = new BigInteger
|
||||||
("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16);
|
("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16);
|
||||||
try {
|
try {
|
||||||
testNetChain.add(bad);
|
testNetChain.add(bad);
|
||||||
@ -214,6 +214,7 @@ public class BlockChainTest {
|
|||||||
} catch (VerificationException e) {
|
} catch (VerificationException e) {
|
||||||
assertTrue(e.getMessage(), e.getCause().getMessage().indexOf("Unexpected change in difficulty") >= 0);
|
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.
|
// TODO: Test difficulty change is not out of range when a transition period becomes valid.
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.google.bitcoin.core.Transaction.SigHash;
|
|||||||
import com.google.bitcoin.store.FullPrunedBlockStore;
|
import com.google.bitcoin.store.FullPrunedBlockStore;
|
||||||
import com.google.bitcoin.store.MemoryFullPrunedBlockStore;
|
import com.google.bitcoin.store.MemoryFullPrunedBlockStore;
|
||||||
import com.google.bitcoin.utils.BriefLogFormatter;
|
import com.google.bitcoin.utils.BriefLogFormatter;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -48,16 +49,24 @@ public class FullPrunedBlockChainTest {
|
|||||||
private FullPrunedBlockChain chain;
|
private FullPrunedBlockChain chain;
|
||||||
private FullPrunedBlockStore store;
|
private FullPrunedBlockStore store;
|
||||||
|
|
||||||
|
private int oldInterval;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
BriefLogFormatter.init();
|
BriefLogFormatter.init();
|
||||||
unitTestParams = NetworkParameters.unitTests();
|
unitTestParams = NetworkParameters.unitTests();
|
||||||
|
oldInterval = unitTestParams.interval;
|
||||||
unitTestParams.interval = 10000;
|
unitTestParams.interval = 10000;
|
||||||
|
|
||||||
store = new MemoryFullPrunedBlockStore(unitTestParams, UNDOABLE_BLOCKS_STORED);
|
store = new MemoryFullPrunedBlockStore(unitTestParams, UNDOABLE_BLOCKS_STORED);
|
||||||
chain = new FullPrunedBlockChain(unitTestParams, store);
|
chain = new FullPrunedBlockChain(unitTestParams, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
unitTestParams.interval = oldInterval;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGeneratedChain() throws Exception {
|
public void testGeneratedChain() throws Exception {
|
||||||
// Tests various test cases from FullBlockTestGenerator
|
// Tests various test cases from FullBlockTestGenerator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user