aboutsummaryrefslogtreecommitdiffstats
path: root/state.cpp
diff options
context:
space:
mode:
authorChristoph Jentzsch <jentzsch.software@gmail.com>2014-11-12 05:25:21 +0800
committerChristoph Jentzsch <jentzsch.software@gmail.com>2014-11-12 05:25:21 +0800
commit508b7f14d8639ccf650fc1717c37eefce5d14f09 (patch)
tree45745511b07245b29f6be1120467b59943734d0e /state.cpp
parentd010b15523d0c59d4152ebb1b63ef2b5452abf17 (diff)
downloaddexon-solidity-508b7f14d8639ccf650fc1717c37eefce5d14f09.tar
dexon-solidity-508b7f14d8639ccf650fc1717c37eefce5d14f09.tar.gz
dexon-solidity-508b7f14d8639ccf650fc1717c37eefce5d14f09.tar.bz2
dexon-solidity-508b7f14d8639ccf650fc1717c37eefce5d14f09.tar.lz
dexon-solidity-508b7f14d8639ccf650fc1717c37eefce5d14f09.tar.xz
dexon-solidity-508b7f14d8639ccf650fc1717c37eefce5d14f09.tar.zst
dexon-solidity-508b7f14d8639ccf650fc1717c37eefce5d14f09.zip
Create state test with commandline flag
Diffstat (limited to 'state.cpp')
-rw-r--r--state.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/state.cpp b/state.cpp
index 91d9f3e5..b5b23829 100644
--- a/state.cpp
+++ b/state.cpp
@@ -122,6 +122,40 @@ BOOST_AUTO_TEST_CASE(stPreCompiledContracts)
dev::test::executeTests("stPreCompiledContracts", "/StateTests", dev::test::doStateTests);
}
+BOOST_AUTO_TEST_CASE(stCreateTest)
+{
+ 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 == "--createtest")
+ {
+ if (boost::unit_test::framework::master_test_suite().argc <= i + 2)
+ {
+ cnote << "usage: ./testeth --createtest <PathToConstructor> <PathToDestiny>\n";
+ return;
+ }
+ try
+ {
+ cnote << "Populating tests...";
+ json_spirit::mValue v;
+ string s = asString(dev::contents(boost::unit_test::framework::master_test_suite().argv[i + 1]));
+ BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content of " + (string)boost::unit_test::framework::master_test_suite().argv[i + 1] + " is empty.");
+ json_spirit::read_string(s, v);
+ dev::test::doStateTests(v, true);
+ writeFile(boost::unit_test::framework::master_test_suite().argv[i + 2], asBytes(json_spirit::write_string(v, true)));
+ }
+ catch (Exception const& _e)
+ {
+ BOOST_ERROR("Failed state test with Exception: " << diagnostic_information(_e));
+ }
+ catch (std::exception const& _e)
+ {
+ BOOST_ERROR("Failed state test with Exception: " << _e.what());
+ }
+ }
+ }
+}
+
BOOST_AUTO_TEST_CASE(userDefinedFileState)
{
dev::test::userDefinedTest("--statetest", dev::test::doStateTests);