From efdef7f526d7cdf0dead9036a27794126bc4dceb Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 8 Jan 2015 17:18:31 +0100 Subject: Compiler EVM generation now takes into account for the new function hash identifier - Changed tests to comply with the new function hash identifier - Changed the function index offset to 4, and made it a constant for easy adjustment in the future --- SolidityOptimizer.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'SolidityOptimizer.cpp') diff --git a/SolidityOptimizer.cpp b/SolidityOptimizer.cpp index ef5c6f9b..f334eee1 100644 --- a/SolidityOptimizer.cpp +++ b/SolidityOptimizer.cpp @@ -55,12 +55,12 @@ public: } template - void compareVersions(byte _index, Args const&... _arguments) + void compareVersions(std::string _sig, Args const&... _arguments) { m_contractAddress = m_nonOptimizedContract; - bytes nonOptimizedOutput = callContractFunction(_index, _arguments...); + bytes nonOptimizedOutput = callContractFunction(_sig, _arguments...); m_contractAddress = m_optimizedContract; - bytes optimizedOutput = callContractFunction(_index, _arguments...); + bytes optimizedOutput = callContractFunction(_sig, _arguments...); BOOST_CHECK_MESSAGE(nonOptimizedOutput == optimizedOutput, "Computed values do not match." "\nNon-Optimized: " + toHex(nonOptimizedOutput) + "\nOptimized: " + toHex(optimizedOutput)); @@ -81,8 +81,8 @@ BOOST_AUTO_TEST_CASE(smoke_test) return a; } })"; - compileBothVersions(4, sourceCode); - compareVersions(0, u256(7)); + compileBothVersions(29, sourceCode); + compareVersions("f(uint256)", u256(7)); } BOOST_AUTO_TEST_CASE(large_integers) @@ -94,8 +94,8 @@ BOOST_AUTO_TEST_CASE(large_integers) b = 0x110000000000000000000000002; } })"; - compileBothVersions(28, sourceCode); - compareVersions(0); + compileBothVersions(53, sourceCode); + compareVersions("f()"); } BOOST_AUTO_TEST_CASE(invariants) @@ -106,8 +106,8 @@ BOOST_AUTO_TEST_CASE(invariants) return (((a + (1 - 1)) ^ 0) | 0) & (uint(0) - 1); } })"; - compileBothVersions(28, sourceCode); - compareVersions(0, u256(0x12334664)); + compileBothVersions(53, sourceCode); + compareVersions("f(uint256)", u256(0x12334664)); } BOOST_AUTO_TEST_CASE(unused_expressions) @@ -120,8 +120,8 @@ BOOST_AUTO_TEST_CASE(unused_expressions) data; } })"; - compileBothVersions(11, sourceCode); - compareVersions(0); + compileBothVersions(36, sourceCode); + compareVersions("f()"); } BOOST_AUTO_TEST_CASE(constant_folding_both_sides) @@ -135,8 +135,8 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides) return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102); } })"; - compileBothVersions(31, sourceCode); - compareVersions(0); + compileBothVersions(56, sourceCode); + compareVersions("f(uint256)"); } BOOST_AUTO_TEST_SUITE_END() -- cgit