mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
All Fields Hex: block tests
This commit is contained in:
parent
10245ce4b3
commit
92269d4df7
@ -120,13 +120,17 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):
|
|||||||
|
|
||||||
json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
|
json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
|
||||||
{
|
{
|
||||||
|
static const std::string hashes[] = {"bloom" , "coinbase", "hash", "mixHash", "parentHash", "receiptTrie",
|
||||||
|
"stateRoot", "transactionsTrie", "uncleHash", "currentCoinbase",
|
||||||
|
"previousHash", "to", "address", "caller", "origin"};
|
||||||
|
|
||||||
for (json_spirit::mObject::iterator it = _o.begin(); it != _o.end(); it++)
|
for (json_spirit::mObject::iterator it = _o.begin(); it != _o.end(); it++)
|
||||||
{
|
{
|
||||||
string key = (*it).first;
|
std::string key = (*it).first;
|
||||||
if (key == "to")
|
if (std::find(std::begin(hashes), std::end(hashes), key) != std::end(hashes))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string str;
|
std::string str;
|
||||||
json_spirit::mValue value = (*it).second;
|
json_spirit::mValue value = (*it).second;
|
||||||
|
|
||||||
if (value.type() == json_spirit::int_type)
|
if (value.type() == json_spirit::int_type)
|
||||||
@ -135,14 +139,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
|
|||||||
str = value.get_str();
|
str = value.get_str();
|
||||||
else continue;
|
else continue;
|
||||||
|
|
||||||
_o[key] = (str.substr(0, 2) == "0x" ||
|
_o[key] = (str.substr(0, 2) == "0x") ? str : "0x" + toHex(toCompactBigEndian(toInt(str)));
|
||||||
str.find("a") != string::npos ||
|
|
||||||
str.find("b") != string::npos ||
|
|
||||||
str.find("c") != string::npos ||
|
|
||||||
str.find("d") != string::npos ||
|
|
||||||
str.find("e") != string::npos ||
|
|
||||||
str.find("f") != string::npos
|
|
||||||
) ? str : "0x" + toHex(toCompactBigEndian(toInt(str)));
|
|
||||||
}
|
}
|
||||||
return _o;
|
return _o;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
|||||||
for (auto const& bl: o["blocks"].get_array())
|
for (auto const& bl: o["blocks"].get_array())
|
||||||
{
|
{
|
||||||
mObject blObj = bl.get_obj();
|
mObject blObj = bl.get_obj();
|
||||||
stateTemp = state;
|
|
||||||
// get txs
|
// get txs
|
||||||
TransactionQueue txs;
|
TransactionQueue txs;
|
||||||
ZeroGasPricer gp;
|
ZeroGasPricer gp;
|
||||||
@ -222,6 +222,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
|||||||
txObject["v"] = to_string(txi.second.signature().v + 27);
|
txObject["v"] = to_string(txi.second.signature().v + 27);
|
||||||
txObject["to"] = txi.second.isCreation() ? "" : toString(txi.second.receiveAddress());
|
txObject["to"] = txi.second.isCreation() ? "" : toString(txi.second.receiveAddress());
|
||||||
txObject["value"] = toString(txi.second.value());
|
txObject["value"] = toString(txi.second.value());
|
||||||
|
txObject = ImportTest::makeAllFieldsHex(txObject);
|
||||||
|
|
||||||
txArray.push_back(txObject);
|
txArray.push_back(txObject);
|
||||||
}
|
}
|
||||||
@ -301,6 +302,11 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
|
|||||||
|
|
||||||
o["blocks"] = blArray;
|
o["blocks"] = blArray;
|
||||||
o["postState"] = fillJsonWithState(state);
|
o["postState"] = fillJsonWithState(state);
|
||||||
|
|
||||||
|
//make all values hex
|
||||||
|
State prestate(OverlayDB(), BaseState::Empty, biGenesisBlock.coinbaseAddress);
|
||||||
|
importer.importState(o["pre"].get_obj(), prestate);
|
||||||
|
o["pre"] = fillJsonWithState(prestate);
|
||||||
}//_fillin
|
}//_fillin
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -619,11 +625,11 @@ void writeBlockHeaderToJson(mObject& _o, BlockInfo const& _bi)
|
|||||||
_o["transactionsTrie"] = toString(_bi.transactionsRoot);
|
_o["transactionsTrie"] = toString(_bi.transactionsRoot);
|
||||||
_o["receiptTrie"] = toString(_bi.receiptsRoot);
|
_o["receiptTrie"] = toString(_bi.receiptsRoot);
|
||||||
_o["bloom"] = toString(_bi.logBloom);
|
_o["bloom"] = toString(_bi.logBloom);
|
||||||
_o["difficulty"] = toString(_bi.difficulty);
|
_o["difficulty"] = "0x" + toHex(toCompactBigEndian(_bi.difficulty));
|
||||||
_o["number"] = toString(_bi.number);
|
_o["number"] = "0x" + toHex(toCompactBigEndian(_bi.number));
|
||||||
_o["gasLimit"] = toString(_bi.gasLimit);
|
_o["gasLimit"] = "0x" + toHex(toCompactBigEndian(_bi.gasLimit));
|
||||||
_o["gasUsed"] = toString(_bi.gasUsed);
|
_o["gasUsed"] = "0x" + toHex(toCompactBigEndian(_bi.gasUsed));
|
||||||
_o["timestamp"] = toString(_bi.timestamp);
|
_o["timestamp"] = "0x" + toHex(toCompactBigEndian(_bi.timestamp));
|
||||||
_o["extraData"] ="0x" + toHex(_bi.extraData);
|
_o["extraData"] ="0x" + toHex(_bi.extraData);
|
||||||
_o["mixHash"] = toString(_bi.mixHash);
|
_o["mixHash"] = toString(_bi.mixHash);
|
||||||
_o["nonce"] = toString(_bi.nonce);
|
_o["nonce"] = toString(_bi.nonce);
|
||||||
|
Loading…
Reference in New Issue
Block a user