Browse Source

Random test code

cl-refactor
Dimitry 10 years ago
parent
commit
b43c4f1145
  1. 4
      test/TestHelper.cpp
  2. 1
      test/TestHelper.h
  3. 5
      test/fuzzTesting/createRandomStateTest.cpp

4
test/TestHelper.cpp

@ -328,7 +328,7 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost)
{ {
// export output // export output
m_TestObject["out"] = _output.size() > 4096 ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add); m_TestObject["out"] = (_output.size() > 4096 && !Options::get().fulloutput) ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add);
// export logs // export logs
m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries()); m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries());
@ -760,6 +760,8 @@ Options::Options()
else else
singleTestName = std::move(name1); singleTestName = std::move(name1);
} }
else if (arg == "--fulloutput")
fulloutput = true;
} }
} }

1
test/TestHelper.h

@ -184,6 +184,7 @@ public:
bool stats = false; ///< Execution time stats bool stats = false; ///< Execution time stats
std::string statsOutFile; ///< Stats output file. "out" for standard output std::string statsOutFile; ///< Stats output file. "out" for standard output
bool checkState = false;///< Throw error when checking test states bool checkState = false;///< Throw error when checking test states
bool fulloutput = false;///< Replace large output to just it's length
/// Test selection /// Test selection
/// @{ /// @{

5
test/fuzzTesting/createRandomStateTest.cpp

@ -173,7 +173,8 @@ void doRandomCodeAlgo()
dev::test::RandomCodeOptions options; dev::test::RandomCodeOptions options;
options.setWeight(dev::eth::Instruction::STOP, 10); //default 50 options.setWeight(dev::eth::Instruction::STOP, 10); //default 50
options.setWeight(dev::eth::Instruction::SSTORE, 70); options.setWeight(dev::eth::Instruction::SSTORE, 70);
string randomCode = dev::test::RandomCode::generate(15); string randomCode = dev::test::RandomCode::generate(10);
string randomData = dev::test::RandomCode::generate(10);
mValue v; mValue v;
read_string(c_testExample, v); read_string(c_testExample, v);
@ -182,7 +183,7 @@ void doRandomCodeAlgo()
v.get_obj().find("randomStatetest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode; v.get_obj().find("randomStatetest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode;
// insert new data in tx // insert new data in tx
v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["data"] = "0x" + randomCode; v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["data"] = "0x" + randomData;
// insert new value in tx // insert new value in tx
v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["value"] = dev::test::RandomCode::randomUniInt(); v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["value"] = dev::test::RandomCode::randomUniInt();

Loading…
Cancel
Save