0x -> 0x0 for numbers

This commit is contained in:
CJentzsch 2015-04-17 18:41:27 +02:00
parent 7571971ca0
commit 22d16c048b
2 changed files with 9 additions and 9 deletions

View File

@ -123,7 +123,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
{ {
static const set<string> hashes {"bloom" , "coinbase", "hash", "mixHash", "parentHash", "receiptTrie", static const set<string> hashes {"bloom" , "coinbase", "hash", "mixHash", "parentHash", "receiptTrie",
"stateRoot", "transactionsTrie", "uncleHash", "currentCoinbase", "stateRoot", "transactionsTrie", "uncleHash", "currentCoinbase",
"previousHash", "to", "address", "caller", "origin", "secretKey"}; "previousHash", "to", "address", "caller", "origin", "secretKey", "data"};
for (auto& i: _o) for (auto& i: _o)
{ {
@ -140,7 +140,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") ? str : "0x" + toHex(toCompactBigEndian(toInt(str))); _o[key] = (str.substr(0, 2) == "0x") ? str : "0x" + (toHex(toCompactBigEndian(toInt(str))).empty() ? "0" : toHex(toCompactBigEndian(toInt(str))));
} }
return _o; return _o;
} }
@ -363,8 +363,8 @@ json_spirit::mObject fillJsonWithState(State _state)
for (auto const& a: _state.addresses()) for (auto const& a: _state.addresses())
{ {
json_spirit::mObject o; json_spirit::mObject o;
o["balance"] = "0x" + toHex(toCompactBigEndian(_state.balance(a.first))); o["balance"] = "0x" + (toHex(toCompactBigEndian(_state.balance(a.first))).empty() ? "0" : toHex(toCompactBigEndian(_state.balance(a.first))));
o["nonce"] = "0x" + toHex(toCompactBigEndian(_state.transactionsFrom(a.first))); o["nonce"] = "0x" + (toHex(toCompactBigEndian(_state.transactionsFrom(a.first))).empty() ? "0" : toHex(toCompactBigEndian(_state.transactionsFrom(a.first))));
{ {
json_spirit::mObject store; json_spirit::mObject store;
for (auto const& s: _state.storage(a.first)) for (auto const& s: _state.storage(a.first))

View File

@ -625,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"] = "0x" + toHex(toCompactBigEndian(_bi.difficulty)); _o["difficulty"] = "0x" + (toHex(toCompactBigEndian(_bi.difficulty)).empty() ? "0" : toHex(toCompactBigEndian(_bi.difficulty)));
_o["number"] = "0x" + toHex(toCompactBigEndian(_bi.number)); _o["number"] = "0x" + (toHex(toCompactBigEndian(_bi.number)).empty() ? "0" : toHex(toCompactBigEndian(_bi.number)));
_o["gasLimit"] = "0x" + toHex(toCompactBigEndian(_bi.gasLimit)); _o["gasLimit"] = "0x" + (toHex(toCompactBigEndian(_bi.gasLimit)).empty() ? "0" : toHex(toCompactBigEndian(_bi.gasLimit)));
_o["gasUsed"] = "0x" + toHex(toCompactBigEndian(_bi.gasUsed)); _o["gasUsed"] = "0x" + (toHex(toCompactBigEndian(_bi.gasUsed)).empty() ? "0" : toHex(toCompactBigEndian(_bi.gasUsed)));
_o["timestamp"] = "0x" + toHex(toCompactBigEndian(_bi.timestamp)); _o["timestamp"] = "0x" + (toHex(toCompactBigEndian(_bi.timestamp)).empty() ? "0" : 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);