Merge pull request #1195 from CJentzsch/POC9tests

remove genesis state from state tests
This commit is contained in:
Gav Wood 2015-03-04 11:58:57 +01:00
commit ebd7ac43e0
3 changed files with 41 additions and 36 deletions

View File

@ -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));

View File

@ -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);

View File

@ -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,23 +169,35 @@ 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")
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";
@ -192,15 +205,16 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest)
}
}
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);
}
BOOST_AUTO_TEST_CASE(stSolidityTest)
{
dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests);
}
BOOST_AUTO_TEST_CASE(stCreateTest)
{