Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

Conflicts:
	mix/MixClient.cpp
This commit is contained in:
Gav Wood 2015-03-18 22:12:17 +01:00
commit 5bac44337d
6 changed files with 42 additions and 8 deletions

View File

@ -628,6 +628,11 @@ RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, cons
BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_SUITE(BlockChainTests)
BOOST_AUTO_TEST_CASE(bcInvalidRLPTest)
{
dev::test::executeTests("bcInvalidRLPTest", "/BlockTests", dev::test::doBlockchainTests);
}
BOOST_AUTO_TEST_CASE(bcJS_API_Test) BOOST_AUTO_TEST_CASE(bcJS_API_Test)
{ {
dev::test::executeTests("bcJS_API_Test", "/BlockTests", dev::test::doBlockchainTests); dev::test::executeTests("bcJS_API_Test", "/BlockTests", dev::test::doBlockchainTests);

View File

@ -21,6 +21,7 @@
*/ */
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
#include <libdevcore/Assertions.h>
#include <libdevcore/Exceptions.h> #include <libdevcore/Exceptions.h>
#include <libdevcore/Log.h> #include <libdevcore/Log.h>
#include <libevm/VMFactory.h> #include <libevm/VMFactory.h>

View File

@ -21,6 +21,7 @@
*/ */
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
#include <libdevcore/Assertions.h>
#include <libdevcore/Exceptions.h> #include <libdevcore/Exceptions.h>
#include <libdevcore/Log.h> #include <libdevcore/Log.h>
#include <libevm/VMFactory.h> #include <libevm/VMFactory.h>

View File

@ -55,20 +55,37 @@ int main(int argc, char *argv[])
auto now = chrono::steady_clock::now().time_since_epoch(); auto now = chrono::steady_clock::now().time_since_epoch();
auto timeSinceEpoch = chrono::duration_cast<chrono::nanoseconds>(now).count(); auto timeSinceEpoch = chrono::duration_cast<chrono::nanoseconds>(now).count();
gen.seed(static_cast<unsigned int>(timeSinceEpoch)); gen.seed(static_cast<unsigned int>(timeSinceEpoch));
boost::random::uniform_int_distribution<> lengthOfCodeDist(2, 16); // set min and max length of the random evm code
boost::random::uniform_int_distribution<> lengthOfCodeDist(8, 24);
boost::random::uniform_int_distribution<> reasonableInputValuesSize(0, 7);
boost::random::uniform_int_distribution<> opcodeDist(0, 255); boost::random::uniform_int_distribution<> opcodeDist(0, 255);
boost::random::uniform_int_distribution<> BlockInfoOpcodeDist(0x40, 0x45); boost::random::uniform_int_distribution<> BlockInfoOpcodeDist(0x40, 0x45);
boost::random::uniform_int_distribution<> uniformInt(0, 0x7fffffff);
boost::random::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> > randGenInputValue(gen, reasonableInputValuesSize);
boost::random::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> > randGenUniformInt(gen, uniformInt);
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<> > randGen(gen, opcodeDist);
boost::random::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> > randGenBlockInfoOpcode(gen, BlockInfoOpcodeDist); boost::random::variate_generator<boost::mt19937&, boost::random::uniform_int_distribution<> > randGenBlockInfoOpcode(gen, BlockInfoOpcodeDist);
std::vector<u256> reasonableInputValues;
reasonableInputValues.push_back(0);
reasonableInputValues.push_back(1);
reasonableInputValues.push_back(50000);
reasonableInputValues.push_back(u256("0x10000000000000000000000000000000000000000"));
reasonableInputValues.push_back(u256("0xffffffffffffffffffffffffffffffffffffffff"));
reasonableInputValues.push_back(u256("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"));
reasonableInputValues.push_back(u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
reasonableInputValues.push_back(u256("0x945304eb96065b2a98b57a48a06ae28d285a71b5"));
reasonableInputValues.push_back(randGenUniformInt());
int lengthOfCode = lengthOfCodeDist(gen); int lengthOfCode = lengthOfCodeDist(gen);
string randomCode; string randomCode;
for (int i = 0; i < lengthOfCode; ++i) for (int i = 0; i < lengthOfCode; ++i)
{ {
// pre-fill stack to avoid that most of the test fail with a stackunderflow
if (i < 8 && (randGen() < 192)) if (i < 8 && (randGen() < 192))
{ {
randomCode += toHex(toCompactBigEndian((uint8_t)randGenBlockInfoOpcode())); randomCode += randGen() < 32 ? toHex(toCompactBigEndian((uint8_t)randGenBlockInfoOpcode())) : "7f" + toHex(reasonableInputValues[randGenInputValue()]);
continue; continue;
} }
@ -93,7 +110,7 @@ int main(int argc, char *argv[])
}, },
"pre" : { "pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "0",
"code" : "0x6001600101600055", "code" : "0x6001600101600055",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
@ -130,7 +147,16 @@ int main(int argc, char *argv[])
read_string(s, v); read_string(s, v);
// insert new random code // insert new random code
v.get_obj().find("randomStatetest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode + (randGen() > 128 ? "55" : ""); v.get_obj().find("randomStatetest")->second.get_obj().find("pre")->second.get_obj().begin()->second.get_obj()["code"] = "0x" + randomCode + (randGen() > 128 ? "55" : "") + (randGen() > 128 ? "60005155" : "");
// insert new data in tx
v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["data"] = "0x" + randomCode;
// insert new value in tx
v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["value"] = toString(randGenUniformInt());
// insert new gasLimit in tx
v.get_obj().find("randomStatetest")->second.get_obj().find("transaction")->second.get_obj()["gasLimit"] = "0x" + toHex(toCompactBigEndian((int)randGenUniformInt()));
// fill test // fill test
doStateTests(v); doStateTests(v);

View File

@ -22,6 +22,7 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <libdevcore/Worker.h> #include <libdevcore/Worker.h>
#include <libdevcore/Assertions.h>
#include <libdevcrypto/Common.h> #include <libdevcrypto/Common.h>
#include <libp2p/UDP.h> #include <libp2p/UDP.h>
#include <libp2p/NodeTable.h> #include <libp2p/NodeTable.h>

View File

@ -211,7 +211,7 @@
"transaction" : "transaction" :
{ {
"data" : "", "data" : "",
"gasLimit" : "0xffffffffffffffffffffffffffffff", "gasLimit" : "15720826",
"gasPrice" : "1", "gasPrice" : "1",
"nonce" : "", "nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -260,7 +260,7 @@
"transaction" : "transaction" :
{ {
"data" : "", "data" : "",
"gasLimit" : "0xffffffffffffffffffffffffffffff", "gasLimit" : "166262",
"gasPrice" : "1", "gasPrice" : "1",
"nonce" : "", "nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -308,7 +308,7 @@
"transaction" : "transaction" :
{ {
"data" : "", "data" : "",
"gasLimit" : "0xffffffffffffffffffffffffffffff", "gasLimit" : "17592186099592",
"gasPrice" : "1", "gasPrice" : "1",
"nonce" : "", "nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
@ -355,7 +355,7 @@
"transaction" : "transaction" :
{ {
"data" : "", "data" : "",
"gasLimit" : "0xffffffffffffffffffffffffffffff", "gasLimit" : "15720826",
"gasPrice" : "1", "gasPrice" : "1",
"nonce" : "", "nonce" : "",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",