aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/RPCSession.cpp35
-rw-r--r--test/RPCSession.h3
-rw-r--r--test/libsolidity/GasMeter.cpp12
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp3
-rwxr-xr-xtest/solcjsTests.sh2
5 files changed, 11 insertions, 44 deletions
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp
index 0aae21a7..60848118 100644
--- a/test/RPCSession.cpp
+++ b/test/RPCSession.cpp
@@ -296,40 +296,7 @@ void RPCSession::test_mineBlocks(int _number)
{
u256 startBlock = fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString()));
BOOST_REQUIRE(rpcCall("test_mineBlocks", { to_string(_number) }, true) == true);
-
- // We auto-calibrate the time it takes to mine the transaction.
- // It would be better to go without polling, but that would probably need a change to the test client
-
- auto startTime = std::chrono::steady_clock::now();
- unsigned sleepTime = m_sleepTime;
- size_t tries = 0;
- for (; ; ++tries)
- {
- std::this_thread::sleep_for(chrono::milliseconds(sleepTime));
- auto endTime = std::chrono::steady_clock::now();
- unsigned timeSpent = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
- if (timeSpent > m_maxMiningTime)
- BOOST_FAIL("Error in test_mineBlocks: block mining timeout!");
- if (fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString())) >= startBlock + _number)
- break;
- else
- sleepTime *= 2;
- }
- if (tries > 1)
- {
- m_successfulMineRuns = 0;
- m_sleepTime += 2;
- }
- else if (tries == 1)
- {
- m_successfulMineRuns++;
- if (m_successfulMineRuns > 5)
- {
- m_successfulMineRuns = 0;
- if (m_sleepTime > 2)
- m_sleepTime--;
- }
- }
+ BOOST_REQUIRE(fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString())) == startBlock + _number);
}
void RPCSession::test_modifyTimestamp(size_t _timestamp)
diff --git a/test/RPCSession.h b/test/RPCSession.h
index 6e1391b4..92f9da4a 100644
--- a/test/RPCSession.h
+++ b/test/RPCSession.h
@@ -136,9 +136,6 @@ private:
IPCSocket m_ipcSocket;
size_t m_rpcSequence = 1;
- unsigned m_maxMiningTime = 6000000; // 600 seconds
- unsigned m_sleepTime = 10; // 10 milliseconds
- unsigned m_successfulMineRuns = 0;
bool m_receiptHasStatusField = false;
std::vector<std::string> m_accounts;
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)
diff --git a/test/solcjsTests.sh b/test/solcjsTests.sh
index e0bbc5df..b9224862 100755
--- a/test/solcjsTests.sh
+++ b/test/solcjsTests.sh
@@ -60,7 +60,7 @@ DIR=$(mktemp -d)
# Update version (needed for some tests)
echo "Updating package.json to version $VERSION"
- npm version --no-git-tag-version $VERSION
+ npm version --allow-same-version --no-git-tag-version $VERSION
echo "Running solc-js tests..."
npm run test