diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-09 05:49:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-09 05:49:14 +0800 |
commit | 38e79adfe44b7dc11778942174384eff509db56f (patch) | |
tree | 4cd8a71afff72090be832e99e2c42793768a550b | |
parent | b66d9c3258c986c44e013595da5b021b7cdf8775 (diff) | |
parent | af6ab7fa916ac0f56c2caeae03be47bbefd8a50f (diff) | |
download | dexon-solidity-38e79adfe44b7dc11778942174384eff509db56f.tar.gz dexon-solidity-38e79adfe44b7dc11778942174384eff509db56f.tar.zst dexon-solidity-38e79adfe44b7dc11778942174384eff509db56f.zip |
Merge pull request #1662 from ethereum/ipc-safety-checks
Add safety checks to IPC (tests)
-rw-r--r-- | test/RPCSession.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp index 44d21d69..5cd1bc7e 100644 --- a/test/RPCSession.cpp +++ b/test/RPCSession.cpp @@ -75,6 +75,8 @@ IPCSocket::IPCSocket(string const& _path): m_path(_path) BOOST_FAIL("Error connecting to IPC socket: " << _path); m_fp = fdopen(m_socket, "r"); + if (!m_fp) + BOOST_FAIL("Error opening IPC socket: " << _path); #endif } @@ -109,7 +111,9 @@ string IPCSocket::sendRequest(string const& _req) if (!fSuccess) BOOST_FAIL("ReadFile from pipe failed"); - cerr << "."; //Output for log activity + // This is needed for Appveyor, otherwise it may terminate + // the session due to the inactivity. + cerr << "."; return returnStr; #else send(m_socket, _req.c_str(), _req.length(), 0); @@ -187,7 +191,7 @@ string RPCSession::eth_getStorageRoot(string const& _address, string const& _blo void RPCSession::personal_unlockAccount(string const& _address, string const& _password, int _duration) { - rpcCall("personal_unlockAccount", { quote(_address), quote(_password), to_string(_duration) }); + BOOST_REQUIRE(rpcCall("personal_unlockAccount", { quote(_address), quote(_password), to_string(_duration) }) == true); } string RPCSession::personal_newAccount(string const& _password) @@ -231,18 +235,18 @@ void RPCSession::test_setChainParams(vector<string> const& _accounts) void RPCSession::test_setChainParams(string const& _config) { - rpcCall("test_setChainParams", { _config }); + BOOST_REQUIRE(rpcCall("test_setChainParams", { _config }) == true); } void RPCSession::test_rewindToBlock(size_t _blockNr) { - rpcCall("test_rewindToBlock", { to_string(_blockNr) }); + BOOST_REQUIRE(rpcCall("test_rewindToBlock", { to_string(_blockNr) }) == true); } void RPCSession::test_mineBlocks(int _number) { u256 startBlock = fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString())); - rpcCall("test_mineBlocks", { to_string(_number) }, true); + BOOST_REQUIRE(rpcCall("test_mineBlocks", { to_string(_number) }, true) == true); bool mined = false; @@ -281,7 +285,7 @@ void RPCSession::test_mineBlocks(int _number) void RPCSession::test_modifyTimestamp(size_t _timestamp) { - rpcCall("test_modifyTimestamp", { to_string(_timestamp) }); + BOOST_REQUIRE(rpcCall("test_modifyTimestamp", { to_string(_timestamp) }) == true); } Json::Value RPCSession::rpcCall(string const& _methodName, vector<string> const& _args, bool _canFail) @@ -302,7 +306,7 @@ Json::Value RPCSession::rpcCall(string const& _methodName, vector<string> const& //cout << "Reply: " << reply << endl; Json::Value result; - Json::Reader().parse(reply, result, false); + BOOST_REQUIRE(Json::Reader().parse(reply, result, false)); if (result.isMember("error")) { |