diff options
author | Paweł Bylica <chfast@gmail.com> | 2015-06-03 23:16:33 +0800 |
---|---|---|
committer | Paweł Bylica <chfast@gmail.com> | 2015-06-03 23:16:33 +0800 |
commit | 3bacb6f3776ffcf9cf13c1dbc733f24a430337fd (patch) | |
tree | d8a89f6d510a5b2eb52e9b1760c7b0a0b375879c /libsolidity/solidityExecutionFramework.h | |
parent | 77dd832403a7f4dc11c60b25f6eec786a80c6e08 (diff) | |
parent | 0e8ce9d069b92f98fc4e96a75da11c63276b8cf7 (diff) | |
download | dexon-solidity-3bacb6f3776ffcf9cf13c1dbc733f24a430337fd.tar dexon-solidity-3bacb6f3776ffcf9cf13c1dbc733f24a430337fd.tar.gz dexon-solidity-3bacb6f3776ffcf9cf13c1dbc733f24a430337fd.tar.bz2 dexon-solidity-3bacb6f3776ffcf9cf13c1dbc733f24a430337fd.tar.lz dexon-solidity-3bacb6f3776ffcf9cf13c1dbc733f24a430337fd.tar.xz dexon-solidity-3bacb6f3776ffcf9cf13c1dbc733f24a430337fd.tar.zst dexon-solidity-3bacb6f3776ffcf9cf13c1dbc733f24a430337fd.zip |
Merge remote-tracking branch 'upstream/develop' into refactor_executive
Conflicts:
test/libsolidity/solidityExecutionFramework.h
Diffstat (limited to 'libsolidity/solidityExecutionFramework.h')
-rw-r--r-- | libsolidity/solidityExecutionFramework.h | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/libsolidity/solidityExecutionFramework.h b/libsolidity/solidityExecutionFramework.h index 8b8d851a..133b2360 100644 --- a/libsolidity/solidityExecutionFramework.h +++ b/libsolidity/solidityExecutionFramework.h @@ -42,21 +42,25 @@ class ExecutionFramework public: ExecutionFramework() { g_logVerbosity = 0; } - bytes const& compileAndRun(std::string const& _sourceCode, u256 const& _value = 0, std::string const& _contractName = "") + bytes const& compileAndRunWthoutCheck(std::string const& _sourceCode, u256 const& _value = 0, std::string const& _contractName = "") { m_compiler.reset(false, m_addStandardSources); m_compiler.addSource("", _sourceCode); ETH_TEST_REQUIRE_NO_THROW(m_compiler.compile(m_optimize), "Compiling contract failed"); - bytes code = m_compiler.getBytecode(_contractName); sendMessage(code, true, _value); + return m_output; + } + + bytes const& compileAndRun(std::string const& _sourceCode, u256 const& _value = 0, std::string const& _contractName = "") + { + compileAndRunWthoutCheck(_sourceCode, _value, _contractName); BOOST_REQUIRE(!m_output.empty()); return m_output; } template <class... Args> - bytes const& callContractFunctionWithValue(std::string _sig, u256 const& _value, - Args const&... _arguments) + bytes const& callContractFunctionWithValue(std::string _sig, u256 const& _value, Args const&... _arguments) { FixedHash<4> hash(dev::sha3(_sig)); sendMessage(hash.asBytes() + encodeArgs(_arguments...), false, _value); @@ -74,21 +78,30 @@ public: { bytes solidityResult = callContractFunction(_sig, _arguments...); bytes cppResult = callCppAndEncodeResult(_cppFunction, _arguments...); - BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match." - "\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult)); + BOOST_CHECK_MESSAGE( + solidityResult == cppResult, + "Computed values do not match.\nSolidity: " + + toHex(solidityResult) + + "\nC++: " + + toHex(cppResult)); } template <class CppFunction, class... Args> - void testSolidityAgainstCppOnRange(std::string _sig, CppFunction const& _cppFunction, - u256 const& _rangeStart, u256 const& _rangeEnd) + void testSolidityAgainstCppOnRange(std::string _sig, CppFunction const& _cppFunction, u256 const& _rangeStart, u256 const& _rangeEnd) { for (u256 argument = _rangeStart; argument < _rangeEnd; ++argument) { bytes solidityResult = callContractFunction(_sig, argument); bytes cppResult = callCppAndEncodeResult(_cppFunction, argument); - BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match." - "\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult) + - "\nArgument: " + toHex(encode(argument))); + BOOST_CHECK_MESSAGE( + solidityResult == cppResult, + "Computed values do not match.\nSolidity: " + + toHex(solidityResult) + + "\nC++: " + + toHex(cppResult) + + "\nArgument: " + + toHex(encode(argument)) + ); } } @@ -137,8 +150,10 @@ protected: eth::Executive executive(m_state, eth::LastHashes(), 0); eth::ExecutionResult res; executive.collectResult(res); - eth::Transaction t = _isCreation ? eth::Transaction(_value, m_gasPrice, m_gas, _data, 0, KeyPair::create().sec()) - : eth::Transaction(_value, m_gasPrice, m_gas, m_contractAddress, _data, 0, KeyPair::create().sec()); + eth::Transaction t = + _isCreation ? + eth::Transaction(_value, m_gasPrice, m_gas, _data, 0, KeyPair::create().sec()) : + eth::Transaction(_value, m_gasPrice, m_gas, m_contractAddress, _data, 0, KeyPair::create().sec()); bytes transactionRLP = t.rlp(); try { |