aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-02-14 20:50:57 +0800
committerGitHub <noreply@github.com>2017-02-14 20:50:57 +0800
commit91d5515c3335a5e0d502494f2d0a08237e3dd993 (patch)
tree5a6a45aefa55da099a0691089cb4d95aa83af2f2
parentd4da4ef35f8118d49bed54f11392036e1d31f7e7 (diff)
parent0fe788aad6d55c440e04f6f64f1927613bd6b16b (diff)
downloaddexon-solidity-91d5515c3335a5e0d502494f2d0a08237e3dd993.tar.gz
dexon-solidity-91d5515c3335a5e0d502494f2d0a08237e3dd993.tar.zst
dexon-solidity-91d5515c3335a5e0d502494f2d0a08237e3dd993.zip
Merge pull request #1692 from ethereum/rpc-mining-time
Use maxMiningTime in mining as opposed to poll counter
-rw-r--r--test/RPCSession.cpp20
-rw-r--r--test/RPCSession.h3
2 files changed, 12 insertions, 11 deletions
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp
index c27e73d4..ff00d783 100644
--- a/test/RPCSession.cpp
+++ b/test/RPCSession.cpp
@@ -243,27 +243,30 @@ 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);
- bool mined = false;
-
// 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 polls = 0;
- for (; polls < 14 && !mined; ++polls)
+ 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)
- mined = true;
+ break;
else
sleepTime *= 2;
}
- if (polls > 1)
+ if (tries > 1)
{
m_successfulMineRuns = 0;
m_sleepTime += 2;
}
- else if (polls == 1)
+ else if (tries == 1)
{
m_successfulMineRuns++;
if (m_successfulMineRuns > 5)
@@ -273,9 +276,6 @@ void RPCSession::test_mineBlocks(int _number)
m_sleepTime--;
}
}
-
- if (!mined)
- BOOST_FAIL("Error in test_mineBlocks: block mining timeout!");
}
void RPCSession::test_modifyTimestamp(size_t _timestamp)
diff --git a/test/RPCSession.h b/test/RPCSession.h
index 105ba378..414db323 100644
--- a/test/RPCSession.h
+++ b/test/RPCSession.h
@@ -126,7 +126,8 @@ private:
IPCSocket m_ipcSocket;
size_t m_rpcSequence = 1;
- unsigned m_sleepTime = 10;
+ unsigned m_maxMiningTime = 15000; // 15 seconds
+ unsigned m_sleepTime = 10; // 10 milliseconds
unsigned m_successfulMineRuns = 0;
std::vector<std::string> m_accounts;