aboutsummaryrefslogtreecommitdiffstats
path: root/test/RPCSession.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-02-13 21:59:29 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-02-13 22:11:03 +0800
commit1d4ef87bb11e447334d2dea99b5a70c7201d6b97 (patch)
treec001cb069d52dbe04f8478f121504e58640abf8d /test/RPCSession.cpp
parent0d8a9c328910bc9a0ab18beb273c029dc9a05b15 (diff)
downloaddexon-solidity-1d4ef87bb11e447334d2dea99b5a70c7201d6b97.tar.gz
dexon-solidity-1d4ef87bb11e447334d2dea99b5a70c7201d6b97.tar.zst
dexon-solidity-1d4ef87bb11e447334d2dea99b5a70c7201d6b97.zip
Use maxMiningTime in mining as opposed to poll counter
Diffstat (limited to 'test/RPCSession.cpp')
-rw-r--r--test/RPCSession.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp
index c27e73d4..613d042a 100644
--- a/test/RPCSession.cpp
+++ b/test/RPCSession.cpp
@@ -248,22 +248,26 @@ void RPCSession::test_mineBlocks(int _number)
// 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
+ unsigned startTime = boost::posix_time::microsec_clock::local_time();
unsigned sleepTime = m_sleepTime;
- size_t polls = 0;
- for (; polls < 14 && !mined; ++polls)
+ size_t tries = 0;
+ for (; !mined; ++tries)
{
std::this_thread::sleep_for(chrono::milliseconds(sleepTime));
+ boost::posix_time::time_duration timeSpent = boost::posix_time::microsec_clock::local_time() - startTime;
+ if (timeSpent > m_maxMiningTime)
+ break;
if (fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString())) >= startBlock + _number)
mined = true;
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)