diff options
author | winsvega <winsvega@mail.ru> | 2015-04-13 21:33:42 +0800 |
---|---|---|
committer | winsvega <winsvega@mail.ru> | 2015-04-16 21:46:40 +0800 |
commit | 92269d4df7b6d3b454ca44a8dde2ab0a3e113749 (patch) | |
tree | dd9582a15d04c7b1f8c93c845aa4d9c901c4dc54 | |
parent | 10245ce4b3b3b5dcf50dac8a097b96cd1d5adaf9 (diff) | |
download | dexon-solidity-92269d4df7b6d3b454ca44a8dde2ab0a3e113749.tar.gz dexon-solidity-92269d4df7b6d3b454ca44a8dde2ab0a3e113749.tar.zst dexon-solidity-92269d4df7b6d3b454ca44a8dde2ab0a3e113749.zip |
All Fields Hex: block tests
-rw-r--r-- | TestHelper.cpp | 19 | ||||
-rw-r--r-- | blockchain.cpp | 18 |
2 files changed, 20 insertions, 17 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp index 5b8e7fbc..c02e8b28 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -120,13 +120,17 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): 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++) { - string key = (*it).first; - if (key == "to") + std::string key = (*it).first; + if (std::find(std::begin(hashes), std::end(hashes), key) != std::end(hashes)) continue; - string str; + std::string str; json_spirit::mValue value = (*it).second; if (value.type() == json_spirit::int_type) @@ -135,14 +139,7 @@ json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o) str = value.get_str(); else continue; - _o[key] = (str.substr(0, 2) == "0x" || - 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))); + _o[key] = (str.substr(0, 2) == "0x") ? str : "0x" + toHex(toCompactBigEndian(toInt(str))); } return _o; } diff --git a/blockchain.cpp b/blockchain.cpp index 4aa70c63..b144abe6 100644 --- a/blockchain.cpp +++ b/blockchain.cpp @@ -90,7 +90,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); - stateTemp = state; + // get txs TransactionQueue txs; ZeroGasPricer gp; @@ -222,6 +222,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txObject["v"] = to_string(txi.second.signature().v + 27); txObject["to"] = txi.second.isCreation() ? "" : toString(txi.second.receiveAddress()); txObject["value"] = toString(txi.second.value()); + txObject = ImportTest::makeAllFieldsHex(txObject); txArray.push_back(txObject); } @@ -301,6 +302,11 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) o["blocks"] = blArray; 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 else @@ -619,11 +625,11 @@ void writeBlockHeaderToJson(mObject& _o, BlockInfo const& _bi) _o["transactionsTrie"] = toString(_bi.transactionsRoot); _o["receiptTrie"] = toString(_bi.receiptsRoot); _o["bloom"] = toString(_bi.logBloom); - _o["difficulty"] = toString(_bi.difficulty); - _o["number"] = toString(_bi.number); - _o["gasLimit"] = toString(_bi.gasLimit); - _o["gasUsed"] = toString(_bi.gasUsed); - _o["timestamp"] = toString(_bi.timestamp); + _o["difficulty"] = "0x" + toHex(toCompactBigEndian(_bi.difficulty)); + _o["number"] = "0x" + toHex(toCompactBigEndian(_bi.number)); + _o["gasLimit"] = "0x" + toHex(toCompactBigEndian(_bi.gasLimit)); + _o["gasUsed"] = "0x" + toHex(toCompactBigEndian(_bi.gasUsed)); + _o["timestamp"] = "0x" + toHex(toCompactBigEndian(_bi.timestamp)); _o["extraData"] ="0x" + toHex(_bi.extraData); _o["mixHash"] = toString(_bi.mixHash); _o["nonce"] = toString(_bi.nonce); |