Having the test client use the server's io_service.

This commit is contained in:
clemahieu 2016-04-18 18:03:12 -05:00
commit 2e915ddea7

View file

@ -8,10 +8,10 @@
#include <boost/property_tree/json_parser.hpp>
#include <boost/thread.hpp>
std::pair <boost::property_tree::ptree, boost::network::http::server <rai::rpc>::response::status_type> test_response (boost::property_tree::ptree const & request_a, rai::rpc & rpc_a)
std::pair <boost::property_tree::ptree, boost::network::http::server <rai::rpc>::response::status_type> test_response (boost::property_tree::ptree const & request_a, rai::rpc & rpc_a, boost::shared_ptr <boost::asio::io_service> service_a)
{
std::pair <boost::property_tree::ptree, boost::network::http::server <rai::rpc>::response::status_type> result;
boost::network::http::client client;
boost::network::http::client client (boost::network::http::client::options ().io_service (service_a));
auto url ("http://[::1]:" + std::to_string (rpc_a.config.port));
boost::network::http::client::request request (url);
std::string request_string;
@ -49,7 +49,7 @@ TEST (rpc, account_balance)
boost::property_tree::ptree request;
request.put ("action", "account_balance");
request.put ("account", rai::test_genesis_key.pub.to_account ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string balance_text (response.first.get <std::string> ("balance"));
ASSERT_EQ ("340282366920938463463374607431768211455", balance_text);
@ -67,7 +67,7 @@ TEST (rpc, account_create)
boost::property_tree::ptree request;
request.put ("action", "account_create");
request.put ("wallet", system.nodes [0]->wallets.items.begin ()->first.to_string ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto account_text (response.first.get <std::string> ("account"));
rai::uint256_union account;
@ -92,7 +92,7 @@ TEST (rpc, account_weight)
boost::property_tree::ptree request;
request.put ("action", "account_weight");
request.put ("account", key.pub.to_account ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string balance_text (response.first.get <std::string> ("weight"));
ASSERT_EQ ("340282366920938463463374607431768211455", balance_text);
@ -114,7 +114,7 @@ TEST (rpc, wallet_contains)
request.put ("wallet", wallet);
request.put ("action", "wallet_contains");
request.put ("account", rai::test_genesis_key.pub.to_account ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string exists_text (response.first.get <std::string> ("exists"));
ASSERT_EQ ("1", exists_text);
@ -135,7 +135,7 @@ TEST (rpc, wallet_doesnt_contain)
request.put ("wallet", wallet);
request.put ("action", "wallet_contains");
request.put ("account", rai::test_genesis_key.pub.to_account ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string exists_text (response.first.get <std::string> ("exists"));
ASSERT_EQ ("0", exists_text);
@ -154,7 +154,7 @@ TEST (rpc, validate_account_number)
boost::property_tree::ptree request;
request.put ("action", "validate_account_number");
request.put ("account", rai::test_genesis_key.pub.to_account ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
std::string exists_text (response.first.get <std::string> ("valid"));
ASSERT_EQ ("1", exists_text);
rpc.stop();
@ -175,7 +175,7 @@ TEST (rpc, validate_account_invalid)
boost::property_tree::ptree request;
request.put ("action", "validate_account_number");
request.put ("account", account);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string exists_text (response.first.get <std::string> ("valid"));
ASSERT_EQ ("0", exists_text);
@ -209,7 +209,7 @@ TEST (rpc, send)
ASSERT_LT (iterations, 200);
}
});
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string block_text (response.first.get <std::string> ("block"));
rai::block_hash block;
@ -246,7 +246,7 @@ TEST (rpc, send_fail)
ASSERT_LT (iterations, 200);
}
});
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
done = true;
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string block_text (response.first.get <std::string> ("block"));
@ -267,7 +267,7 @@ TEST (rpc, stop)
std::thread thread1 ([&rpc] () {rpc.server.run();});
boost::property_tree::ptree request;
request.put ("action", "stop");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_FALSE (system.nodes [0]->network.on);
rpc.stop ();
thread1.join ();
@ -290,7 +290,7 @@ TEST (rpc, wallet_add)
request.put ("wallet", wallet);
request.put ("action", "wallet_add");
request.put ("key", key_text);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string account_text1 (response.first.get <std::string> ("account"));
ASSERT_EQ (account_text1, key1.pub.to_account ());
@ -310,7 +310,7 @@ TEST (rpc, wallet_password_valid)
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
request.put ("wallet", wallet);
request.put ("action", "password_valid");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string account_text1 (response.first.get <std::string> ("valid"));
ASSERT_EQ (account_text1, "1");
@ -331,7 +331,7 @@ TEST (rpc, wallet_password_change)
request.put ("wallet", wallet);
request.put ("action", "password_change");
request.put ("password", "test");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string account_text1 (response.first.get <std::string> ("changed"));
ASSERT_EQ (account_text1, "1");
@ -367,7 +367,7 @@ TEST (rpc, wallet_password_enter)
request.put ("wallet", wallet);
request.put ("action", "password_enter");
request.put ("password", "");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string account_text1 (response.first.get <std::string> ("valid"));
ASSERT_EQ (account_text1, "1");
@ -387,7 +387,7 @@ TEST (rpc, representative)
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
request.put ("wallet", wallet);
request.put ("action", "representative");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string account_text1 (response.first.get <std::string> ("representative"));
ASSERT_EQ (account_text1, rai::genesis_account.to_account ());
@ -409,7 +409,7 @@ TEST (rpc, representative_set)
rai::keypair key;
request.put ("action", "representative_set");
request.put ("representative", key.pub.to_account ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
ASSERT_EQ (key.pub, system.nodes [0]->wallets.items.begin ()->second->store.representative (transaction));
@ -432,7 +432,7 @@ TEST (rpc, account_list)
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
request.put ("wallet", wallet);
request.put ("action", "account_list");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & accounts_node (response.first.get_child ("accounts"));
std::vector <rai::uint256_union> accounts;
@ -465,7 +465,7 @@ TEST (rpc, wallet_key_valid)
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
request.put ("wallet", wallet);
request.put ("action", "wallet_key_valid");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string exists_text (response.first.get <std::string> ("valid"));
ASSERT_EQ ("1", exists_text);
@ -482,7 +482,7 @@ TEST (rpc, wallet_create)
std::thread thread1 ([&rpc] () {rpc.server.run();});
boost::property_tree::ptree request;
request.put ("action", "wallet_create");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string wallet_text (response.first.get <std::string> ("wallet"));
rai::uint256_union wallet_id;
@ -503,7 +503,7 @@ TEST (rpc, wallet_export)
boost::property_tree::ptree request;
request.put ("action", "wallet_export");
request.put ("wallet", system.nodes [0]->wallets.items.begin ()->first.to_string ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string wallet_json (response.first.get <std::string> ("json"));
bool error (false);
@ -528,7 +528,7 @@ TEST (rpc, wallet_destroy)
boost::property_tree::ptree request;
request.put ("action", "wallet_destroy");
request.put ("wallet", wallet_id.to_string ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
ASSERT_EQ (system.nodes [0]->wallets.items.end (), system.nodes [0]->wallets.items.find (wallet_id));
rpc.stop();
@ -558,7 +558,7 @@ TEST (rpc, account_move)
entry.put ("", key.pub.to_string ());
keys.push_back (std::make_pair ("", entry));
request.add_child ("accounts", keys);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
ASSERT_EQ ("1", response.first.get <std::string> ("moved"));
ASSERT_TRUE (destination->exists (key.pub));
@ -579,7 +579,7 @@ TEST (rpc, block)
boost::property_tree::ptree request;
request.put ("action", "block");
request.put ("hash", system.nodes [0]->latest (rai::genesis_account).to_string ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto contents (response.first.get <std::string> ("contents"));
ASSERT_FALSE (contents.empty ());
@ -598,7 +598,7 @@ TEST (rpc, block_account)
boost::property_tree::ptree request;
request.put ("action", "block_account");
request.put ("hash", genesis.hash ().to_string ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
std::string account_text (response.first.get <std::string> ("account"));
rai::account account;
@ -624,7 +624,7 @@ TEST (rpc, chain)
request.put ("action", "chain");
request.put ("block", block->hash().to_string ());
request.put ("count", std::to_string (std::numeric_limits <uint64_t>::max ()));
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & blocks_node (response.first.get_child ("blocks"));
std::vector <rai::block_hash> blocks;
@ -656,7 +656,7 @@ TEST (rpc, chain_limit)
request.put ("action", "chain");
request.put ("block", block->hash().to_string ());
request.put ("count", 1);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & blocks_node (response.first.get_child ("blocks"));
std::vector <rai::block_hash> blocks;
@ -692,7 +692,7 @@ TEST (rpc, frontier)
request.put ("action", "frontiers");
request.put ("account", rai::account (0).to_account ());
request.put ("count", std::to_string (std::numeric_limits <uint64_t>::max ()));
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & frontiers_node (response.first.get_child ("frontiers"));
std::unordered_map <rai::account, rai::block_hash> frontiers;
@ -732,7 +732,7 @@ TEST (rpc, frontier_limited)
request.put ("action", "frontiers");
request.put ("account", rai::account (0).to_account ());
request.put ("count", std::to_string (100));
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & frontiers_node (response.first.get_child ("frontiers"));
ASSERT_EQ (100, frontiers_node.size ());
@ -762,7 +762,7 @@ TEST (rpc, frontier_startpoint)
request.put ("action", "frontiers");
request.put ("account", source.begin ()->first.to_account ());
request.put ("count", std::to_string (1));
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & frontiers_node (response.first.get_child ("frontiers"));
ASSERT_EQ (1, frontiers_node.size ());
@ -789,7 +789,7 @@ TEST (rpc, history)
request.put ("action", "history");
request.put ("hash", receive->hash().to_string ());
request.put ("count", 100);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & history_node (response.first.get_child ("history"));
ASSERT_EQ (3, history_node.size ());
@ -831,7 +831,7 @@ TEST (rpc, history_count)
request.put ("action", "history");
request.put ("hash", receive->hash().to_string ());
request.put ("count", 1);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & history_node (response.first.get_child ("history"));
ASSERT_EQ (1, history_node.size ());
@ -855,7 +855,7 @@ TEST (rpc, process_block)
std::string json;
send.serialize_json (json);
request.put ("block", json);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
ASSERT_EQ (send.hash (), system.nodes [0]->latest (rai::test_genesis_key.pub));
rpc.stop();
@ -880,7 +880,7 @@ TEST (rpc, keepalive)
request.put ("port", port);
ASSERT_FALSE (system.nodes [0]->peers.known_peer (node1->network.endpoint ()));
ASSERT_EQ (0, system.nodes [0]->peers.size());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto iterations (0);
while (!system.nodes [0]->peers.known_peer (node1->network.endpoint ()))
@ -909,7 +909,7 @@ TEST (rpc, payment_init)
boost::property_tree::ptree request;
request.put ("action", "payment_init");
request.put ("wallet", wallet_id.pub.to_string ());
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
ASSERT_EQ ("Ready", response.first.get <std::string> ("status"));
rpc.stop();
@ -931,7 +931,7 @@ TEST (rpc, payment_begin_end)
boost::property_tree::ptree request1;
request1.put ("action", "payment_begin");
request1.put ("wallet", wallet_id.pub.to_string ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
auto account_text (response1.first.get <std::string> ("account"));
rai::uint256_union account;
@ -953,7 +953,7 @@ TEST (rpc, payment_begin_end)
request2.put ("action", "payment_end");
request2.put ("wallet", wallet_id.pub.to_string ());
request2.put ("account", account.to_account ());
auto response2 (test_response (request2, rpc));
auto response2 (test_response (request2, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response2.second);
ASSERT_TRUE (wallet->exists (account));
ASSERT_NE (wallet->free_accounts.end (), wallet->free_accounts.find (account));
@ -977,7 +977,7 @@ TEST (rpc, payment_end_nonempty)
request1.put ("action", "payment_end");
request1.put ("wallet", wallet_id.to_string ());
request1.put ("account", rai::test_genesis_key.pub.to_account ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::bad_request, response1.second);
rpc.stop();
thread1.join();
@ -998,7 +998,7 @@ TEST (rpc, payment_zero_balance)
boost::property_tree::ptree request1;
request1.put ("action", "payment_begin");
request1.put ("wallet", wallet_id.to_string ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
auto account_text (response1.first.get <std::string> ("account"));
rai::uint256_union account;
@ -1023,7 +1023,7 @@ TEST (rpc, payment_begin_reuse)
boost::property_tree::ptree request1;
request1.put ("action", "payment_begin");
request1.put ("wallet", wallet_id.pub.to_string ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
auto account_text (response1.first.get <std::string> ("account"));
rai::uint256_union account;
@ -1034,11 +1034,11 @@ TEST (rpc, payment_begin_reuse)
request2.put ("action", "payment_end");
request2.put ("wallet", wallet_id.pub.to_string ());
request2.put ("account", account.to_account ());
auto response2 (test_response (request2, rpc));
auto response2 (test_response (request2, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response2.second);
ASSERT_TRUE (wallet->exists (account));
ASSERT_NE (wallet->free_accounts.end (), wallet->free_accounts.find (account));
auto response3 (test_response (request1, rpc));
auto response3 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response3.second);
auto account2_text (response1.first.get <std::string> ("account"));
rai::uint256_union account2;
@ -1068,7 +1068,7 @@ TEST (rpc, payment_begin_locked)
boost::property_tree::ptree request1;
request1.put ("action", "payment_begin");
request1.put ("wallet", wallet_id.pub.to_string ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::bad_request, response1.second);
rpc.stop();
thread1.join();
@ -1092,7 +1092,7 @@ TEST (rpc, DISABLED_payment_wait)
request1.put ("account", key.pub.to_account ());
request1.put ("amount", rai::amount (rai::Mrai_ratio).to_string_dec ());
request1.put ("timeout", "100");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("nothing", response1.first.get <std::string> ("status"));
request1.put ("timeout", "100000");
@ -1101,11 +1101,11 @@ TEST (rpc, DISABLED_payment_wait)
{
system.wallet (0)->send_action (rai::test_genesis_key.pub, key.pub, rai::Mrai_ratio);
});
auto response2 (test_response (request1, rpc));
auto response2 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response2.second);
ASSERT_EQ ("success", response2.first.get <std::string> ("status"));
request1.put ("amount", rai::amount (rai::Mrai_ratio * 2).to_string_dec ());
auto response3 (test_response (request1, rpc));
auto response3 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response3.second);
ASSERT_EQ ("success", response2.first.get <std::string> ("status"));
node1->stop ();
@ -1123,7 +1123,7 @@ TEST (rpc, peers)
std::thread thread1 ([&rpc] () {rpc.server.run();});
boost::property_tree::ptree request;
request.put ("action", "peers");
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto & frontiers_node (response.first.get_child ("peers"));
ASSERT_EQ (1, frontiers_node.size ());
@ -1169,7 +1169,7 @@ TEST (rpc, search_pending)
boost::property_tree::ptree request;
request.put ("action", "search_pending");
request.put ("wallet", wallet);
auto response (test_response (request, rpc));
auto response (test_response (request, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.second);
auto iterations (0);
while (system.nodes [0]->balance (rai::test_genesis_key.pub) != rai::genesis_amount)
@ -1196,7 +1196,7 @@ TEST (rpc, version)
std::thread thread1 ([&rpc] () {rpc.server.run();});
boost::property_tree::ptree request1;
request1.put ("action", "version");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("1", response1.first.get <std::string> ("rpc_version"));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
@ -1221,7 +1221,7 @@ TEST (rpc, work_generate)
boost::property_tree::ptree request1;
request1.put ("action", "work_generate");
request1.put ("hash", hash1.to_string ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
auto work1 (response1.first.get <std::string> ("work"));
uint64_t work2;
@ -1252,7 +1252,7 @@ TEST (rpc, work_cancel)
{
work = system.work.generate_maybe (hash1);
});
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
thread.join ();
rpc.stop();
@ -1379,7 +1379,7 @@ TEST (rpc, block_count)
std::thread thread1 ([&rpc] () {rpc.server.run();});
boost::property_tree::ptree request1;
request1.put ("action", "block_count");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("1", response1.first.get <std::string> ("count"));
rpc.stop ();
@ -1398,7 +1398,7 @@ TEST (rpc, frontier_count)
std::thread thread1 ([&rpc] () {rpc.server.run();});
boost::property_tree::ptree request1;
request1.put ("action", "frontier_count");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("1", response1.first.get <std::string> ("count"));
rpc.stop ();
@ -1417,13 +1417,13 @@ TEST (rpc, available_supply)
std::thread thread1 ([&rpc] () {rpc.server.run();});
boost::property_tree::ptree request1;
request1.put ("action", "available_supply");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("0", response1.first.get <std::string> ("available"));
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
rai::keypair key;
auto block (system.wallet (0)->send_action (rai::test_genesis_key.pub, key.pub, 1));
auto response2 (test_response (request1, rpc));
auto response2 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response2.second);
ASSERT_EQ ("1", response2.first.get <std::string> ("available"));
rpc.stop ();
@ -1443,7 +1443,7 @@ TEST (rpc, mrai_to_raw)
boost::property_tree::ptree request1;
request1.put ("action", "mrai_to_raw");
request1.put ("amount", "1");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ (rai::Mrai_ratio.convert_to <std::string> (), response1.first.get <std::string> ("amount"));
rpc.stop ();
@ -1463,7 +1463,7 @@ TEST (rpc, mrai_from_raw)
boost::property_tree::ptree request1;
request1.put ("action", "mrai_from_raw");
request1.put ("amount", rai::Mrai_ratio.convert_to <std::string> ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("1", response1.first.get <std::string> ("amount"));
rpc.stop ();
@ -1483,7 +1483,7 @@ TEST (rpc, krai_to_raw)
boost::property_tree::ptree request1;
request1.put ("action", "krai_to_raw");
request1.put ("amount", "1");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ (rai::krai_ratio.convert_to <std::string> (), response1.first.get <std::string> ("amount"));
rpc.stop ();
@ -1503,7 +1503,7 @@ TEST (rpc, krai_from_raw)
boost::property_tree::ptree request1;
request1.put ("action", "krai_from_raw");
request1.put ("amount", rai::krai_ratio.convert_to <std::string> ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("1", response1.first.get <std::string> ("amount"));
rpc.stop ();
@ -1523,7 +1523,7 @@ TEST (rpc, rai_to_raw)
boost::property_tree::ptree request1;
request1.put ("action", "rai_to_raw");
request1.put ("amount", "1");
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ (rai::rai_ratio.convert_to <std::string> (), response1.first.get <std::string> ("amount"));
rpc.stop ();
@ -1543,7 +1543,7 @@ TEST (rpc, rai_from_raw)
boost::property_tree::ptree request1;
request1.put ("action", "rai_from_raw");
request1.put ("amount", rai::rai_ratio.convert_to <std::string> ());
auto response1 (test_response (request1, rpc));
auto response1 (test_response (request1, rpc, system.service));
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response1.second);
ASSERT_EQ ("1", response1.first.get <std::string> ("amount"));
rpc.stop ();