From 5549af41b9939f880481ba56fb7b724894c3a1dc Mon Sep 17 00:00:00 2001 From: Dimitry Date: Thu, 14 Jun 2018 18:26:28 +0300 Subject: [PATCH] remove double check of accountMask upon loading chain config --- libethereum/Account.cpp | 2 +- libethereum/ValidationSchemes.h | 1 + test/tools/libtesteth/BlockChainHelper.cpp | 7 +++++++ test/tools/libtesteth/ImportTest.cpp | 14 ++++++++++---- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libethereum/Account.cpp b/libethereum/Account.cpp index 52aa5a58d26..ab8291e832d 100644 --- a/libethereum/Account.cpp +++ b/libethereum/Account.cpp @@ -85,6 +85,7 @@ PrecompiledContract createPrecompiledContract(js::mObject const& _precompiled) } } +// TODO move AccountMaskObj to libtesteth (it is used only in test logic) AccountMap dev::eth::jsonToAccountMap(std::string const& _json, u256 const& _defaultNonce, AccountMaskMap* o_mask, PrecompiledContractMap* o_precompiled, const fs::path& _configPath) { @@ -105,7 +106,6 @@ AccountMap dev::eth::jsonToAccountMap(std::string const& _json, u256 const& _def { Address a(fromHex(account.first)); auto const& accountMaskJson = account.second.get_obj(); - validateAccountMaskObj(accountMaskJson); bool haveBalance = (accountMaskJson.count(c_wei) || accountMaskJson.count(c_finney) || accountMaskJson.count(c_balance)); diff --git a/libethereum/ValidationSchemes.h b/libethereum/ValidationSchemes.h index 59d1471b307..b3e716d6991 100644 --- a/libethereum/ValidationSchemes.h +++ b/libethereum/ValidationSchemes.h @@ -74,6 +74,7 @@ void validateConfigJson(json_spirit::mObject const& _obj); // Validate account json object void validateAccountObj(json_spirit::mObject const& _o); +// TODO move AccountMaskObj to libtesteth (it is used only in test logic) // Validate accountMask json object. Mask indicates which fields are set void validateAccountMaskObj(json_spirit::mObject const& _o); } diff --git a/test/tools/libtesteth/BlockChainHelper.cpp b/test/tools/libtesteth/BlockChainHelper.cpp index c2dbdf4400e..24a310c974d 100644 --- a/test/tools/libtesteth/BlockChainHelper.cpp +++ b/test/tools/libtesteth/BlockChainHelper.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include using namespace std; @@ -106,6 +107,12 @@ void TestBlock::initBlockFromJsonHeader(mObject const& _blockHeader, mObject con json_spirit::mObject state = _stateObj; dev::test::replaceCodeInState(state); + + for (auto const& account : state) + { + auto const& accountJson = account.second.get_obj(); + validation::validateAccountObj(accountJson); + } m_accountMap = jsonToAccountMap(json_spirit::write_string(json_spirit::mValue(state), false)); m_blockHeader = diff --git a/test/tools/libtesteth/ImportTest.cpp b/test/tools/libtesteth/ImportTest.cpp index c2aa6fa8d94..953b2b74aef 100644 --- a/test/tools/libtesteth/ImportTest.cpp +++ b/test/tools/libtesteth/ImportTest.cpp @@ -18,14 +18,15 @@ * Helper class for managing data when running state tests */ -#include -#include -#include +#include +#include #include +#include #include +#include +#include #include #include -#include #include @@ -384,6 +385,11 @@ void ImportTest::importState(json_spirit::mObject const& _o, State& _state, Acco json_spirit::mObject o = _o; replaceCodeInState( o); // Compile LLL and other src code of the test Fillers using external call to lllc + for (auto const& account : o) + { + auto const& accountMaskJson = account.second.get_obj(); + validation::validateAccountMaskObj(accountMaskJson); + } std::string jsondata = json_spirit::write_string((json_spirit::mValue)o, false); _state.populateFrom(jsonToAccountMap(jsondata, 0, &o_mask)); }