Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
remove double check of accountMask upon loading chain config
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Jun 14, 2018
1 parent 2dd0bf0 commit 5549af4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libethereum/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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));
Expand Down
1 change: 1 addition & 0 deletions libethereum/ValidationSchemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
7 changes: 7 additions & 0 deletions test/tools/libtesteth/BlockChainHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <libethereum/BlockChain.h>
#include <libethereum/GenesisInfo.h>
#include <libethereum/TransactionQueue.h>
#include <libethereum/ValidationSchemes.h>
#include <test/tools/libtesteth/BlockChainHelper.h>
#include <test/tools/libtesteth/TestHelper.h>
using namespace std;
Expand Down Expand Up @@ -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 =
Expand Down
14 changes: 10 additions & 4 deletions test/tools/libtesteth/ImportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
* Helper class for managing data when running state tests
*/

#include <test/tools/libtesteth/TestHelper.h>
#include <test/tools/libtesteth/ImportTest.h>
#include <test/tools/libtesteth/TestOutputHelper.h>
#include <libethereum/ValidationSchemes.h>
#include <test/tools/jsontests/BlockChainTests.h>
#include <test/tools/libtesteth/BlockChainHelper.h>
#include <test/tools/libtesteth/ImportTest.h>
#include <test/tools/libtesteth/Options.h>
#include <test/tools/libtesteth/TestHelper.h>
#include <test/tools/libtesteth/TestOutputHelper.h>
#include <test/tools/libtestutils/Common.h>
#include <test/tools/libtestutils/TestLastBlockHashes.h>
#include <test/tools/jsontests/BlockChainTests.h>

#include <boost/filesystem/path.hpp>

Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 5549af4

Please sign in to comment.