diff options
author | Gav Wood <g@ethdev.com> | 2015-03-31 17:52:03 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-03-31 17:52:03 +0800 |
commit | 91336ce42b1616ee8af39d5b2be9c96f097d375f (patch) | |
tree | 396edd09173889d5514654614a854269ca42a299 | |
parent | 8860f8d4c3590423f486559b11bf6c2db9bbab7a (diff) | |
parent | 0f416747ad3492aaab2b3a61d380579410753727 (diff) | |
download | dexon-solidity-91336ce42b1616ee8af39d5b2be9c96f097d375f.tar.gz dexon-solidity-91336ce42b1616ee8af39d5b2be9c96f097d375f.tar.zst dexon-solidity-91336ce42b1616ee8af39d5b2be9c96f097d375f.zip |
Merge pull request #1461 from debris/prestate_tests
failing tests, incomplete genesis state object
-rw-r--r-- | ClientBase.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/ClientBase.cpp b/ClientBase.cpp index 2197ac83..304182cf 100644 --- a/ClientBase.cpp +++ b/ClientBase.cpp @@ -34,34 +34,45 @@ BOOST_AUTO_TEST_CASE(blocks) { enumerateClients([](Json::Value const& _json, dev::eth::ClientBase& _client) -> void { - for (string const& name: _json["postState"].getMemberNames()) + auto compareState = [&_client](Json::Value const& _o, string const& _name, BlockNumber _blockNumber) -> void { - Json::Value o = _json["postState"][name]; - Address address(name); + Address address(_name); // balanceAt - u256 expectedBalance = u256(o["balance"].asString()); - u256 balance = _client.balanceAt(address); + u256 expectedBalance = u256(_o["balance"].asString()); + u256 balance = _client.balanceAt(address, _blockNumber); ETH_CHECK_EQUAL(expectedBalance, balance); // countAt - u256 expectedCount = u256(o["nonce"].asString()); - u256 count = _client.countAt(address); + u256 expectedCount = u256(_o["nonce"].asString()); + u256 count = _client.countAt(address, _blockNumber); ETH_CHECK_EQUAL(expectedCount, count); // stateAt - for (string const& pos: o["storage"].getMemberNames()) + for (string const& pos: _o["storage"].getMemberNames()) { - u256 expectedState = u256(o["storage"][pos].asString()); - u256 state = _client.stateAt(address, u256(pos)); + u256 expectedState = u256(_o["storage"][pos].asString()); + u256 state = _client.stateAt(address, u256(pos), _blockNumber); ETH_CHECK_EQUAL(expectedState, state); } // codeAt - bytes expectedCode = fromHex(o["code"].asString()); - bytes code = _client.codeAt(address); + bytes expectedCode = fromHex(_o["code"].asString()); + bytes code = _client.codeAt(address, _blockNumber); ETH_CHECK_EQUAL_COLLECTIONS(expectedCode.begin(), expectedCode.end(), - code.begin(), code.end()); + code.begin(), code.end()); + }; + + for (string const& name: _json["postState"].getMemberNames()) + { + Json::Value o = _json["postState"][name]; + compareState(o, name, PendingBlock); + } + + for (string const& name: _json["pre"].getMemberNames()) + { + Json::Value o = _json["pre"][name]; + compareState(o, name, 0); } // number |