mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'upstream/develop' into newTests
Conflicts: test/vm.cpp
This commit is contained in:
commit
dcc0361c7c
@ -386,6 +386,7 @@ void executeTests(const string& _name, const string& _testPathAppendix, std::fun
|
|||||||
{
|
{
|
||||||
BOOST_ERROR("Failed test with Exception: " << _e.what());
|
BOOST_ERROR("Failed test with Exception: " << _e.what());
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
recursiveCreateFiller.json
Normal file
35
recursiveCreateFiller.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"recursiveCreate": {
|
||||||
|
"env": {
|
||||||
|
"previousHash": "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber": "0",
|
||||||
|
"currentGasLimit": "10000000",
|
||||||
|
"currentDifficulty": "256",
|
||||||
|
"currentTimestamp": 1,
|
||||||
|
"currentCoinbase": "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre": {
|
||||||
|
"095e7baea6a6c7c4c2dfeb977efac326af552d87": {
|
||||||
|
"balance": "20000000",
|
||||||
|
"nonce": 0,
|
||||||
|
"code": "{(CODECOPY 0 0 32)(CREATE 0 0 32)}",
|
||||||
|
"storage": {}
|
||||||
|
},
|
||||||
|
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||||
|
"balance": "1000000000000000000",
|
||||||
|
"nonce": 0,
|
||||||
|
"code": "",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transaction": {
|
||||||
|
"nonce": "0",
|
||||||
|
"gasPrice": "1",
|
||||||
|
"gasLimit": "465224",
|
||||||
|
"to": "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value": "100000",
|
||||||
|
"secretKey": "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
|
"data": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -700,6 +700,28 @@ BOOST_AUTO_TEST_CASE(structs)
|
|||||||
BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
|
BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(constructor)
|
||||||
|
{
|
||||||
|
char const* sourceCode = "contract test {\n"
|
||||||
|
" mapping(uint => uint) data;\n"
|
||||||
|
" function test() {\n"
|
||||||
|
" data[7] = 8;\n"
|
||||||
|
" }\n"
|
||||||
|
" function get(uint key) returns (uint value) {\n"
|
||||||
|
" return data[key];"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
map<u256, byte> data;
|
||||||
|
data[7] = 8;
|
||||||
|
auto get = [&](u256 const& _x) -> u256
|
||||||
|
{
|
||||||
|
return data[_x];
|
||||||
|
};
|
||||||
|
testSolidityAgainstCpp(0, get, u256(6));
|
||||||
|
testSolidityAgainstCpp(0, get, u256(7));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
13
vm.cpp
13
vm.cpp
@ -337,6 +337,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
VM vm(fev.gas);
|
VM vm(fev.gas);
|
||||||
|
|
||||||
u256 gas;
|
u256 gas;
|
||||||
|
bool vmExceptionOccured = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
output = vm.go(fev, fev.simpleTrace()).toBytes();
|
output = vm.go(fev, fev.simpleTrace()).toBytes();
|
||||||
@ -345,7 +346,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
catch (VMException const& _e)
|
catch (VMException const& _e)
|
||||||
{
|
{
|
||||||
cnote << "VM did throw an exception: " << diagnostic_information(_e);
|
cnote << "VM did throw an exception: " << diagnostic_information(_e);
|
||||||
gas = 0;
|
vmExceptionOccured = true;
|
||||||
}
|
}
|
||||||
catch (Exception const& _e)
|
catch (Exception const& _e)
|
||||||
{
|
{
|
||||||
@ -379,14 +380,21 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
{
|
{
|
||||||
o["env"] = mValue(fev.exportEnv());
|
o["env"] = mValue(fev.exportEnv());
|
||||||
o["exec"] = mValue(fev.exportExec());
|
o["exec"] = mValue(fev.exportExec());
|
||||||
|
if (!vmExceptionOccured)
|
||||||
|
{
|
||||||
o["post"] = mValue(fev.exportState());
|
o["post"] = mValue(fev.exportState());
|
||||||
o["callcreates"] = fev.exportCallCreates();
|
o["callcreates"] = fev.exportCallCreates();
|
||||||
o["out"] = "0x" + toHex(output);
|
o["out"] = "0x" + toHex(output);
|
||||||
fev.push(o, "gas", gas);
|
fev.push(o, "gas", gas);
|
||||||
o["logs"] = mValue(fev.exportLog());
|
o["logs"] = mValue(fev.exportLog());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (o.count("post") > 0) // No exceptions expected
|
||||||
|
{
|
||||||
|
BOOST_CHECK(!vmExceptionOccured);
|
||||||
|
|
||||||
BOOST_REQUIRE(o.count("post") > 0);
|
BOOST_REQUIRE(o.count("post") > 0);
|
||||||
BOOST_REQUIRE(o.count("callcreates") > 0);
|
BOOST_REQUIRE(o.count("callcreates") > 0);
|
||||||
BOOST_REQUIRE(o.count("out") > 0);
|
BOOST_REQUIRE(o.count("out") > 0);
|
||||||
@ -427,6 +435,9 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
|
|
||||||
checkLog(fev.sub.logs, test.sub.logs);
|
checkLog(fev.sub.logs, test.sub.logs);
|
||||||
}
|
}
|
||||||
|
else // Exception expected
|
||||||
|
BOOST_CHECK(vmExceptionOccured);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user