mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1662 from ethereum/ipc-safety-checks
Add safety checks to IPC (tests)
This commit is contained in:
commit
38e79adfe4
@ -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"))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user