|
@ -34,6 +34,7 @@ extern std::string const c_testExampleStateTest; |
|
|
extern std::string const c_testExampleTransactionTest; |
|
|
extern std::string const c_testExampleTransactionTest; |
|
|
extern std::string const c_testExampleVMTest; |
|
|
extern std::string const c_testExampleVMTest; |
|
|
extern std::string const c_testExampleBlockchainTest; |
|
|
extern std::string const c_testExampleBlockchainTest; |
|
|
|
|
|
extern std::string const c_testExampleRLPTest; |
|
|
|
|
|
|
|
|
//Main Test functinos
|
|
|
//Main Test functinos
|
|
|
void fillRandomTest(std::function<void(json_spirit::mValue&, bool)> _doTests, std::string const& _testString, bool _debug = false); |
|
|
void fillRandomTest(std::function<void(json_spirit::mValue&, bool)> _doTests, std::string const& _testString, bool _debug = false); |
|
@ -62,7 +63,8 @@ int main(int argc, char *argv[]) |
|
|
if (arg == "-t" && i + 1 < argc) |
|
|
if (arg == "-t" && i + 1 < argc) |
|
|
{ |
|
|
{ |
|
|
testSuite = argv[i + 1]; |
|
|
testSuite = argv[i + 1]; |
|
|
if (testSuite != "BlockChainTests" && testSuite != "TransactionTests" && testSuite != "StateTests" && testSuite != "VMTests") |
|
|
if (testSuite != "BlockChainTests" && testSuite != "TransactionTests" && testSuite != "StateTests" |
|
|
|
|
|
&& testSuite != "VMTests" && testSuite != "RLPTests") |
|
|
testSuite = ""; |
|
|
testSuite = ""; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@ -139,6 +141,14 @@ int main(int argc, char *argv[]) |
|
|
else |
|
|
else |
|
|
fillRandomTest(dev::test::doVMTests, (filltest) ? testFillString : c_testExampleVMTest, filldebug); |
|
|
fillRandomTest(dev::test::doVMTests, (filltest) ? testFillString : c_testExampleVMTest, filldebug); |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
if (testSuite == "RLPTests") |
|
|
|
|
|
{ |
|
|
|
|
|
if (checktest) |
|
|
|
|
|
return checkRandomTest(dev::test::doRlpTests, testmValue, debug); |
|
|
|
|
|
else |
|
|
|
|
|
fillRandomTest(dev::test::doRlpTests, (filltest) ? testFillString : c_testExampleRLPTest, filldebug); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
@ -239,12 +249,23 @@ void parseTestWithTypes(std::string& _test) |
|
|
std::size_t pos = _test.find(types.at(i)); |
|
|
std::size_t pos = _test.find(types.at(i)); |
|
|
while (pos != std::string::npos) |
|
|
while (pos != std::string::npos) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (types.at(i) == "[RLP]") |
|
|
|
|
|
{ |
|
|
|
|
|
std::string debug; |
|
|
|
|
|
int randomDepth = 1 + dev::test::RandomCode::randomUniInt() % 10; |
|
|
|
|
|
_test.replace(pos, 5, dev::test::RandomCode::rndRLPSequence(randomDepth, debug)); |
|
|
|
|
|
cnote << debug; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
if (types.at(i) == "[CODE]") |
|
|
if (types.at(i) == "[CODE]") |
|
|
_test.replace(pos, 6, "0x"+dev::test::RandomCode::generate(10, options)); |
|
|
_test.replace(pos, 6, "0x"+dev::test::RandomCode::generate(10, options)); |
|
|
else |
|
|
else |
|
|
if (types.at(i) == "[HEX]") |
|
|
if (types.at(i) == "[HEX]") |
|
|
_test.replace(pos, 5, dev::test::RandomCode::randomUniIntHex()); |
|
|
_test.replace(pos, 5, dev::test::RandomCode::randomUniIntHex()); |
|
|
else |
|
|
else |
|
|
|
|
|
if (types.at(i) == "[HEX32]") |
|
|
|
|
|
_test.replace(pos, 7, dev::test::RandomCode::randomUniIntHex(std::numeric_limits<uint32_t>::max())); |
|
|
|
|
|
else |
|
|
if (types.at(i) == "[GASLIMIT]") |
|
|
if (types.at(i) == "[GASLIMIT]") |
|
|
_test.replace(pos, 10, dev::test::RandomCode::randomUniIntHex(dev::u256("3000000000"))); |
|
|
_test.replace(pos, 10, dev::test::RandomCode::randomUniIntHex(dev::u256("3000000000"))); |
|
|
else |
|
|
else |
|
@ -276,7 +297,7 @@ void parseTestWithTypes(std::string& _test) |
|
|
|
|
|
|
|
|
std::vector<std::string> getTypes() |
|
|
std::vector<std::string> getTypes() |
|
|
{ |
|
|
{ |
|
|
return {"[CODE]", "[HEX]", "[HASH20]", "[HASH32]", "[0xHASH32]", "[V]", "[GASLIMIT]"}; |
|
|
return {"[RLP]", "[CODE]", "[HEX]", "[HEX32]", "[HASH20]", "[HASH32]", "[0xHASH32]", "[V]", "[GASLIMIT]"}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::string const c_testExampleTransactionTest = R"( |
|
|
std::string const c_testExampleTransactionTest = R"( |
|
@ -305,7 +326,7 @@ std::string const c_testExampleStateTest = R"( |
|
|
"currentCoinbase" : "[HASH20]", |
|
|
"currentCoinbase" : "[HASH20]", |
|
|
"currentDifficulty" : "[HEX]", |
|
|
"currentDifficulty" : "[HEX]", |
|
|
"currentGasLimit" : "[GASLIMIT]", |
|
|
"currentGasLimit" : "[GASLIMIT]", |
|
|
"currentNumber" : "[HEX]", |
|
|
"currentNumber" : "[HEX32]", |
|
|
"currentTimestamp" : "[HEX]", |
|
|
"currentTimestamp" : "[HEX]", |
|
|
"previousHash" : "[HASH32]" |
|
|
"previousHash" : "[HASH32]" |
|
|
}, |
|
|
}, |
|
@ -335,7 +356,7 @@ std::string const c_testExampleStateTest = R"( |
|
|
"transaction" : { |
|
|
"transaction" : { |
|
|
"data" : "[CODE]", |
|
|
"data" : "[CODE]", |
|
|
"gasLimit" : "[HEX]", |
|
|
"gasLimit" : "[HEX]", |
|
|
"gasPrice" : "[V]", |
|
|
"gasPrice" : "[HEX32]", |
|
|
"nonce" : "0", |
|
|
"nonce" : "0", |
|
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", |
|
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", |
|
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", |
|
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", |
|
@ -377,6 +398,14 @@ std::string const c_testExampleVMTest = R"( |
|
|
} |
|
|
} |
|
|
)"; |
|
|
)"; |
|
|
|
|
|
|
|
|
|
|
|
std::string const c_testExampleRLPTest = R"( |
|
|
|
|
|
{ |
|
|
|
|
|
"randomRLPTest" : { |
|
|
|
|
|
"out" : "[RLP]" |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
)"; |
|
|
|
|
|
|
|
|
std::string const c_testExampleBlockchainTest = R"( |
|
|
std::string const c_testExampleBlockchainTest = R"( |
|
|
{ |
|
|
{ |
|
|
"randomBlockTest" : { |
|
|
"randomBlockTest" : { |
|
|