diff options
author | Gav Wood <g@ethdev.com> | 2015-03-04 18:58:57 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-03-04 18:58:57 +0800 |
commit | ebd7ac43e06b282ec0b32894b7bff3db25760c96 (patch) | |
tree | dd09dca552a44141800184a3ff1529f22f9ee939 | |
parent | 366b9e8b712453bb1c6b34ba6a8d155fa6733952 (diff) | |
parent | a35c9d8e3529fd66cf714105ad6e5f4eacae9c12 (diff) | |
download | dexon-solidity-ebd7ac43e06b282ec0b32894b7bff3db25760c96.tar.gz dexon-solidity-ebd7ac43e06b282ec0b32894b7bff3db25760c96.tar.zst dexon-solidity-ebd7ac43e06b282ec0b32894b7bff3db25760c96.zip |
Merge pull request #1195 from CJentzsch/POC9tests
remove genesis state from state tests
-rw-r--r-- | TestHelper.cpp | 10 | ||||
-rw-r--r-- | TestHelper.h | 3 | ||||
-rw-r--r-- | state.cpp | 64 |
3 files changed, 41 insertions, 36 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp index 1d544304..6d5a91cd 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<Address, Account> 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 c4dde1a6..75edcbf3 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); @@ -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<chrono::milliseconds>(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<chrono::milliseconds>(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<chrono::milliseconds>(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<chrono::milliseconds>(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) { |