aboutsummaryrefslogtreecommitdiffstats
path: root/solidityExecutionFramework.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-01-09 18:22:59 +0800
committerchriseth <c@ethdev.com>2015-01-09 18:22:59 +0800
commit0504dc21e1ea9820bdc1e92f539d661866490822 (patch)
treebd38be567ae2895b613c107fbfe4bd7db61f5d74 /solidityExecutionFramework.h
parent90cdc52ae788d24e79800bf44473f3c8c087c1f4 (diff)
parent765bd95a075107667f45177d07c00151e59ed713 (diff)
downloaddexon-solidity-0504dc21e1ea9820bdc1e92f539d661866490822.tar.gz
dexon-solidity-0504dc21e1ea9820bdc1e92f539d661866490822.tar.zst
dexon-solidity-0504dc21e1ea9820bdc1e92f539d661866490822.zip
Merge pull request #754 from LefterisJP/sol_abiFunctionHash
Calculation of ABI Function Identifier Hash
Diffstat (limited to 'solidityExecutionFramework.h')
-rw-r--r--solidityExecutionFramework.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/solidityExecutionFramework.h b/solidityExecutionFramework.h
index e476140d..5ef23fdb 100644
--- a/solidityExecutionFramework.h
+++ b/solidityExecutionFramework.h
@@ -56,34 +56,36 @@ public:
return m_output;
}
- bytes const& callContractFunction(byte _index, bytes const& _data = bytes(), u256 const& _value = 0)
+ bytes const& callContractFunction(std::string _sig, bytes const& _data = bytes(),
+ u256 const& _value = 0)
{
- sendMessage(bytes(1, _index) + _data, false, _value);
+ FixedHash<4> hash(dev::sha3(_sig));
+ sendMessage(hash.asBytes() + _data, false, _value);
return m_output;
}
template <class... Args>
- bytes const& callContractFunction(byte _index, Args const&... _arguments)
+ bytes const& callContractFunction(std::string _sig, Args const&... _arguments)
{
- return callContractFunction(_index, argsToBigEndian(_arguments...));
+ return callContractFunction(_sig, argsToBigEndian(_arguments...));
}
template <class CppFunction, class... Args>
- void testSolidityAgainstCpp(byte _index, CppFunction const& _cppFunction, Args const&... _arguments)
+ void testSolidityAgainstCpp(std::string _sig, CppFunction const& _cppFunction, Args const&... _arguments)
{
- bytes solidityResult = callContractFunction(_index, _arguments...);
+ 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));
}
template <class CppFunction, class... Args>
- void testSolidityAgainstCppOnRange(byte _index, CppFunction const& _cppFunction,
+ void testSolidityAgainstCppOnRange(std::string _sig, CppFunction const& _cppFunction,
u256 const& _rangeStart, u256 const& _rangeEnd)
{
for (u256 argument = _rangeStart; argument < _rangeEnd; ++argument)
{
- bytes solidityResult = callContractFunction(_index, 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) +