From 874a16bed4232d2c1fb79ee34e1a2e8f3ba89bdf Mon Sep 17 00:00:00 2001 From: Dimitry Date: Mon, 13 Jun 2016 16:17:56 +0300 Subject: fix rpc mining --- test/IPCSocket.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/test/IPCSocket.cpp b/test/IPCSocket.cpp index 77a8e176..b7b2572b 100644 --- a/test/IPCSocket.cpp +++ b/test/IPCSocket.cpp @@ -148,24 +148,16 @@ void RPCSession::test_mineBlocks(int _number) u256 startBlock = fromBigEndian(fromHex(rpcCall("eth_blockNumber").asString())); u256 currentBlock = startBlock; u256 targetBlock = startBlock + _number; - cout << "A" << endl; - for (size_t tries = 0; tries < 3 && startBlock < targetBlock; ++tries) + cout << "MINE" << endl; + rpcCall("test_mineBlocks", { (targetBlock - startBlock).str() }, true); + + //@TODO do not use polling - but that would probably need a change to the test client + for (size_t polls = 0; polls < 100; ++polls) { - if (currentBlock == startBlock) - { - cout << "MINE" << endl; - rpcCall("test_mineBlocks", { (targetBlock - startBlock).str() }, true); - } - cout << "WOIT" << endl; - startBlock = currentBlock; - //@TODO do not use polling - but that would probably need a change to the test client - for (size_t polls = 0; polls < 10; ++polls) - { - currentBlock = fromBigEndian(fromHex(rpcCall("eth_blockNumber").asString())); - if (currentBlock >= targetBlock) - return; - std::this_thread::sleep_for(chrono::milliseconds(1)); - } + currentBlock = fromBigEndian(fromHex(rpcCall("eth_blockNumber").asString())); + if (currentBlock >= targetBlock) + return; + std::this_thread::sleep_for(chrono::milliseconds(10)); //it does not work faster then 10 ms } } @@ -194,7 +186,9 @@ Json::Value RPCSession::rpcCall(string const& _methodName, vector const& { if (_canFail) return Json::Value(); - BOOST_FAIL("Error on JSON-RPC call: " + result["error"].asString()); + + Json::Value jsonError = result["error"]; + BOOST_FAIL("Error on JSON-RPC call: " + jsonError["message"].asString()); } return result["result"]; } -- cgit v1.2.3