From 1d156a5726bc8c1eadc8b8297aa10f5212990e52 Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Wed, 5 Nov 2014 20:21:33 +0100 Subject: Moved code export to export function in ImportHelper --- TestHelper.cpp | 26 ++++++++++++++++++++++++-- 1 file 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 #include -//#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) -- cgit