Browse Source

style

cl-refactor
Christoph Jentzsch 10 years ago
parent
commit
8dcf6635ac
  1. 4
      libdevcore/Exceptions.h
  2. 3
      test/TestHelper.cpp
  3. 10
      test/TestHelper.h
  4. 13
      test/state.cpp

4
libdevcore/Exceptions.h

@ -46,11 +46,7 @@ struct FileError: virtual Exception {};
typedef boost::error_info<struct tag_invalidSymbol, char> errinfo_invalidSymbol; typedef boost::error_info<struct tag_invalidSymbol, char> errinfo_invalidSymbol;
typedef boost::error_info<struct tag_address, std::string> errinfo_wrongAddress; typedef boost::error_info<struct tag_address, std::string> errinfo_wrongAddress;
typedef boost::error_info<struct tag_comment, std::string> errinfo_comment; typedef boost::error_info<struct tag_comment, std::string> errinfo_comment;
typedef boost::error_info<struct tag_required, int> errinfo_required; typedef boost::error_info<struct tag_required, int> errinfo_required;
typedef boost::error_info<struct tag_got, int> errinfo_got; typedef boost::error_info<struct tag_got, int> errinfo_got;
typedef boost::tuple<errinfo_required, errinfo_got> RequirementError; typedef boost::tuple<errinfo_required, errinfo_got> RequirementError;
} }

3
test/TestHelper.cpp

@ -67,7 +67,6 @@ namespace test
ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):m_TestObject(_o) ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):m_TestObject(_o)
{ {
importEnv(_o["env"].get_obj()); importEnv(_o["env"].get_obj());
importState(_o["pre"].get_obj(), m_statePre); importState(_o["pre"].get_obj(), m_statePre);
importTransaction(_o["transaction"].get_obj()); importTransaction(_o["transaction"].get_obj());
@ -111,7 +110,6 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
Address address = Address(i.first); Address address = Address(i.first);
for (auto const& j: o["storage"].get_obj()) for (auto const& j: o["storage"].get_obj())
_state.setStorage(address, toInt(j.first), toInt(j.second)); _state.setStorage(address, toInt(j.first), toInt(j.second));
@ -120,7 +118,6 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
toInt(o["nonce"]); toInt(o["nonce"]);
if (toHex(code).size()) if (toHex(code).size())
{ {
cout << "address: " << address << "has code: " << toHex(code) << endl;
_state.m_cache[address] = Account(toInt(o["balance"]), Account::ContractConception); _state.m_cache[address] = Account(toInt(o["balance"]), Account::ContractConception);
i.second.get_obj()["code"] = "0x" + toHex(code); //preperation for export i.second.get_obj()["code"] = "0x" + toHex(code); //preperation for export
_state.m_cache[address].setCode(bytesConstRef(&code)); _state.m_cache[address].setCode(bytesConstRef(&code));

10
test/TestHelper.h

@ -52,28 +52,18 @@ public:
void importState(json_spirit::mObject& _o, eth::State& _state); void importState(json_spirit::mObject& _o, eth::State& _state);
void importTransaction(json_spirit::mObject& _o); void importTransaction(json_spirit::mObject& _o);
void exportTest(bytes _output, eth::State& _statePost); void exportTest(bytes _output, eth::State& _statePost);
eth::Manifest* getManifest(){ return &m_manifest;}
eth::State m_statePre; eth::State m_statePre;
eth::State m_statePost; eth::State m_statePost;
eth::ExtVMFace m_environment; eth::ExtVMFace m_environment;
u256 gas;
u256 gasExec;
eth::Transaction m_transaction; eth::Transaction m_transaction;
bytes output;
eth::Manifest m_manifest;
bytes code; bytes code;
private: private:
json_spirit::mObject& m_TestObject; json_spirit::mObject& m_TestObject;
// needed for const ref
bytes data;
}; };
// helping functions // helping functions
u256 toInt(json_spirit::mValue const& _v); u256 toInt(json_spirit::mValue const& _v);
byte toByte(json_spirit::mValue const& _v); byte toByte(json_spirit::mValue const& _v);
bytes importCode(json_spirit::mObject &_o); bytes importCode(json_spirit::mObject &_o);

13
test/state.cpp

@ -55,7 +55,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
BOOST_REQUIRE(o.count("pre") > 0); BOOST_REQUIRE(o.count("pre") > 0);
BOOST_REQUIRE(o.count("transaction") > 0); BOOST_REQUIRE(o.count("transaction") > 0);
ImportTest importer(o,_fillin); ImportTest importer(o, _fillin);
if (_fillin) if (_fillin)
{ {
@ -64,20 +64,9 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
} }
State theState = importer.m_statePre; State theState = importer.m_statePre;
bytes tx = importer.m_transaction.rlp(); bytes tx = importer.m_transaction.rlp();
bytes output; bytes output;
// check
for (auto const& a: theState.addresses())
{
cout << "address: " << a.first << endl;
cout << "balance: " << theState.balance(a.first) << endl;
cout << "has code: " << theState.addressHasCode(a.first) << endl;
}
try try
{ {
theState.execute(tx, &output); theState.execute(tx, &output);

Loading…
Cancel
Save