diff --git a/TestHelper.cpp b/TestHelper.cpp index 1d544304c..6d5a91cdd 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -67,7 +67,7 @@ namespace test struct ValueTooLarge: virtual Exception {}; bigint const c_max256plus1 = bigint(1) << 256; -ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o) +ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller) : m_statePre(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) { importEnv(_o["env"].get_obj()); importState(_o["pre"].get_obj(), m_statePre); @@ -181,13 +181,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost) // export post state json_spirit::mObject postState; - std::map genesis = genesisState(); - for (auto const& a: _statePost.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(_statePost.balance(a.first)); o["nonce"] = toString(_statePost.transactionsFrom(a.first)); @@ -210,9 +205,6 @@ void ImportTest::exportTest(bytes _output, State& _statePost) for (auto const& a: m_statePre.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(m_statePre.balance(a.first)); o["nonce"] = toString(m_statePre.transactionsFrom(a.first)); diff --git a/TestHelper.h b/TestHelper.h index c4dde1a60..75edcbf31 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -45,9 +45,8 @@ namespace test class ImportTest { public: - ImportTest(json_spirit::mObject& _o) : m_TestObject(_o) {} + ImportTest(json_spirit::mObject& _o) : m_statePre(Address(), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) {} ImportTest(json_spirit::mObject& _o, bool isFiller); - // imports void importEnv(json_spirit::mObject& _o); void importState(json_spirit::mObject& _o, eth::State& _state); diff --git a/state.cpp b/state.cpp index 7649dae61..8db082d0c 100644 --- a/state.cpp +++ b/state.cpp @@ -64,6 +64,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) catch (Exception const& _e) { cnote << "state execution did throw an exception: " << diagnostic_information(_e); + theState.commit(); } catch (std::exception const& _e) { @@ -168,39 +169,52 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } +//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--quadratic" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); + +// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} + BOOST_AUTO_TEST_CASE(stMemoryStressTest) { - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - else if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } + BOOST_AUTO_TEST_CASE(stMemoryTest) { - dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stSolidityTest) -{ - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); -} BOOST_AUTO_TEST_CASE(stCreateTest) {