24 #include <boost/test/unit_test.hpp> 25 #include <boost/filesystem.hpp> 26 #include <jsonrpccpp/common/exception.h> 55 boost::filesystem::create_directories(tempDir.
path() +
"/keys");
61 WebThreeDirect::composeClientVersion(
"eth"),
71 bool userShouldEnterPassword =
false;
72 string passwordUserWillEnter;
76 [&](
Address) {
if (!userShouldEnterPassword) BOOST_FAIL(
"Password input requested");
return passwordUserWillEnter; },
87 string password =
"12345";
88 string address = personal.personal_newAccount(password);
94 tx[
"to"] = string(
"0x0000000000000000000000000000000000000000");
95 tx[
"value"] = string(
"0x10000");
96 tx[
"value"] = string(
"0x5208");
97 auto sendingShouldFail = [&]() ->
string 101 eth.eth_sendTransaction(tx);
102 BOOST_FAIL(
"Exception expected.");
104 catch (jsonrpc::JsonRpcException
const& _e)
106 return _e.GetMessage();
110 auto sendingShouldSucceed = [&]()
115 BOOST_TEST_CHECKPOINT(
"Account is locked at the start.");
118 BOOST_TEST_CHECKPOINT(
"Unlocking without password should not work.");
119 BOOST_CHECK(!personal.personal_unlockAccount(address,
string(), 2));
122 BOOST_TEST_CHECKPOINT(
"Unlocking with wrong password should not work.");
123 BOOST_CHECK(!personal.personal_unlockAccount(address,
"abcd", 2));
126 BOOST_TEST_CHECKPOINT(
"Unlocking with correct password should work.");
127 BOOST_CHECK(personal.personal_unlockAccount(address, password, 2));
128 sendingShouldSucceed();
129 BOOST_TEST_CHECKPOINT(
"Transaction should be sendable multiple times in unlocked mode.");
130 sendingShouldSucceed();
132 this_thread::sleep_for(chrono::seconds(2));
133 BOOST_TEST_CHECKPOINT(
"After unlock time, account should be locked again.");
136 BOOST_TEST_CHECKPOINT(
"Unlocking again with empty password should not work.");
137 BOOST_CHECK(!personal.personal_unlockAccount(address,
string(), 2));
void stopSealing() override
Stop sealing.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
void stopNetwork() override
Stop the network subsystem.
unique_ptr< AccountHolder > accountHolder
eth::Client * ethereum() const
h160 Address
An Ethereum address: 20 bytes.
std::hash for asio::adress
Main API hub for interfacing with Web 3 components.
std::string getDataDir(std::string _prefix="ethereum")
High-level manager of password-encrypted keys for Ethereum.
void setDataDir(std::string const &_dir)
Sets the data dir for the default ("ethereum") prefix.
BOOST_AUTO_TEST_CASE(Personal)
JSON-RPC api implementation.
#define BOOST_FIXTURE_TEST_SUITE(a, b)
std::string const & path() const
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_AUTO_TEST_SUITE_END()
struct evm_uint160be address(struct evm_env *env)
temporary directory implementation It creates temporary directory in the given path.
Helper functions to work with json::spirit and test files.
#define BOOST_CHECK(expr)