From dc15e31605d1de47883c2890878195403ba984aa Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Tue, 25 May 2021 17:21:48 +0200 Subject: [PATCH] Increased the tolerance for two GasMeter tests. --- test/libsolidity/GasMeter.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 43256d14f..d77462eb9 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -192,7 +192,15 @@ BOOST_AUTO_TEST_CASE(function_calls) } )"; testCreationTimeGas(sourceCode); - testRunTimeGas("f(uint256)", vector{encodeArgs(2), encodeArgs(8)}); + // In f, data2 is accessed twice, so there is a reduction of 2200 to 100 in actual costs. + // However, GasMeter always assumes cold costs. + testRunTimeGas( + "f(uint256)", + vector{encodeArgs(2), encodeArgs(8)}, + m_evmVersion < EVMVersion::berlin() ? + u256(0) : + u256(2100) + ); } BOOST_AUTO_TEST_CASE(multiple_external_functions) @@ -213,7 +221,16 @@ BOOST_AUTO_TEST_CASE(multiple_external_functions) } )"; testCreationTimeGas(sourceCode); - testRunTimeGas("f(uint256)", vector{encodeArgs(2), encodeArgs(8)}); + // In f, data2 is accessed twice, so there is a reduction of 2200 to 100 in actual costs. + // However, GasMeter always assumes cold costs. + testRunTimeGas( + "f(uint256)", + vector{encodeArgs(2), encodeArgs(8)}, + m_evmVersion < EVMVersion::berlin() ? + u256(0) : + u256(2100) + ); + testRunTimeGas("g(uint256)", vector{encodeArgs(2)}); }