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
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
m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries());
@ -760,6 +760,8 @@ Options::Options()
else
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
std::string statsOutFile; ///< Stats output file. "out" for standard output
bool checkState = false;///< Throw error when checking test states
bool fulloutput = false;///< Replace large output to just it's length
/// Test selection
/// @{

5
test/fuzzTesting/createRandomStateTest.cpp

@ -173,7 +173,8 @@ void doRandomCodeAlgo()
dev::test::RandomCodeOptions options;
options.setWeight(dev::eth::Instruction::STOP, 10); //default 50
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;
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;
// 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
v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["value"] = dev::test::RandomCode::randomUniInt();

Loading…
Cancel
Save