Browse Source

Merge branch 'develop' into feature/vm_gas_counter_refactor

Conflicts:
	test/libevm/vm.cpp
cl-refactor
Paweł Bylica 10 years ago
parent
commit
b57b4eea77
  1. 28
      libsolidity/InterfaceHandler.cpp
  2. 9
      test/TestHelper.cpp
  3. 6
      test/libethereum/StateTestsFiller/stMemoryStressTestFiller.json
  4. 2
      test/libethereum/state.cpp
  5. 2
      test/libevm/vm.cpp

28
libsolidity/InterfaceHandler.cpp

@ -107,17 +107,27 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio
unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition const& _contractDef)
{
string ret = "contract " + _contractDef.getName() + "{";
auto populateParameters = [](vector<string> const& _paramNames, vector<string> const& _paramTypes)
{
string r = "";
solAssert(_paramNames.size() == _paramTypes.size(), "Names and types vector size does not match");
for (unsigned i = 0; i < _paramNames.size(); ++i)
r += (r.size() ? "," : "(") + _paramTypes[i] + " " + _paramNames[i];
return r.size() ? r + ")" : "()";
};
if (_contractDef.getConstructor())
{
auto externalFunction = FunctionType(*_contractDef.getConstructor()).externalFunctionType();
solAssert(!!externalFunction, "");
ret +=
"function " +
_contractDef.getName() +
populateParameters(externalFunction->getParameterNames(), externalFunction->getParameterTypeNames()) +
";";
}
for (auto const& it: _contractDef.getInterfaceFunctions())
{
auto populateParameters = [](vector<string> const& _paramNames,
vector<string> const& _paramTypes)
{
string r = "";
solAssert(_paramNames.size() == _paramTypes.size(), "Names and types vector size does not match");
for (unsigned i = 0; i < _paramNames.size(); ++i)
r += (r.size() ? "," : "(") + _paramTypes[i] + " " + _paramNames[i];
return r.size() ? r + ")" : "()";
};
ret += "function " + it.second->getDeclaration().getName() +
populateParameters(it.second->getParameterNames(), it.second->getParameterTypeNames()) +
(it.second->isConstant() ? "constant " : "");

9
test/TestHelper.cpp

@ -327,7 +327,8 @@ void ImportTest::checkExpectedState(State const& _stateExpect, State const& _sta
void ImportTest::exportTest(bytes const& _output, State const& _statePost)
{
// export output
m_TestObject["out"] = toHex(_output, 2, HexPrefix::Add);
m_TestObject["out"] = _output.size() > 4096 ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add);
// export logs
m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries());
@ -489,7 +490,11 @@ LogEntries importLog(json_spirit::mArray& _a)
void checkOutput(bytes const& _output, json_spirit::mObject& _o)
{
int j = 0;
if (_o["out"].type() == json_spirit::array_type)
if (_o["out"].get_str().find("#") == 0)
BOOST_CHECK((u256)_output.size() == toInt(_o["out"].get_str().substr(1)));
else if (_o["out"].type() == json_spirit::array_type)
for (auto const& d: _o["out"].get_array())
{
BOOST_CHECK_MESSAGE(_output[j] == toInt(d), "Output byte [" << j << "] different!");

6
test/libethereum/StateTestsFiller/stMemoryStressTestFiller.json

@ -58,7 +58,7 @@
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"code" : "{ (RETURN 0 4294967297) } ",
"code" : "{ (RETURN 0 4294967295) } ",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
@ -77,7 +77,7 @@
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
},
"mload32bitBound_return2": {
"env" : {
@ -98,7 +98,7 @@
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"code" : "{[ 0 ] 1 (RETURN 0 4294967296) } ",
"code" : "{[ 0 ] 1 (RETURN 0 4294967295) } ",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {

2
test/libethereum/state.cpp

@ -176,12 +176,10 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest)
dev::test::executeTests("stMemoryStressTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests);
}
#if ETH_SOLIDITY
BOOST_AUTO_TEST_CASE(stSolidityTest)
{
dev::test::executeTests("stSolidityTest", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests);
}
#endif
BOOST_AUTO_TEST_CASE(stMemoryTest)
{

2
test/libevm/vm.cpp

@ -388,7 +388,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
}
o["callcreates"] = fev.exportCallCreates();
o["out"] = toHex(output, 2, HexPrefix::Add);
o["out"] = output.size() > 4096 ? "#" + toString(output.size()) : toHex(output, 2, HexPrefix::Add);
o["gas"] = toCompactHex(fev.gas, HexPrefix::Add, 1);
o["logs"] = exportLog(fev.sub.logs);
}

Loading…
Cancel
Save