diff options
author | Christoph Jentzsch <jentzsch.software@gmail.com> | 2014-11-06 03:21:33 +0800 |
---|---|---|
committer | Christoph Jentzsch <jentzsch.software@gmail.com> | 2014-11-06 03:21:33 +0800 |
commit | 1d156a5726bc8c1eadc8b8297aa10f5212990e52 (patch) | |
tree | dab54e18950096497977cdd461a3aced1807988e | |
parent | 6b6bb65eb8bdca8754d334510fc6938ff4b1ef5c (diff) | |
download | dexon-solidity-1d156a5726bc8c1eadc8b8297aa10f5212990e52.tar.gz dexon-solidity-1d156a5726bc8c1eadc8b8297aa10f5212990e52.tar.zst dexon-solidity-1d156a5726bc8c1eadc8b8297aa10f5212990e52.zip |
Moved code export to export function in ImportHelper
-rw-r--r-- | TestHelper.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp index 277c3351..b9c3223d 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -27,7 +27,7 @@ #include <libethereum/Client.h> #include <liblll/Compiler.h> -//#define FILL_TESTS +#define FILL_TESTS using namespace std; using namespace dev::eth; @@ -118,7 +118,6 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) if (code.size()) { _state.m_cache[address] = Account(toInt(o["balance"]), Account::ContractConception); - i.second.get_obj()["code"] = "0x" + toHex(code); //preperation for export _state.m_cache[address].setCode(bytesConstRef(&code)); } else @@ -175,6 +174,29 @@ void ImportTest::exportTest(bytes _output, State& _statePost) postState[toString(a.first)] = o; } m_TestObject["post"] = json_spirit::mValue(postState); + + // export pre state + json_spirit::mObject preState; + + for (auto const& a: m_statePre.addresses()) + { + if (genesis.count(a.first)) + continue; + + json_spirit::mObject o; + o["balance"] = toString(m_statePre.balance(a.first)); + o["nonce"] = toString(m_statePre.transactionsFrom(a.first)); + { + json_spirit::mObject store; + for (auto const& s: m_statePre.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)); + + preState[toString(a.first)] = o; + } + m_TestObject["pre"] = json_spirit::mValue(preState); } u256 toInt(json_spirit::mValue const& _v) |