mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' into new_jsonrpc
This commit is contained in:
commit
68db4681c0
@ -181,46 +181,35 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost)
|
||||
m_TestObject["logs"] = exportLog(_statePost.pending().size() ? _statePost.log(0) : LogEntries());
|
||||
|
||||
// export post state
|
||||
json_spirit::mObject postState;
|
||||
|
||||
for (auto const& a: _statePost.addresses())
|
||||
{
|
||||
json_spirit::mObject o;
|
||||
o["balance"] = toString(_statePost.balance(a.first));
|
||||
o["nonce"] = toString(_statePost.transactionsFrom(a.first));
|
||||
{
|
||||
json_spirit::mObject store;
|
||||
for (auto const& s: _statePost.storage(a.first))
|
||||
store["0x"+toHex(toCompactBigEndian(s.first))] = "0x"+toHex(toCompactBigEndian(s.second));
|
||||
o["storage"] = store;
|
||||
}
|
||||
o["code"] = "0x" + toHex(_statePost.code(a.first));
|
||||
|
||||
postState[toString(a.first)] = o;
|
||||
}
|
||||
m_TestObject["post"] = json_spirit::mValue(postState);
|
||||
|
||||
m_TestObject["post"] = fillJsonWithState(_statePost);
|
||||
m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes());
|
||||
|
||||
// export pre state
|
||||
json_spirit::mObject preState;
|
||||
m_TestObject["pre"] = fillJsonWithState(m_statePre);
|
||||
}
|
||||
|
||||
for (auto const& a: m_statePre.addresses())
|
||||
json_spirit::mObject fillJsonWithState(State _state)
|
||||
{
|
||||
// export pre state
|
||||
json_spirit::mObject oState;
|
||||
|
||||
for (auto const& a: _state.addresses())
|
||||
{
|
||||
json_spirit::mObject o;
|
||||
o["balance"] = toString(m_statePre.balance(a.first));
|
||||
o["nonce"] = toString(m_statePre.transactionsFrom(a.first));
|
||||
o["balance"] = toString(_state.balance(a.first));
|
||||
o["nonce"] = toString(_state.transactionsFrom(a.first));
|
||||
{
|
||||
json_spirit::mObject store;
|
||||
for (auto const& s: m_statePre.storage(a.first))
|
||||
for (auto const& s: _state.storage(a.first))
|
||||
store["0x"+toHex(toCompactBigEndian(s.first))] = "0x"+toHex(toCompactBigEndian(s.second));
|
||||
o["storage"] = store;
|
||||
}
|
||||
o["code"] = "0x" + toHex(m_statePre.code(a.first));
|
||||
o["code"] = "0x" + toHex(_state.code(a.first));
|
||||
|
||||
preState[toString(a.first)] = o;
|
||||
oState[toString(a.first)] = o;
|
||||
}
|
||||
m_TestObject["pre"] = json_spirit::mValue(preState);
|
||||
return oState;
|
||||
}
|
||||
|
||||
u256 toInt(json_spirit::mValue const& _v)
|
||||
|
@ -117,6 +117,13 @@ private:
|
||||
json_spirit::mObject& m_TestObject;
|
||||
};
|
||||
|
||||
class ZeroGasPricer: public eth::GasPricer
|
||||
{
|
||||
protected:
|
||||
u256 ask(eth::State const&) const override { return 0; }
|
||||
u256 bid(eth::TransactionPriority = eth::TransactionPriority::Medium) const override { return 0; }
|
||||
};
|
||||
|
||||
// helping functions
|
||||
u256 toInt(json_spirit::mValue const& _v);
|
||||
byte toByte(json_spirit::mValue const& _v);
|
||||
@ -136,6 +143,7 @@ void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::m
|
||||
RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj);
|
||||
void processCommandLineOptions();
|
||||
eth::LastHashes lastHashes(u256 _currentBlockNumber);
|
||||
json_spirit::mObject fillJsonWithState(eth::State _state);
|
||||
|
||||
template<typename mapType>
|
||||
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
|
||||
|
@ -265,23 +265,7 @@
|
||||
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
|
||||
},
|
||||
{
|
||||
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"coinbase" : "0000000000000000000000000000000000000000",
|
||||
"difficulty" : "131072",
|
||||
"extraData" : "0x",
|
||||
"gasLimit" : "99902343",
|
||||
"gasUsed" : "0",
|
||||
"hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04",
|
||||
"mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770",
|
||||
"nonce" : "18a524c1790fa83b",
|
||||
"number" : "2",
|
||||
"parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae",
|
||||
"receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
"seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
"stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd",
|
||||
"timestamp" : "0x54c98c82",
|
||||
"transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
|
||||
"sameAsPreviousSibling" : "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
||||
ImportTest importer(o["pre"].get_obj());
|
||||
State state(Address(), OverlayDB(), BaseState::Empty);
|
||||
importer.importState(o["pre"].get_obj(), state);
|
||||
o["pre"] = fillJsonWithState(state);
|
||||
state.commit();
|
||||
|
||||
if (_fillin)
|
||||
@ -87,7 +88,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
||||
|
||||
// get txs
|
||||
TransactionQueue txs;
|
||||
TrivialGasPricer gp;
|
||||
ZeroGasPricer gp;
|
||||
BOOST_REQUIRE(blObj.count("transactions"));
|
||||
for (auto const& txObj: blObj["transactions"].get_array())
|
||||
{
|
||||
@ -101,10 +102,18 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
||||
BlockQueue uncleBlockQueue;
|
||||
mArray aUncleList;
|
||||
vector<BlockInfo> vBiUncles;
|
||||
mObject uncleHeaderObj_pre;
|
||||
|
||||
for (auto const& uHObj: blObj["uncleHeaders"].get_array())
|
||||
{
|
||||
mObject uncleHeaderObj = uHObj.get_obj();
|
||||
if (uncleHeaderObj.count("sameAsPreviousSibling"))
|
||||
{
|
||||
writeBlockHeaderToJson(uncleHeaderObj_pre, vBiUncles[vBiUncles.size()-1]);
|
||||
aUncleList.push_back(uncleHeaderObj_pre);
|
||||
vBiUncles.push_back(vBiUncles[vBiUncles.size()-1]);
|
||||
continue;
|
||||
}
|
||||
BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj);
|
||||
|
||||
// make uncle header valid
|
||||
@ -123,6 +132,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
||||
cnote << "import uncle in blockQueue";
|
||||
RLPStream uncle = createFullBlockFromHeader(uncleBlockFromFields);
|
||||
uncleBlockQueue.import(&uncle.out(), bc);
|
||||
|
||||
uncleHeaderObj_pre = uncleHeaderObj;
|
||||
}
|
||||
|
||||
blObj["uncleHeaders"] = aUncleList;
|
||||
@ -579,6 +590,7 @@ void updatePoW(BlockInfo& _bi)
|
||||
ret = pow.mine(_bi, 10000, true, true); // tie(ret, blockFromFields.nonce)
|
||||
Ethash::assignResult(ret.second, _bi);
|
||||
}
|
||||
_bi.hash = _bi.headerHash(WithNonce);
|
||||
}
|
||||
|
||||
void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi)
|
||||
|
19
natspec.cpp
19
natspec.cpp
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(natspec_eval_function_exists)
|
||||
// given
|
||||
NatspecExpressionEvaluator e;
|
||||
// when
|
||||
string result = e.evalExpression("`typeof evaluateExpression`").toStdString();
|
||||
string result = e.evalExpression("`typeof natspec.evaluateExpression`").toStdString();
|
||||
// then
|
||||
BOOST_CHECK_EQUAL(result, "function");
|
||||
}
|
||||
@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params)
|
||||
// given
|
||||
char const* abi = R"([
|
||||
{
|
||||
"name": "f",
|
||||
"name": "multiply",
|
||||
"constant": false,
|
||||
"type": "function",
|
||||
"inputs": [
|
||||
@ -94,7 +94,18 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params)
|
||||
]
|
||||
}
|
||||
])";
|
||||
NatspecExpressionEvaluator e(abi, "'f'", "[4]");
|
||||
|
||||
char const* transaction = R"({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_call",
|
||||
"params": [{
|
||||
"to": "0x8521742d3f456bd237e312d6e30724960f72517a",
|
||||
"data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000004"
|
||||
}],
|
||||
"id": 6
|
||||
})";
|
||||
|
||||
NatspecExpressionEvaluator e(abi, transaction , "multiply");
|
||||
// when
|
||||
string result = e.evalExpression("Will multiply `a` by 7 and return `a * 7`.").toStdString();
|
||||
// then
|
||||
@ -108,7 +119,7 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_error)
|
||||
// when
|
||||
string result = e.evalExpression("`test(`").toStdString();
|
||||
// then
|
||||
BOOST_CHECK_EQUAL(result, "`test(`");
|
||||
BOOST_CHECK_EQUAL(result, "Natspec evaluation failed, wrong input params");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
58
vm.cpp
58
vm.cpp
@ -533,33 +533,43 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest)
|
||||
}
|
||||
}
|
||||
|
||||
//BOOST_AUTO_TEST_CASE(vmInputLimitsTest1)
|
||||
//{
|
||||
// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
// {
|
||||
// string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||
// if (arg == "--inputlimits" || arg == "--all")
|
||||
// {
|
||||
// auto start = chrono::steady_clock::now();
|
||||
BOOST_AUTO_TEST_CASE(vmInputLimitsTest1)
|
||||
{
|
||||
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
{
|
||||
string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||
if (arg == "--inputlimits" || arg == "--all")
|
||||
{
|
||||
auto start = chrono::steady_clock::now();
|
||||
|
||||
// dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests);
|
||||
dev::test::executeTests("vmInputLimits1", "/VMTests", dev::test::doVMTests);
|
||||
|
||||
// auto end = chrono::steady_clock::now();
|
||||
// auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
|
||||
// cnote << "test duration: " << duration.count() << " milliseconds.\n";
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
auto end = chrono::steady_clock::now();
|
||||
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
|
||||
cnote << "test duration: " << duration.count() << " milliseconds.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BOOST_AUTO_TEST_CASE(vmInputLimitsTest2)
|
||||
//{
|
||||
// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
// {
|
||||
// string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||
// if (arg == "--inputlimits" || arg == "--all")
|
||||
// dev::test::executeTests("vmInputLimitsTest2", "/VMTests", dev::test::doVMTests);
|
||||
// }
|
||||
//}
|
||||
BOOST_AUTO_TEST_CASE(vmInputLimitsTest2)
|
||||
{
|
||||
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
{
|
||||
string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||
if (arg == "--inputlimits" || arg == "--all")
|
||||
dev::test::executeTests("vmInputLimits2", "/VMTests", dev::test::doVMTests);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(vmInputLimitsLightTest)
|
||||
{
|
||||
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||
{
|
||||
string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||
if (arg == "--inputlimits" || arg == "--all")
|
||||
dev::test::executeTests("vmInputLimitsLight", "/VMTests", dev::test::doVMTests);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(vmRandom)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user