diff options
author | chriseth <chris@ethereum.org> | 2018-12-13 01:41:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-13 01:41:35 +0800 |
commit | 17bf164afeb067d3570f0d253f059be6fb3aac4b (patch) | |
tree | b16b078a99ef5567f0781944c1e7e8463b49b2df /test/libsolidity | |
parent | 1c8c8734654a4bea8270beff7e1a295323002af3 (diff) | |
parent | 123d33ad41b1dea43d7b6aee4b31bc6cf373bf4a (diff) | |
download | dexon-solidity-17bf164afeb067d3570f0d253f059be6fb3aac4b.tar.gz dexon-solidity-17bf164afeb067d3570f0d253f059be6fb3aac4b.tar.zst dexon-solidity-17bf164afeb067d3570f0d253f059be6fb3aac4b.zip |
Merge pull request #4951 from ethereum/alethUpdates
Use current aleth release for testing.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/GasMeter.cpp | 12 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 5535bd74..12c22604 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -62,7 +62,7 @@ public: ); } - void testCreationTimeGas(string const& _sourceCode) + void testCreationTimeGas(string const& _sourceCode, u256 const& _tolerance = u256(0)) { compileAndRun(_sourceCode); auto state = make_shared<KnownState>(); @@ -75,12 +75,13 @@ public: gas += gasForTransaction(m_compiler.object(m_compiler.lastContractName()).bytecode, true); BOOST_REQUIRE(!gas.isInfinite); - BOOST_CHECK_EQUAL(gas.value, m_gasUsed); + BOOST_CHECK_LE(m_gasUsed, gas.value); + BOOST_CHECK_LE(gas.value - _tolerance, m_gasUsed); } /// Compares the gas computed by PathGasMeter for the given signature (but unknown arguments) /// against the actual gas usage computed by the VM on the given set of argument variants. - void testRunTimeGas(string const& _sig, vector<bytes> _argumentVariants) + void testRunTimeGas(string const& _sig, vector<bytes> _argumentVariants, u256 const& _tolerance = u256(0)) { u256 gasUsed = 0; GasMeter::GasConsumption gas; @@ -98,7 +99,8 @@ public: _sig ); BOOST_REQUIRE(!gas.isInfinite); - BOOST_CHECK_EQUAL(gas.value, m_gasUsed); + BOOST_CHECK_LE(m_gasUsed, gas.value); + BOOST_CHECK_LE(gas.value - _tolerance, m_gasUsed); } static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation) @@ -186,7 +188,7 @@ BOOST_AUTO_TEST_CASE(updating_store) } } )"; - testCreationTimeGas(sourceCode); + testCreationTimeGas(sourceCode, m_evmVersion < EVMVersion::constantinople() ? u256(0) : u256(9600)); } BOOST_AUTO_TEST_CASE(branches) diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index dfa60fc5..8d219d16 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -3039,7 +3039,8 @@ BOOST_AUTO_TEST_CASE(gaslimit) } )"; compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("f()"), encodeArgs(gasLimit())); + auto result = callContractFunction("f()"); + ABI_CHECK(result, encodeArgs(gasLimit())); } BOOST_AUTO_TEST_CASE(gasprice) |