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:46:23 +0800
commit3e88362dff2ad0b5c190361995a26b7f5bb3b346 (patch)
treed3aa300795c03b670421605ce2783299a0443fcd /blockchain.cpp
parent298919844b3f6548e200637a0446a4bbd0251b75 (diff)
downloaddexon-solidity-3e88362dff2ad0b5c190361995a26b7f5bb3b346.tar.gz
dexon-solidity-3e88362dff2ad0b5c190361995a26b7f5bb3b346.tar.zst
dexon-solidity-3e88362dff2ad0b5c190361995a26b7f5bb3b346.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()