aboutsummaryrefslogtreecommitdiffstats
path: root/blockchain.cpp
diff options
context:
space:
mode:
authorCJentzsch <jentzsch.software@gmail.com>2015-03-04 07:24:06 +0800
committerGav Wood <i@gavwood.com>2015-03-06 19:19:44 +0800
commitfb81df79d1a4d316409f2a5152edbf96ed048347 (patch)
tree2129f181b854afe53ae8f5057058adfc300bf9e6 /blockchain.cpp
parent784e8410288f85ca8998ab892fdf166397adace1 (diff)
downloaddexon-solidity-fb81df79d1a4d316409f2a5152edbf96ed048347.tar.gz
dexon-solidity-fb81df79d1a4d316409f2a5152edbf96ed048347.tar.zst
dexon-solidity-fb81df79d1a4d316409f2a5152edbf96ed048347.zip
more block tests + bugfix for longer chains
Diffstat (limited to 'blockchain.cpp')
-rw-r--r--blockchain.cpp45
1 files changed, 15 insertions, 30 deletions
diff --git a/blockchain.cpp b/blockchain.cpp
index 7dad5b4f..69ea8fa2 100644
--- a/blockchain.cpp
+++ b/blockchain.cpp
@@ -81,7 +81,7 @@ bytes createBlockRLPFromFields(mObject& _tObj)
return rlpStream.out();
}
-void doBlockTests(json_spirit::mValue& _v, bool _fillin)
+void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
{
for (auto& i: _v.get_obj())
{
@@ -271,7 +271,6 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin)
if (tmp != current_BlockHeader)
{
current_BlockHeader = tmp;
- cout << "new header!\n";
ProofOfWork pow;
MineInfo ret;
while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty))
@@ -343,14 +342,9 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin)
try
{
- ImportTest importerTmp(o["pre"].get_obj());
- State stateTmp(Address(), OverlayDB(), BaseState::Empty);
- importerTmp.importState(o["pre"].get_obj(), stateTmp);
- stateTmp.commit();
- BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true);
- stateTmp.sync(bcTmp);
- bc.import(block2.out(), stateTmp.db());
- stateTmp.sync(bcTmp);
+ state.sync(bc);
+ bc.import(block2.out(), state.db());
+ state.sync(bc);
}
// if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given
catch (...)
@@ -505,32 +499,23 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests)
BOOST_AUTO_TEST_CASE(bcBlockChainTest)
{
- dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests);
+ dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests);
}
-//BOOST_AUTO_TEST_CASE(blValidBlockTest)
-//{
-// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests);
-//}
-
-//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP)
-//{
-// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests);
-//}
+BOOST_AUTO_TEST_CASE(bcValidBlockTest)
+{
+ dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests);
+}
-//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest)
-//{
-// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests);
-//}
+BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest)
+{
+ dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests);
+}
-//BOOST_AUTO_TEST_CASE(blForkBlocks)
-//{
-// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests);
-//}
-BOOST_AUTO_TEST_CASE(userDefinedFileBl)
+BOOST_AUTO_TEST_CASE(userDefinedFileBc)
{
- dev::test::userDefinedTest("--bltest", dev::test::doBlockTests);
+ dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests);
}
BOOST_AUTO_TEST_SUITE_END()