diff options
author | Gav Wood <g@ethdev.com> | 2015-01-14 18:52:00 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-01-14 18:52:00 +0800 |
commit | e2efcfb8a647cc1fc52cce757db0714958b328fd (patch) | |
tree | b9bcffa1ab6a3afeda5fc4609aac38503c2faaf2 /createRandomTest.cpp | |
parent | cf6641c345074c7e3e7cc582726891f774e2996a (diff) | |
parent | 69bd72c6670a2fd3b5268e4ae9ca426b823b738e (diff) | |
download | dexon-solidity-e2efcfb8a647cc1fc52cce757db0714958b328fd.tar.gz dexon-solidity-e2efcfb8a647cc1fc52cce757db0714958b328fd.tar.zst dexon-solidity-e2efcfb8a647cc1fc52cce757db0714958b328fd.zip |
Merge pull request #796 from CJentzsch/randomTestEfficiency
Random test efficiency
Diffstat (limited to 'createRandomTest.cpp')
-rw-r--r-- | createRandomTest.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/createRandomTest.cpp b/createRandomTest.cpp index b3700fd0..fa5ed7bd 100644 --- a/createRandomTest.cpp +++ b/createRandomTest.cpp @@ -54,18 +54,26 @@ int main(int argc, char *argv[]) gen.seed(static_cast<unsigned int>(timeSinceEpoch)); boost::random::uniform_int_distribution<> lengthOfCodeDist(2, 16); boost::random::uniform_int_distribution<> opcodeDist(0, 255); + boost::random::uniform_int_distribution<> BlockInfoOpcodeDist(0x40, 0x45); boost::random::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> > randGen(gen, opcodeDist); + boost::random::variate_generator<boost::mt19937&, + boost::random::uniform_int_distribution<> > randGenBlockInfoOpcode(gen, BlockInfoOpcodeDist); int lengthOfCode = lengthOfCodeDist(gen); string randomCode; for (int i = 0; i < lengthOfCode; ++i) { - uint8_t opcode = randGen(); + if (i < 8 && (randGen() < 192)) + { + randomCode += toHex(toCompactBigEndian((uint8_t)randGenBlockInfoOpcode())); + continue; + } - // disregard all invalid commands, except of one (0x10) - if (dev::eth::isValidInstruction(dev::eth::Instruction(opcode)) || opcode == 0x10) + uint8_t opcode = randGen(); + // disregard all invalid commands, except of one (0x0c) + if ((dev::eth::isValidInstruction(dev::eth::Instruction(opcode)) || (randGen() > 250))) randomCode += toHex(toCompactBigEndian(opcode)); else i--; @@ -76,10 +84,10 @@ int main(int argc, char *argv[]) \"randomVMtest\": {\n\ \"env\" : {\n\ \"previousHash\" : \"5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6\",\n\ - \"currentNumber\" : \"0\",\n\ + \"currentNumber\" : \"300\",\n\ \"currentGasLimit\" : \"1000000\",\n\ - \"currentDifficulty\" : \"256\",\n\ - \"currentTimestamp\" : 1,\n\ + \"currentDifficulty\" : \"115792089237316195423570985008687907853269984665640564039457584007913129639935\",\n\ + \"currentTimestamp\" : 2,\n\ \"currentCoinbase\" : \"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba\"\n\ },\n\ \"pre\" : {\n\ @@ -106,7 +114,7 @@ int main(int argc, char *argv[]) read_string(s, v); // insert new random code - v.get_obj().find("randomVMtest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode; + v.get_obj().find("randomVMtest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode + (randGen() > 128 ? "55" : ""); // execute code in vm doMyTests(v); |