Renaming client to node since we're all peers.
This commit is contained in:
parent
469f062c8a
commit
470903a9c0
23 changed files with 762 additions and 762 deletions
|
@ -37,9 +37,9 @@ add_library (secure
|
|||
rai/secure.cpp
|
||||
)
|
||||
|
||||
add_library (core
|
||||
rai/core/core.hpp
|
||||
rai/core/core.cpp
|
||||
add_library (node
|
||||
rai/node.hpp
|
||||
rai/node.cpp
|
||||
ed25519-donna/ed25519-hash-custom.h
|
||||
ed25519-donna/ed25519-randombytes-custom.h
|
||||
ed25519-donna/ed25519.h
|
||||
|
@ -50,7 +50,7 @@ add_executable (core_test
|
|||
rai/core_test/block.cpp
|
||||
rai/core_test/block_store.cpp
|
||||
rai/core_test/block_synchronization.cpp
|
||||
rai/core_test/client.cpp
|
||||
rai/core_test/node.cpp
|
||||
rai/core_test/conflicts.cpp
|
||||
rai/core_test/daemon.cpp
|
||||
rai/core_test/entry.cpp
|
||||
|
@ -68,7 +68,7 @@ add_executable (core_test
|
|||
)
|
||||
|
||||
add_executable (slow_test
|
||||
rai/slow_test/client.cpp)
|
||||
rai/slow_test/node.cpp)
|
||||
|
||||
add_executable (qt_test
|
||||
rai/qt_test/qt.cpp)
|
||||
|
@ -98,7 +98,7 @@ set (CPACK_PACKAGE_VERSION_PATCH "0")
|
|||
SET (ACTIVE_NETWORK rai_active_network CACHE STRING "Selects which network parameters are used")
|
||||
set_property (CACHE ACTIVE_NETWORK PROPERTY STRINGS rai_test_network rai_beta_network rai_live_network)
|
||||
|
||||
set_target_properties (secure core core_test slow_test qt_test cli qt qt_client qt_system landing PROPERTIES COMPILE_FLAGS "-std=c++11 -Werror=switch ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DED25519_CUSTOMHASH -DED25519_CUSTOMRNG -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DRAIBLOCKS_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set_target_properties (secure node core_test slow_test qt_test cli qt qt_client qt_system landing PROPERTIES COMPILE_FLAGS "-std=c++11 -Werror=switch ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DED25519_CUSTOMHASH -DED25519_CUSTOMRNG -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DRAIBLOCKS_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set_target_properties (qt_client qt_test PROPERTIES LINK_FLAGS "${PLATFORM_GUI_EXE_LINK_FLAGS}")
|
||||
|
||||
if (WIN32)
|
||||
|
@ -107,19 +107,19 @@ else (WIN32)
|
|||
set (PLATFORM_LIBS)
|
||||
endif (WIN32)
|
||||
|
||||
target_link_libraries (core_test core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
target_link_libraries (core_test node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
|
||||
target_link_libraries (slow_test core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
target_link_libraries (slow_test node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
|
||||
target_link_libraries (cli core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
target_link_libraries (cli node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
|
||||
target_link_libraries (landing core secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
target_link_libraries (landing node secure ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
|
||||
target_link_libraries (qt_test core secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
target_link_libraries (qt_test node secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
|
||||
target_link_libraries (qt_client core secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
target_link_libraries (qt_client node secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
|
||||
target_link_libraries (qt_system core secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
target_link_libraries (qt_system node secure qt ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${GTEST_MAIN_LIBRARY} ${GTEST_LIBRARY} ${CRYPTOPP_LIBRARY} ${CPPNETLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Widgets ${QT_QTGUI_LIBRARY} pthread ${PLATFORM_LIBS} ${LevelDB_LIBRARY})
|
||||
|
||||
if (APPLE)
|
||||
get_filename_component (Qt5Core_framework_DIR ${Qt5_DIR}/../../QtCore.framework ABSOLUTE)
|
||||
|
|
|
@ -105,8 +105,8 @@ void rai_daemon::daemon::run (int argc, char * const * argv)
|
|||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::processor_service processor;
|
||||
rai::client_init init;
|
||||
auto client (std::make_shared <rai::client> (init, service, config.peering_port, working, processor));
|
||||
rai::node_init init;
|
||||
auto client (std::make_shared <rai::node> (init, service, config.peering_port, working, processor));
|
||||
if (!init.error ())
|
||||
{
|
||||
client->bootstrap_peers = config.bootstrap_peers;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <rai/core/core.hpp>
|
||||
#include <rai/node.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <rai/core/core.hpp>
|
||||
#include <rai/node.hpp>
|
||||
#include <rai/cli/daemon.hpp>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
@ -129,7 +129,7 @@ int main (int argc, char * const * argv)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
size_t count (10000);
|
||||
system.generate_mass_activity (count, *system.clients [0]);
|
||||
system.generate_mass_activity (count, *system.nodes [0]);
|
||||
}
|
||||
else if (vm.count ("generate_key"))
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
TEST (conflicts, start_stop)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
@ -31,7 +31,7 @@ TEST (conflicts, start_stop)
|
|||
TEST (conflicts, add_existing)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
@ -67,7 +67,7 @@ TEST (conflicts, add_existing)
|
|||
TEST (conflicts, add_two)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
TEST (gap_cache, add_new)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::gap_cache cache (*system.clients [0]);
|
||||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1;
|
||||
cache.add (rai::send_block (block1), block1.previous ());
|
||||
ASSERT_NE (cache.blocks.end (), cache.blocks.find (block1.previous ()));
|
||||
|
@ -13,7 +13,7 @@ TEST (gap_cache, add_new)
|
|||
TEST (gap_cache, add_existing)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::gap_cache cache (*system.clients [0]);
|
||||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1;
|
||||
auto previous (block1.previous ());
|
||||
cache.add (block1, previous);
|
||||
|
@ -31,7 +31,7 @@ TEST (gap_cache, add_existing)
|
|||
TEST (gap_cache, comparison)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::gap_cache cache (*system.clients [0]);
|
||||
rai::gap_cache cache (*system.nodes [0]);
|
||||
rai::send_block block1;
|
||||
block1.hashables.previous.clear ();
|
||||
auto previous1 (block1.previous ());
|
||||
|
@ -54,7 +54,7 @@ TEST (gap_cache, comparison)
|
|||
TEST (gap_cache, limit)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::gap_cache cache (*system.clients [0]);
|
||||
rai::gap_cache cache (*system.nodes [0]);
|
||||
for (auto i (0); i < cache.max * 2; ++i)
|
||||
{
|
||||
rai::send_block block1;
|
||||
|
@ -69,7 +69,7 @@ TEST (gap_cache, gap_bootstrap)
|
|||
{
|
||||
rai::system system (24000, 2);
|
||||
auto iterations1 (0);
|
||||
while (system.clients [0]->bootstrap_initiator.in_progress || system.clients [1]->bootstrap_initiator.in_progress)
|
||||
while (system.nodes [0]->bootstrap_initiator.in_progress || system.nodes [1]->bootstrap_initiator.in_progress)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -80,19 +80,19 @@ TEST (gap_cache, gap_bootstrap)
|
|||
rai::send_block send;
|
||||
send.hashables.balance = std::numeric_limits <rai::uint128_t>::max () - 100;
|
||||
send.hashables.destination = key.pub;
|
||||
send.hashables.previous = system.clients [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
system.clients [0]->work_create (send);
|
||||
send.hashables.previous = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
system.nodes [0]->work_create (send);
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send.hash (), send.signature);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients [0]->processor.process_receive (send));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 100, system.clients [0]->ledger.account_balance (rai::genesis_account));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), system.clients [1]->ledger.account_balance (rai::genesis_account));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->processor.process_receive (send));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 100, system.nodes [0]->ledger.account_balance (rai::genesis_account));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), system.nodes [1]->ledger.account_balance (rai::genesis_account));
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
system.wallet (0)->store.insert (key.prv);
|
||||
system.wallet (0)->send (key.pub, 100);
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 200, system.clients [0]->ledger.account_balance (rai::genesis_account));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), system.clients [1]->ledger.account_balance (rai::genesis_account));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 200, system.nodes [0]->ledger.account_balance (rai::genesis_account));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), system.nodes [1]->ledger.account_balance (rai::genesis_account));
|
||||
auto iterations2 (0);
|
||||
while (system.clients [1]->ledger.account_balance (rai::genesis_account) != std::numeric_limits <rai::uint128_t>::max () - 200)
|
||||
while (system.nodes [1]->ledger.account_balance (rai::genesis_account) != std::numeric_limits <rai::uint128_t>::max () - 200)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
|
|
@ -76,7 +76,7 @@ TEST (ledger, checksum_persistence)
|
|||
TEST (system, system_genesis)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
for (auto & i: system.clients)
|
||||
for (auto & i: system.nodes)
|
||||
{
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), i->ledger.account_balance (rai::genesis_account));
|
||||
}
|
||||
|
@ -578,13 +578,13 @@ TEST (system, generate_send_existing)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::frontier frontier1;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
system.generate_send_existing (*system.clients [0]);
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
system.generate_send_existing (*system.nodes [0]);
|
||||
rai::frontier frontier2;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier2));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier2));
|
||||
ASSERT_NE (frontier1.hash, frontier2.hash);
|
||||
auto iterations1 (0);
|
||||
while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) == std::numeric_limits <rai::uint128_t>::max ())
|
||||
while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) == std::numeric_limits <rai::uint128_t>::max ())
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -592,7 +592,7 @@ TEST (system, generate_send_existing)
|
|||
ASSERT_LT (iterations1, 20);
|
||||
}
|
||||
auto iterations2 (0);
|
||||
while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits <rai::uint128_t>::max ())
|
||||
while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits <rai::uint128_t>::max ())
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -605,10 +605,10 @@ TEST (system, generate_send_new)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
auto iterator1 (system.clients [0]->store.latest_begin ());
|
||||
auto iterator1 (system.nodes [0]->store.latest_begin ());
|
||||
++iterator1;
|
||||
ASSERT_EQ (system.clients [0]->store.latest_end (), iterator1);
|
||||
system.generate_send_new (*system.clients [0]);
|
||||
ASSERT_EQ (system.nodes [0]->store.latest_end (), iterator1);
|
||||
system.generate_send_new (*system.nodes [0]);
|
||||
rai::account new_account;
|
||||
auto iterator2 (system.wallet (0)->store.begin ());
|
||||
if (iterator2->first != rai::test_genesis_key.pub)
|
||||
|
@ -624,7 +624,7 @@ TEST (system, generate_send_new)
|
|||
++iterator2;
|
||||
ASSERT_EQ (system.wallet (0)->store.end (), iterator2);
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->ledger.account_balance (new_account) == 0)
|
||||
while (system.nodes [0]->ledger.account_balance (new_account) == 0)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -795,7 +795,7 @@ TEST (ledegr, double_receive)
|
|||
TEST (votes, add_unsigned)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
@ -819,7 +819,7 @@ TEST (votes, add_unsigned)
|
|||
TEST (votes, add_one)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
@ -849,7 +849,7 @@ TEST (votes, add_one)
|
|||
TEST (votes, add_two)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
@ -890,7 +890,7 @@ TEST (votes, add_two)
|
|||
TEST (votes, add_existing)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
@ -929,7 +929,7 @@ TEST (votes, add_existing)
|
|||
TEST (votes, add_old)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block send1;
|
||||
rai::keypair key1;
|
||||
|
@ -975,17 +975,17 @@ TEST (ledger, successor)
|
|||
send1.hashables.balance.clear ();
|
||||
send1.hashables.destination = key1.pub;
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send1.hash (), send1.signature);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (send1));
|
||||
ASSERT_EQ (send1, *system.clients [0]->ledger.successor (genesis.hash ()));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (send1));
|
||||
ASSERT_EQ (send1, *system.nodes [0]->ledger.successor (genesis.hash ()));
|
||||
}
|
||||
|
||||
TEST (fork, publish)
|
||||
{
|
||||
std::weak_ptr <rai::client> client0;
|
||||
std::weak_ptr <rai::node> client0;
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
client0 = system.clients [0];
|
||||
auto & client1 (*system.clients [0]);
|
||||
client0 = system.nodes [0];
|
||||
auto & client1 (*system.nodes [0]);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::keypair key1;
|
||||
rai::genesis genesis;
|
||||
|
@ -1032,8 +1032,8 @@ TEST (fork, publish)
|
|||
TEST (ledger, fork_keep)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client2 (*system.clients [1]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
auto & client2 (*system.nodes [1]);
|
||||
ASSERT_EQ (1, client1.peers.size ());
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::keypair key1;
|
||||
|
@ -1068,8 +1068,8 @@ TEST (ledger, fork_keep)
|
|||
auto votes1 (conflict->second);
|
||||
ASSERT_NE (nullptr, votes1);
|
||||
ASSERT_EQ (1, votes1->votes.rep_votes.size ());
|
||||
ASSERT_TRUE (system.clients [0]->store.block_exists (publish1.block->hash ()));
|
||||
ASSERT_TRUE (system.clients [1]->store.block_exists (publish1.block->hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (publish1.block->hash ()));
|
||||
ASSERT_TRUE (system.nodes [1]->store.block_exists (publish1.block->hash ()));
|
||||
auto iterations (0);
|
||||
while (votes1->votes.rep_votes.size () == 1)
|
||||
{
|
||||
|
@ -1081,15 +1081,15 @@ TEST (ledger, fork_keep)
|
|||
auto winner (client1.ledger.winner (votes1->votes));
|
||||
ASSERT_EQ (*publish1.block, *winner.second);
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), winner.first);
|
||||
ASSERT_TRUE (system.clients [0]->store.block_exists (publish1.block->hash ()));
|
||||
ASSERT_TRUE (system.clients [1]->store.block_exists (publish1.block->hash ()));
|
||||
ASSERT_TRUE (system.nodes [0]->store.block_exists (publish1.block->hash ()));
|
||||
ASSERT_TRUE (system.nodes [1]->store.block_exists (publish1.block->hash ()));
|
||||
}
|
||||
|
||||
TEST (ledger, fork_flip)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client2 (*system.clients [1]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
auto & client2 (*system.nodes [1]);
|
||||
ASSERT_EQ (1, client1.peers.size ());
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::keypair key1;
|
||||
|
@ -1145,8 +1145,8 @@ TEST (ledger, fork_flip)
|
|||
TEST (ledger, fork_multi_flip)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client2 (*system.clients [1]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
auto & client2 (*system.nodes [1]);
|
||||
ASSERT_EQ (1, client1.peers.size ());
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::keypair key1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <rai/core/core.hpp>
|
||||
#include <rai/node.hpp>
|
||||
|
||||
TEST (message, keepalive_serialization)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ TEST (message_parser, exact_confirm_ack_size)
|
|||
rai::message_parser parser (visitor);
|
||||
auto block (std::unique_ptr <rai::send_block> (new rai::send_block));
|
||||
block->hashables.previous = 1;
|
||||
system.clients [0]->work_create (*block);
|
||||
system.nodes [0]->work_create (*block);
|
||||
rai::confirm_ack message (std::move (block));
|
||||
std::vector <uint8_t> bytes;
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ TEST (message_parser, exact_confirm_req_size)
|
|||
rai::message_parser parser (visitor);
|
||||
auto block (std::unique_ptr <rai::send_block> (new rai::send_block));
|
||||
block->hashables.previous = 1;
|
||||
system.clients [0]->work_create (*block);
|
||||
system.nodes [0]->work_create (*block);
|
||||
rai::confirm_req message (std::move (block));
|
||||
std::vector <uint8_t> bytes;
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ TEST (message_parser, exact_publish_size)
|
|||
rai::message_parser parser (visitor);
|
||||
auto block (std::unique_ptr <rai::send_block> (new rai::send_block));
|
||||
block->hashables.previous = 1;
|
||||
system.clients [0]->work_create (*block);
|
||||
system.nodes [0]->work_create (*block);
|
||||
rai::publish message (std::move (block));
|
||||
std::vector <uint8_t> bytes;
|
||||
{
|
||||
|
|
|
@ -48,59 +48,59 @@ TEST (network, tcp_connection)
|
|||
TEST (network, construction)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
ASSERT_EQ (1, system.clients.size ());
|
||||
ASSERT_EQ (24000, system.clients [0]->network.socket.local_endpoint ().port ());
|
||||
ASSERT_EQ (1, system.nodes.size ());
|
||||
ASSERT_EQ (24000, system.nodes [0]->network.socket.local_endpoint ().port ());
|
||||
}
|
||||
|
||||
TEST (network, self_discard)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
system.clients [0]->network.remote = system.clients [0]->network.endpoint ();
|
||||
ASSERT_EQ (0, system.clients [0]->network.bad_sender_count);
|
||||
system.clients [0]->network.receive_action (boost::system::error_code {}, 0);
|
||||
ASSERT_EQ (1, system.clients [0]->network.bad_sender_count);
|
||||
system.nodes [0]->network.remote = system.nodes [0]->network.endpoint ();
|
||||
ASSERT_EQ (0, system.nodes [0]->network.bad_sender_count);
|
||||
system.nodes [0]->network.receive_action (boost::system::error_code {}, 0);
|
||||
ASSERT_EQ (1, system.nodes [0]->network.bad_sender_count);
|
||||
}
|
||||
|
||||
TEST (network, send_keepalive)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto list1 (system.clients [0]->peers.list ());
|
||||
auto list1 (system.nodes [0]->peers.list ());
|
||||
ASSERT_EQ (0, list1.size ());
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
client1->start ();
|
||||
system.clients [0]->network.send_keepalive (client1->network.endpoint ());
|
||||
auto initial (system.clients [0]->network.keepalive_count);
|
||||
ASSERT_EQ (0, system.clients [0]->peers.list ().size ());
|
||||
system.nodes [0]->network.send_keepalive (client1->network.endpoint ());
|
||||
auto initial (system.nodes [0]->network.keepalive_count);
|
||||
ASSERT_EQ (0, system.nodes [0]->peers.list ().size ());
|
||||
ASSERT_EQ (0, client1->peers.list ().size ());
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->network.keepalive_count == initial)
|
||||
while (system.nodes [0]->network.keepalive_count == initial)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
auto peers1 (system.clients [0]->peers.list ());
|
||||
auto peers1 (system.nodes [0]->peers.list ());
|
||||
auto peers2 (client1->peers.list ());
|
||||
ASSERT_EQ (1, peers1.size ());
|
||||
ASSERT_EQ (1, peers2.size ());
|
||||
ASSERT_NE (peers1.end (), std::find_if (peers1.begin (), peers1.end (), [&client1] (rai::peer_information const & information_a) {return information_a.endpoint == client1->network.endpoint ();}));
|
||||
ASSERT_NE (peers2.end (), std::find_if (peers2.begin (), peers2.end (), [&system] (rai::peer_information const & information_a) {return information_a.endpoint == system.clients [0]->network.endpoint ();}));
|
||||
ASSERT_NE (peers2.end (), std::find_if (peers2.begin (), peers2.end (), [&system] (rai::peer_information const & information_a) {return information_a.endpoint == system.nodes [0]->network.endpoint ();}));
|
||||
client1->stop ();
|
||||
}
|
||||
|
||||
TEST (network, keepalive_ipv4)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto list1 (system.clients [0]->peers.list ());
|
||||
auto list1 (system.nodes [0]->peers.list ());
|
||||
ASSERT_EQ (0, list1.size ());
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
client1->start ();
|
||||
client1->send_keepalive (rai::endpoint (boost::asio::ip::address_v4::loopback (), 24000));
|
||||
auto initial (system.clients [0]->network.keepalive_count);
|
||||
auto initial (system.nodes [0]->network.keepalive_count);
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->network.keepalive_count == initial)
|
||||
while (system.nodes [0]->network.keepalive_count == initial)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
|
@ -112,30 +112,30 @@ TEST (network, keepalive_ipv4)
|
|||
TEST (network, multi_keepalive)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto list1 (system.clients [0]->peers.list ());
|
||||
auto list1 (system.nodes [0]->peers.list ());
|
||||
ASSERT_EQ (0, list1.size ());
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
client1->start ();
|
||||
ASSERT_EQ (0, client1->peers.size ());
|
||||
client1->network.send_keepalive (system.clients [0]->network.endpoint ());
|
||||
client1->network.send_keepalive (system.nodes [0]->network.endpoint ());
|
||||
ASSERT_EQ (0, client1->peers.size ());
|
||||
ASSERT_EQ (0, system.clients [0]->peers.size ());
|
||||
ASSERT_EQ (0, system.nodes [0]->peers.size ());
|
||||
auto iterations1 (0);
|
||||
while (system.clients [0]->peers.size () != 1)
|
||||
while (system.nodes [0]->peers.size () != 1)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations1;
|
||||
ASSERT_LT (iterations1, 200);
|
||||
}
|
||||
rai::client_init init2;
|
||||
auto client2 (std::make_shared <rai::client> (init2, system.service, 24002, system.processor));
|
||||
rai::node_init init2;
|
||||
auto client2 (std::make_shared <rai::node> (init2, system.service, 24002, system.processor));
|
||||
ASSERT_FALSE (init2.error ());
|
||||
client2->start ();
|
||||
client2->network.send_keepalive (system.clients [0]->network.endpoint ());
|
||||
client2->network.send_keepalive (system.nodes [0]->network.endpoint ());
|
||||
auto iterations2 (0);
|
||||
while (client1->peers.size () != 2 || system.clients [0]->peers.size () != 2 || client2->peers.size () != 2)
|
||||
while (client1->peers.size () != 2 || system.nodes [0]->peers.size () != 2 || client2->peers.size () != 2)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations2;
|
||||
|
@ -150,20 +150,20 @@ TEST (network, send_discarded_publish)
|
|||
rai::system system (24000, 2);
|
||||
std::unique_ptr <rai::send_block> block (new rai::send_block);
|
||||
block->hashables.previous = 1;
|
||||
system.clients [0]->work_create (*block);
|
||||
system.clients [0]->network.republish_block (std::move (block));
|
||||
system.nodes [0]->work_create (*block);
|
||||
system.nodes [0]->network.republish_block (std::move (block));
|
||||
rai::genesis genesis;
|
||||
ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
auto iterations (0);
|
||||
while (system.clients [1]->network.publish_count == 0)
|
||||
while (system.nodes [1]->network.publish_count == 0)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (network, send_invalid_publish)
|
||||
|
@ -172,21 +172,21 @@ TEST (network, send_invalid_publish)
|
|||
std::unique_ptr <rai::send_block> block (new rai::send_block);
|
||||
block->hashables.previous = 1;
|
||||
block->hashables.balance = 20;
|
||||
system.clients [0]->work_create (*block);
|
||||
system.nodes [0]->work_create (*block);
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, block->hash (), block->signature);
|
||||
system.clients [0]->network.republish_block (std::move (block));
|
||||
system.nodes [0]->network.republish_block (std::move (block));
|
||||
rai::genesis genesis;
|
||||
ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
auto iterations (0);
|
||||
while (system.clients [1]->network.publish_count == 0)
|
||||
while (system.nodes [1]->network.publish_count == 0)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
ASSERT_EQ (genesis.hash (), system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.clients [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), system.nodes [1]->ledger.latest (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (network, send_valid_confirm_ack)
|
||||
|
@ -197,28 +197,28 @@ TEST (network, send_valid_confirm_ack)
|
|||
system.wallet (1)->store.insert (key2.prv);
|
||||
rai::send_block block2;
|
||||
rai::frontier frontier1;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
block2.hashables.previous = frontier1.hash;
|
||||
block2.hashables.balance = 50;
|
||||
block2.hashables.destination = key2.pub;
|
||||
system.clients [0]->work_create (block2);
|
||||
system.nodes [0]->work_create (block2);
|
||||
auto hash2 (block2.hash ());
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, hash2, block2.signature);
|
||||
rai::frontier frontier2;
|
||||
ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier2));
|
||||
system.clients [0]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (block2)));
|
||||
ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier2));
|
||||
system.nodes [0]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (block2)));
|
||||
auto iterations (0);
|
||||
while (system.clients [1]->network.confirm_ack_count == 0)
|
||||
while (system.nodes [1]->network.confirm_ack_count == 0)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
rai::frontier frontier3;
|
||||
ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier3));
|
||||
ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier3));
|
||||
ASSERT_FALSE (frontier2.hash == frontier3.hash);
|
||||
ASSERT_EQ (hash2, frontier3.hash);
|
||||
ASSERT_EQ (50, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (50, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (network, send_valid_publish)
|
||||
|
@ -229,28 +229,28 @@ TEST (network, send_valid_publish)
|
|||
system.wallet (1)->store.insert (key2.prv);
|
||||
rai::send_block block2;
|
||||
rai::frontier frontier1;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
block2.hashables.previous = frontier1.hash;
|
||||
block2.hashables.balance = 50;
|
||||
block2.hashables.destination = key2.pub;
|
||||
system.clients [0]->work_create (block2);
|
||||
system.nodes [0]->work_create (block2);
|
||||
auto hash2 (block2.hash ());
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, hash2, block2.signature);
|
||||
rai::frontier frontier2;
|
||||
ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier2));
|
||||
system.clients [1]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (block2)));
|
||||
ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier2));
|
||||
system.nodes [1]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (block2)));
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->network.publish_count == 0)
|
||||
while (system.nodes [0]->network.publish_count == 0)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
rai::frontier frontier3;
|
||||
ASSERT_FALSE (system.clients [1]->store.latest_get (rai::test_genesis_key.pub, frontier3));
|
||||
ASSERT_FALSE (system.nodes [1]->store.latest_get (rai::test_genesis_key.pub, frontier3));
|
||||
ASSERT_FALSE (frontier2.hash == frontier3.hash);
|
||||
ASSERT_EQ (hash2, frontier3.hash);
|
||||
ASSERT_EQ (50, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (50, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (network, send_insufficient_work)
|
||||
|
@ -266,23 +266,23 @@ TEST (network, send_insufficient_work)
|
|||
rai::vectorstream stream (*bytes);
|
||||
publish.serialize (stream);
|
||||
}
|
||||
auto client (system.clients [1]->shared ());
|
||||
system.clients [0]->network.send_buffer (bytes->data (), bytes->size (), system.clients [1]->network.endpoint (), [bytes, client] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, system.clients [0]->network.insufficient_work_count);
|
||||
auto client (system.nodes [1]->shared ());
|
||||
system.nodes [0]->network.send_buffer (bytes->data (), bytes->size (), system.nodes [1]->network.endpoint (), [bytes, client] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, system.nodes [0]->network.insufficient_work_count);
|
||||
auto iterations (0);
|
||||
while (system.clients [1]->network.insufficient_work_count == 0)
|
||||
while (system.nodes [1]->network.insufficient_work_count == 0)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
ASSERT_EQ (1, system.clients [1]->network.insufficient_work_count);
|
||||
ASSERT_EQ (1, system.nodes [1]->network.insufficient_work_count);
|
||||
}
|
||||
|
||||
TEST (receivable_processor, confirm_insufficient_pos)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block block1;
|
||||
block1.hashables.previous = genesis.hash ();
|
||||
|
@ -301,7 +301,7 @@ TEST (receivable_processor, confirm_insufficient_pos)
|
|||
TEST (receivable_processor, confirm_sufficient_pos)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client1 (*system.clients [0]);
|
||||
auto & client1 (*system.nodes [0]);
|
||||
rai::genesis genesis;
|
||||
rai::send_block block1;
|
||||
block1.hashables.previous = genesis.hash ();
|
||||
|
@ -326,34 +326,34 @@ TEST (receivable_processor, send_with_receive)
|
|||
system.wallet (1)->store.insert (key2.prv);
|
||||
auto block1 (new rai::send_block ());
|
||||
rai::frontier frontier1;
|
||||
ASSERT_FALSE (system.clients [0]->ledger.store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
ASSERT_FALSE (system.nodes [0]->ledger.store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
block1->hashables.previous = frontier1.hash;
|
||||
block1->hashables.balance = amount - 100;
|
||||
block1->hashables.destination = key2.pub;
|
||||
system.clients [0]->work_create (*block1);
|
||||
system.nodes [0]->work_create (*block1);
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, block1->hash (), block1->signature);
|
||||
ASSERT_EQ (amount, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.clients [0]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.clients [1]->ledger.account_balance (key2.pub));
|
||||
system.clients [0]->processor.process_receive_republish (block1->clone ());
|
||||
system.clients [1]->processor.process_receive_republish (block1->clone ());
|
||||
ASSERT_EQ (amount - 100, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.clients [0]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount - 100, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.clients [1]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [0]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [1]->ledger.account_balance (key2.pub));
|
||||
system.nodes [0]->processor.process_receive_republish (block1->clone ());
|
||||
system.nodes [1]->processor.process_receive_republish (block1->clone ());
|
||||
ASSERT_EQ (amount - 100, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [0]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount - 100, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [1]->ledger.account_balance (key2.pub));
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->ledger.account_balance (key2.pub) != 100)
|
||||
while (system.nodes [0]->ledger.account_balance (key2.pub) != 100)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
ASSERT_EQ (amount - 100, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (100, system.clients [0]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount - 100, system.clients [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (100, system.clients [1]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount - 100, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (100, system.nodes [0]->ledger.account_balance (key2.pub));
|
||||
ASSERT_EQ (amount - 100, system.nodes [1]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (100, system.nodes [1]->ledger.account_balance (key2.pub));
|
||||
}
|
||||
|
||||
TEST (network, receive_weight_change)
|
||||
|
@ -365,7 +365,7 @@ TEST (network, receive_weight_change)
|
|||
system.wallet (1)->store.representative_set (key2.pub);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 2));
|
||||
auto iterations (0);
|
||||
while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr <rai::client> const & client_a) {return client_a->ledger.weight (key2.pub) != 2;}))
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr <rai::node> const & node_a) {return node_a->ledger.weight (key2.pub) != 2;}))
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -428,7 +428,7 @@ TEST (parse_endpoint, no_colon)
|
|||
TEST (bulk_pull, no_address)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::bulk_pull> req (new rai::bulk_pull);
|
||||
req->start = 1;
|
||||
req->end = 2;
|
||||
|
@ -441,20 +441,20 @@ TEST (bulk_pull, no_address)
|
|||
TEST (bulk_pull, genesis_to_end)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::bulk_pull> req (new rai::bulk_pull {});
|
||||
req->start = rai::test_genesis_key.pub;
|
||||
req->end.clear ();
|
||||
connection->requests.push (std::unique_ptr <rai::message> {});
|
||||
auto request (std::make_shared <rai::bulk_pull_server> (connection, std::move (req)));
|
||||
ASSERT_EQ (system.clients [0]->ledger.latest (rai::test_genesis_key.pub), request->current);
|
||||
ASSERT_EQ (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub), request->current);
|
||||
ASSERT_EQ (request->request->end, request->request->end);
|
||||
}
|
||||
|
||||
TEST (bulk_pull, no_end)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::bulk_pull> req (new rai::bulk_pull {});
|
||||
req->start = rai::test_genesis_key.pub;
|
||||
req->end = 1;
|
||||
|
@ -472,10 +472,10 @@ TEST (bulk_pull, end_not_owned)
|
|||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100));
|
||||
rai::open_block open;
|
||||
open.hashables.representative = key2.pub;
|
||||
open.hashables.source = system.clients [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
open.hashables.source = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
rai::sign_message (key2.prv, key2.pub, open.hash (), open.signature);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (open));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (open));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
rai::genesis genesis;
|
||||
std::unique_ptr <rai::bulk_pull> req (new rai::bulk_pull {});
|
||||
req->start = key2.pub;
|
||||
|
@ -488,7 +488,7 @@ TEST (bulk_pull, end_not_owned)
|
|||
TEST (bulk_pull, none)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
rai::genesis genesis;
|
||||
std::unique_ptr <rai::bulk_pull> req (new rai::bulk_pull {});
|
||||
req->start = genesis.hash ();
|
||||
|
@ -502,7 +502,7 @@ TEST (bulk_pull, none)
|
|||
TEST (bulk_pull, get_next_on_open)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::bulk_pull> req (new rai::bulk_pull {});
|
||||
req->start = rai::test_genesis_key.pub;
|
||||
req->end.clear ();
|
||||
|
@ -519,11 +519,11 @@ TEST (bulk_pull, get_next_on_open)
|
|||
TEST (bootstrap_processor, DISABLED_process_none)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
auto done (false);
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
while (!done)
|
||||
{
|
||||
system.service->run_one ();
|
||||
|
@ -534,7 +534,7 @@ TEST (bootstrap_processor, DISABLED_process_none)
|
|||
TEST (bootstrap_processor, DISABLED_process_incomplete)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto client (std::make_shared <rai::bootstrap_client> (system.clients [0]));
|
||||
auto client (std::make_shared <rai::bootstrap_client> (system.nodes [0]));
|
||||
rai::genesis genesis;
|
||||
auto frontier_req_client (std::make_shared <rai::frontier_req_client> (client));
|
||||
frontier_req_client->pulls [rai::test_genesis_key.pub] = genesis.hash ();
|
||||
|
@ -548,12 +548,12 @@ TEST (bootstrap_processor, process_one)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (rai::test_genesis_key.pub, 100));
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
auto hash1 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
auto hash1 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
auto hash2 (client1->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_NE (hash1, hash2);
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
auto iterations (0);
|
||||
while (client1->ledger.latest (rai::test_genesis_key.pub) != hash1)
|
||||
{
|
||||
|
@ -570,18 +570,18 @@ TEST (bootstrap_processor, process_two)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
auto hash1 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
auto hash1 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_FALSE (system.wallet (0)->send (rai::test_genesis_key.pub, 50));
|
||||
auto hash2 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
auto hash2 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_FALSE (system.wallet (0)->send (rai::test_genesis_key.pub, 50));
|
||||
auto hash3 (system.clients [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
auto hash3 (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_NE (hash1, hash2);
|
||||
ASSERT_NE (hash1, hash3);
|
||||
ASSERT_NE (hash2, hash3);
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
auto iterations (0);
|
||||
while (client1->ledger.latest (rai::test_genesis_key.pub) != hash3)
|
||||
{
|
||||
|
@ -602,19 +602,19 @@ TEST (bootstrap_processor, process_new)
|
|||
system.wallet (1)->store.insert (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100));
|
||||
auto iterations1 (0);
|
||||
while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
++iterations1;
|
||||
ASSERT_LT (iterations1, 200);
|
||||
}
|
||||
auto balance1 (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
auto balance2 (system.clients [0]->ledger.account_balance (key2.pub));
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24002, system.processor));
|
||||
auto balance1 (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
auto balance2 (system.nodes [0]->ledger.account_balance (key2.pub));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24002, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
auto iterations2 (0);
|
||||
while (client1->ledger.account_balance (key2.pub) != balance2)
|
||||
{
|
||||
|
@ -632,34 +632,34 @@ TEST (bootstrap_processor, diamond)
|
|||
rai::system system (24000, 1);
|
||||
rai::keypair key;
|
||||
std::unique_ptr <rai::send_block> send1 (new rai::send_block);
|
||||
send1->hashables.previous = system.clients [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
send1->hashables.previous = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
send1->hashables.destination = key.pub;
|
||||
send1->hashables.balance = 100;
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send1->hash (), send1->signature);
|
||||
system.clients [0]->work_create (*send1);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*send1));
|
||||
system.nodes [0]->work_create (*send1);
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*send1));
|
||||
std::unique_ptr <rai::send_block> send2 (new rai::send_block);
|
||||
send2->hashables.previous = send1->hash ();
|
||||
send2->hashables.destination = key.pub;
|
||||
send2->hashables.balance = 0;
|
||||
system.clients [0]->work_create (*send2);
|
||||
system.nodes [0]->work_create (*send2);
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send2->hash (), send2->signature);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*send2));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*send2));
|
||||
std::unique_ptr <rai::open_block> open (new rai::open_block);
|
||||
open->hashables.source = send1->hash ();
|
||||
system.clients [0]->work_create (*open);
|
||||
system.nodes [0]->work_create (*open);
|
||||
rai::sign_message (key.prv, key.pub, open->hash (), open->signature);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*open));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*open));
|
||||
std::unique_ptr <rai::receive_block> receive (new rai::receive_block);
|
||||
receive->hashables.previous = open->hash ();
|
||||
receive->hashables.source = send2->hash ();
|
||||
rai::sign_message (key.prv, key.pub, receive->hash (), receive->signature);
|
||||
system.clients [0]->work_create (*receive);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients[0]->ledger.process (*receive));
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24002, system.processor));
|
||||
system.nodes [0]->work_create (*receive);
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (*receive));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24002, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
auto iterations (0);
|
||||
while (client1->ledger.account_balance (key.pub) != std::numeric_limits <rai::uint128_t>::max ())
|
||||
{
|
||||
|
@ -675,18 +675,18 @@ TEST (bootstrap_processor, diamond)
|
|||
TEST (bootstrap_processor, push_one)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::client_init init1;
|
||||
rai::node_init init1;
|
||||
rai::keypair key1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
auto wallet (client1->wallets.create (rai::uint256_union ()));
|
||||
ASSERT_NE (nullptr, wallet);
|
||||
wallet->store.insert (rai::test_genesis_key.prv);
|
||||
auto balance (client1->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_FALSE (wallet->send (key1.pub, 100));
|
||||
ASSERT_NE (balance, client1->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance)
|
||||
while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
|
@ -701,7 +701,7 @@ TEST (frontier_req_response, destruction)
|
|||
std::shared_ptr <rai::frontier_req_server> hold;
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::frontier_req> req (new rai::frontier_req);
|
||||
req->start.clear ();
|
||||
req->age = std::numeric_limits <decltype (req->age)>::max ();
|
||||
|
@ -716,14 +716,14 @@ TEST (frontier_req_response, destruction)
|
|||
TEST (frontier_req, begin)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::frontier_req> req (new rai::frontier_req);
|
||||
req->start.clear ();
|
||||
req->age = std::numeric_limits <decltype (req->age)>::max ();
|
||||
req->count = std::numeric_limits <decltype (req->count)>::max ();
|
||||
connection->requests.push (std::unique_ptr <rai::message> {});
|
||||
auto request (std::make_shared <rai::frontier_req_server> (connection, std::move (req)));
|
||||
ASSERT_EQ (connection->client->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator);
|
||||
ASSERT_EQ (connection->node->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator);
|
||||
auto pair (request->get_next ());
|
||||
ASSERT_EQ (rai::test_genesis_key.pub, pair.first);
|
||||
rai::genesis genesis;
|
||||
|
@ -733,14 +733,14 @@ TEST (frontier_req, begin)
|
|||
TEST (frontier_req, end)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::frontier_req> req (new rai::frontier_req);
|
||||
req->start = rai::test_genesis_key.pub.number () + 1;
|
||||
req->age = std::numeric_limits <decltype (req->age)>::max ();
|
||||
req->count = std::numeric_limits <decltype (req->count)>::max ();
|
||||
connection->requests.push (std::unique_ptr <rai::message> {});
|
||||
auto request (std::make_shared <rai::frontier_req_server> (connection, std::move (req)));
|
||||
ASSERT_EQ (connection->client->ledger.store.latest_end (), request->iterator);
|
||||
ASSERT_EQ (connection->node->ledger.store.latest_end (), request->iterator);
|
||||
auto pair (request->get_next ());
|
||||
ASSERT_TRUE (pair.first.is_zero ());
|
||||
}
|
||||
|
@ -748,14 +748,14 @@ TEST (frontier_req, end)
|
|||
TEST (frontier_req, time_bound)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::frontier_req> req (new rai::frontier_req);
|
||||
req->start.clear ();
|
||||
req->age = 0;
|
||||
req->count = std::numeric_limits <decltype (req->count)>::max ();
|
||||
connection->requests.push (std::unique_ptr <rai::message> {});
|
||||
auto request (std::make_shared <rai::frontier_req_server> (connection, std::move (req)));
|
||||
ASSERT_EQ (connection->client->ledger.store.latest_end (), request->iterator);
|
||||
ASSERT_EQ (connection->node->ledger.store.latest_end (), request->iterator);
|
||||
auto pair (request->get_next ());
|
||||
ASSERT_TRUE (pair.first.is_zero ());
|
||||
}
|
||||
|
@ -763,14 +763,14 @@ TEST (frontier_req, time_bound)
|
|||
TEST (frontier_req, time_cutoff)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.clients [0]));
|
||||
auto connection (std::make_shared <rai::bootstrap_server> (nullptr, system.nodes [0]));
|
||||
std::unique_ptr <rai::frontier_req> req (new rai::frontier_req);
|
||||
req->start.clear ();
|
||||
req->age = 10;
|
||||
req->count = std::numeric_limits <decltype (req->count)>::max ();
|
||||
connection->requests.push (std::unique_ptr <rai::message> {});
|
||||
auto request (std::make_shared <rai::frontier_req_server> (connection, std::move (req)));
|
||||
ASSERT_EQ (connection->client->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator);
|
||||
ASSERT_EQ (connection->node->ledger.store.latest_begin (rai::test_genesis_key.pub), request->iterator);
|
||||
auto pair (request->get_next ());
|
||||
ASSERT_EQ (rai::test_genesis_key.pub, pair.first);
|
||||
rai::genesis genesis;
|
||||
|
@ -781,28 +781,28 @@ TEST (bulk, genesis)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
rai::frontier frontier1;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
rai::frontier frontier2;
|
||||
ASSERT_FALSE (client1->store.latest_get (rai::test_genesis_key.pub, frontier2));
|
||||
ASSERT_EQ (frontier1.hash, frontier2.hash);
|
||||
rai::keypair key2;
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100));
|
||||
rai::frontier frontier3;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier3));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier3));
|
||||
ASSERT_NE (frontier1.hash, frontier3.hash);
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
auto iterations (0);
|
||||
while (client1->ledger.latest (rai::test_genesis_key.pub) != system.clients [0]->ledger.latest (rai::test_genesis_key.pub))
|
||||
while (client1->ledger.latest (rai::test_genesis_key.pub) != system.nodes [0]->ledger.latest (rai::test_genesis_key.pub))
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
ASSERT_EQ (system.clients [0]->ledger.latest (rai::test_genesis_key.pub), client1->ledger.latest (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (system.nodes [0]->ledger.latest (rai::test_genesis_key.pub), client1->ledger.latest (rai::test_genesis_key.pub));
|
||||
client1->stop ();
|
||||
}
|
||||
|
||||
|
@ -810,10 +810,10 @@ TEST (bulk, offline_send)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
client1->network.send_keepalive (system.clients [0]->network.endpoint ());
|
||||
client1->network.send_keepalive (system.nodes [0]->network.endpoint ());
|
||||
client1->start ();
|
||||
auto iterations (0);
|
||||
do
|
||||
|
@ -822,13 +822,13 @@ TEST (bulk, offline_send)
|
|||
system.processor.poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
} while (system.clients [0]->peers.empty () || client1->peers.empty ());
|
||||
} while (system.nodes [0]->peers.empty () || client1->peers.empty ());
|
||||
rai::keypair key2;
|
||||
auto wallet (client1->wallets.create (rai::uint256_union ()));
|
||||
wallet->store.insert (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100));
|
||||
ASSERT_NE (std::numeric_limits <rai::uint256_t>::max (), system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
client1->processor.bootstrap (system.clients [0]->bootstrap.endpoint ());
|
||||
ASSERT_NE (std::numeric_limits <rai::uint256_t>::max (), system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
client1->processor.bootstrap (system.nodes [0]->bootstrap.endpoint ());
|
||||
auto iterations2 (0);
|
||||
while (client1->ledger.account_balance (key2.pub) != 100)
|
||||
{
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <rai/core/core.hpp>
|
||||
#include <rai/node.hpp>
|
||||
|
||||
TEST (client, stop)
|
||||
TEST (node, stop)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
ASSERT_NE (system.clients [0]->wallets.items.end (), system.clients [0]->wallets.items.begin ());
|
||||
system.clients [0]->stop ();
|
||||
ASSERT_NE (system.nodes [0]->wallets.items.end (), system.nodes [0]->wallets.items.begin ());
|
||||
system.nodes [0]->stop ();
|
||||
system.processor.run ();
|
||||
system.service->run ();
|
||||
ASSERT_TRUE (true);
|
||||
}
|
||||
|
||||
TEST (client, block_store_path_failure)
|
||||
TEST (node, block_store_path_failure)
|
||||
{
|
||||
rai::client_init init;
|
||||
rai::node_init init;
|
||||
rai::processor_service processor;
|
||||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
auto client (std::make_shared <rai::client> (init, service, 0, boost::filesystem::path {}, processor));
|
||||
client->stop ();
|
||||
auto node (std::make_shared <rai::node> (init, service, 0, boost::filesystem::path {}, processor));
|
||||
node->stop ();
|
||||
}
|
||||
|
||||
TEST (client, balance)
|
||||
TEST (node, balance)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), system.wallet (0)->store.balance (system.clients [0]->ledger));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max (), system.wallet (0)->store.balance (system.nodes [0]->ledger));
|
||||
}
|
||||
|
||||
TEST (client, send_unkeyed)
|
||||
TEST (node, send_unkeyed)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::keypair key2;
|
||||
|
@ -36,7 +36,7 @@ TEST (client, send_unkeyed)
|
|||
ASSERT_TRUE (system.wallet (0)->send (key2.pub, 1000));
|
||||
}
|
||||
|
||||
TEST (client, send_self)
|
||||
TEST (node, send_self)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::keypair key2;
|
||||
|
@ -44,27 +44,27 @@ TEST (client, send_self)
|
|||
system.wallet (0)->store.insert (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000));
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
}
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (client, send_single)
|
||||
TEST (node, send_single)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
rai::keypair key2;
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
system.wallet (1)->store.insert (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.clients [0]->ledger.account_balance (key2.pub).is_zero ());
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ());
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -73,17 +73,17 @@ TEST (client, send_single)
|
|||
}
|
||||
}
|
||||
|
||||
TEST (client, send_single_observing_peer)
|
||||
TEST (node, send_single_observing_peer)
|
||||
{
|
||||
rai::system system (24000, 3);
|
||||
rai::keypair key2;
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
system.wallet (1)->store.insert (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.clients [0]->ledger.account_balance (key2.pub).is_zero ());
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ());
|
||||
auto iterations (0);
|
||||
while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr <rai::client> const & client_a) {return client_a->ledger.account_balance (key2.pub).is_zero();}))
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr <rai::node> const & node_a) {return node_a->ledger.account_balance (key2.pub).is_zero();}))
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -92,17 +92,17 @@ TEST (client, send_single_observing_peer)
|
|||
}
|
||||
}
|
||||
|
||||
TEST (client, send_single_many_peers)
|
||||
TEST (node, send_single_many_peers)
|
||||
{
|
||||
rai::system system (24000, 10);
|
||||
rai::keypair key2;
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
system.wallet (1)->store.insert (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.clients [0]->ledger.account_balance (key2.pub).is_zero ());
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 1000, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ());
|
||||
auto iterations (0);
|
||||
while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr <rai::client> const & client_a) {return client_a->ledger.account_balance (key2.pub).is_zero();}))
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr <rai::node> const & node_a) {return node_a->ledger.account_balance (key2.pub).is_zero();}))
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -111,7 +111,7 @@ TEST (client, send_single_many_peers)
|
|||
}
|
||||
}
|
||||
|
||||
TEST (client, send_out_of_order)
|
||||
TEST (node, send_out_of_order)
|
||||
{
|
||||
rai::system system (24000, 2);
|
||||
rai::keypair key2;
|
||||
|
@ -126,10 +126,10 @@ TEST (client, send_out_of_order)
|
|||
send2.hashables.destination = key2.pub;
|
||||
send2.hashables.previous = send1.hash ();
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send2.hash (), send2.signature);
|
||||
system.clients [0]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (send2)));
|
||||
system.clients [0]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (send1)));
|
||||
system.nodes [0]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (send2)));
|
||||
system.nodes [0]->processor.process_receive_republish (std::unique_ptr <rai::block> (new rai::send_block (send1)));
|
||||
auto iterations (0);
|
||||
while (std::any_of (system.clients.begin (), system.clients.end (), [&] (std::shared_ptr <rai::client> const & client_a) {return client_a->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits <rai::uint128_t>::max () - 2000;}))
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr <rai::node> const & node_a) {return node_a->ledger.account_balance (rai::test_genesis_key.pub) != std::numeric_limits <rai::uint128_t>::max () - 2000;}))
|
||||
{
|
||||
system.service->poll_one ();
|
||||
++iterations;
|
||||
|
@ -137,7 +137,7 @@ TEST (client, send_out_of_order)
|
|||
}
|
||||
}
|
||||
|
||||
TEST (client, quick_confirm)
|
||||
TEST (node, quick_confirm)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::keypair key;
|
||||
|
@ -145,12 +145,12 @@ TEST (client, quick_confirm)
|
|||
rai::send_block send;
|
||||
send.hashables.balance = 0;
|
||||
send.hashables.destination = key.pub;
|
||||
send.hashables.previous = system.clients [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
system.clients [0]->work_create (send);
|
||||
send.hashables.previous = system.nodes [0]->ledger.latest (rai::test_genesis_key.pub);
|
||||
system.nodes [0]->work_create (send);
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send.hash (), send.signature);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients [0]->processor.process_receive (send));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->processor.process_receive (send));
|
||||
auto iterations (0);
|
||||
while (system.clients [0]->ledger.account_balance (key.pub).is_zero ())
|
||||
while (system.nodes [0]->ledger.account_balance (key.pub).is_zero ())
|
||||
{
|
||||
system.processor.poll_one ();
|
||||
system.service->poll_one ();
|
||||
|
@ -159,7 +159,7 @@ TEST (client, quick_confirm)
|
|||
}
|
||||
}
|
||||
|
||||
TEST (client, auto_bootstrap)
|
||||
TEST (node, auto_bootstrap)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -173,16 +173,16 @@ TEST (client, auto_bootstrap)
|
|||
system.processor.poll_one ();
|
||||
++iterations1;
|
||||
ASSERT_LT (iterations1, 200);
|
||||
} while (system.clients [0]->ledger.account_balance (key2.pub) != 100);
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
} while (system.nodes [0]->ledger.account_balance (key2.pub) != 100);
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
client1->network.send_keepalive (system.clients [0]->network.endpoint ());
|
||||
client1->network.send_keepalive (system.nodes [0]->network.endpoint ());
|
||||
client1->start ();
|
||||
ASSERT_FALSE (client1->bootstrap_initiator.warmed_up);
|
||||
ASSERT_FALSE (client1->bootstrap_initiator.in_progress);
|
||||
ASSERT_FALSE (system.clients [0]->bootstrap_initiator.warmed_up);
|
||||
ASSERT_FALSE (system.clients [0]->bootstrap_initiator.in_progress);
|
||||
ASSERT_FALSE (system.nodes [0]->bootstrap_initiator.warmed_up);
|
||||
ASSERT_FALSE (system.nodes [0]->bootstrap_initiator.in_progress);
|
||||
auto iterations2 (0);
|
||||
do
|
||||
{
|
||||
|
@ -190,9 +190,9 @@ TEST (client, auto_bootstrap)
|
|||
system.processor.poll_one ();
|
||||
++iterations2;
|
||||
ASSERT_LT (iterations2, 200);
|
||||
} while (!client1->bootstrap_initiator.in_progress || !system.clients [0]->bootstrap_initiator.in_progress);
|
||||
} while (!client1->bootstrap_initiator.in_progress || !system.nodes [0]->bootstrap_initiator.in_progress);
|
||||
ASSERT_TRUE (client1->bootstrap_initiator.warmed_up);
|
||||
ASSERT_TRUE (system.clients [0]->bootstrap_initiator.warmed_up);
|
||||
ASSERT_TRUE (system.nodes [0]->bootstrap_initiator.warmed_up);
|
||||
auto iterations3 (0);
|
||||
do
|
||||
{
|
||||
|
@ -208,21 +208,21 @@ TEST (client, auto_bootstrap)
|
|||
system.processor.poll_one ();
|
||||
++iterations4;
|
||||
ASSERT_LT (iterations4, 200);
|
||||
} while (client1->bootstrap_initiator.in_progress || system.clients [0]->bootstrap_initiator.in_progress);
|
||||
} while (client1->bootstrap_initiator.in_progress || system.nodes [0]->bootstrap_initiator.in_progress);
|
||||
client1->stop ();
|
||||
}
|
||||
|
||||
TEST (client, auto_bootstrap_reverse)
|
||||
TEST (node, auto_bootstrap_reverse)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
ASSERT_FALSE (init1.error ());
|
||||
rai::keypair key2;
|
||||
system.wallet (0)->store.insert (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 100));
|
||||
system.clients [0]->network.send_keepalive (client1->network.endpoint ());
|
||||
system.nodes [0]->network.send_keepalive (client1->network.endpoint ());
|
||||
client1->start ();
|
||||
auto iterations (0);
|
||||
do
|
||||
|
@ -235,7 +235,7 @@ TEST (client, auto_bootstrap_reverse)
|
|||
client1->stop ();
|
||||
}
|
||||
|
||||
TEST (client, multi_account_send_atomicness)
|
||||
TEST (node, multi_account_send_atomicness)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -245,10 +245,10 @@ TEST (client, multi_account_send_atomicness)
|
|||
system.wallet (0)->send (key1.pub, std::numeric_limits<rai::uint128_t>::max () / 2 + std::numeric_limits<rai::uint128_t>::max () / 4);
|
||||
}
|
||||
|
||||
TEST (client, receive_gap)
|
||||
TEST (node, receive_gap)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto & client (*system.clients [0]);
|
||||
auto & client (*system.nodes [0]);
|
||||
ASSERT_EQ (0, client.gap_cache.blocks.size ());
|
||||
rai::send_block block;
|
||||
rai::confirm_req message;
|
||||
|
@ -257,7 +257,7 @@ TEST (client, receive_gap)
|
|||
ASSERT_EQ (1, client.gap_cache.blocks.size ());
|
||||
}
|
||||
|
||||
TEST (client, scaling)
|
||||
TEST (node, scaling)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto max (std::numeric_limits <rai::uint128_t>::max ());
|
||||
|
@ -268,7 +268,7 @@ TEST (client, scaling)
|
|||
ASSERT_EQ (up1 - up2, rai::scale_64bit_base10);
|
||||
}
|
||||
|
||||
TEST (client, scale_num)
|
||||
TEST (node, scale_num)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::uint128_t num ("60000000000000000000000000000000000000");
|
||||
|
@ -277,25 +277,25 @@ TEST (client, scale_num)
|
|||
ASSERT_EQ (num, up);
|
||||
}
|
||||
|
||||
TEST (client, merge_peers)
|
||||
TEST (node, merge_peers)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
std::array <rai::endpoint, 8> endpoints;
|
||||
endpoints.fill (rai::endpoint (boost::asio::ip::address_v6::loopback (), 24000));
|
||||
endpoints [0] = rai::endpoint (boost::asio::ip::address_v6::loopback (), 24001);
|
||||
system.clients [0]->network.merge_peers (endpoints);
|
||||
ASSERT_EQ (0, system.clients [0]->peers.peers.size ());
|
||||
system.nodes [0]->network.merge_peers (endpoints);
|
||||
ASSERT_EQ (0, system.nodes [0]->peers.peers.size ());
|
||||
}
|
||||
|
||||
TEST (client, search_pending)
|
||||
TEST (node, search_pending)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::keypair key2;
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
auto balance (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
auto balance (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 1000));
|
||||
auto iterations1 (0);
|
||||
while (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance)
|
||||
while (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub) == balance)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -303,9 +303,9 @@ TEST (client, search_pending)
|
|||
ASSERT_LT (iterations1, 200);
|
||||
}
|
||||
system.wallet (0)->store.insert (key2.prv);
|
||||
system.clients [0]->processor.search_pending ();
|
||||
system.nodes [0]->processor.search_pending ();
|
||||
auto iterations2 (0);
|
||||
while (system.clients [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
while (system.nodes [0]->ledger.account_balance (key2.pub).is_zero ())
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -314,15 +314,15 @@ TEST (client, search_pending)
|
|||
}
|
||||
}
|
||||
|
||||
TEST (client, connect_after_junk)
|
||||
TEST (node, connect_after_junk)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::client_init init1;
|
||||
auto client1 (std::make_shared <rai::client> (init1, system.service, 24001, system.processor));
|
||||
rai::node_init init1;
|
||||
auto client1 (std::make_shared <rai::node> (init1, system.service, 24001, system.processor));
|
||||
uint64_t junk;
|
||||
client1->network.socket.async_send_to (boost::asio::buffer (&junk, sizeof (junk)), system.clients [0]->network.endpoint (), [] (boost::system::error_code const &, size_t) {});
|
||||
client1->network.socket.async_send_to (boost::asio::buffer (&junk, sizeof (junk)), system.nodes [0]->network.endpoint (), [] (boost::system::error_code const &, size_t) {});
|
||||
auto iterations1 (0);
|
||||
while (system.clients [0]->network.error_count == 0)
|
||||
while (system.nodes [0]->network.error_count == 0)
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
|
@ -330,7 +330,7 @@ TEST (client, connect_after_junk)
|
|||
ASSERT_LT (iterations1, 200);
|
||||
}
|
||||
client1->start ();
|
||||
client1->network.send_keepalive (system.clients [0]->network.endpoint ());
|
||||
client1->network.send_keepalive (system.nodes [0]->network.endpoint ());
|
||||
auto iterations2 (0);
|
||||
while (client1->peers.empty ())
|
||||
{
|
|
@ -8,14 +8,14 @@ TEST (rpc, account_create)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
request_tree.put ("action", "account_create");
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, request_tree);
|
||||
|
@ -35,7 +35,7 @@ TEST (rpc, account_balance_exact)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
|
@ -60,7 +60,7 @@ TEST (rpc, account_balance)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
|
@ -86,12 +86,12 @@ TEST (rpc, account_weight_exact)
|
|||
rai::keypair key;
|
||||
rai::system system (24000, 1);
|
||||
rai::frontier frontier;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier));
|
||||
rai::change_block block (key.pub, frontier.hash, rai::test_genesis_key.prv, rai::test_genesis_key.pub);
|
||||
system.clients [0]->work_create (block);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (block));
|
||||
system.nodes [0]->work_create (block);
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (block));
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
key.pub.encode_base58check (account);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
|
@ -117,12 +117,12 @@ TEST (rpc, account_weight)
|
|||
rai::keypair key;
|
||||
rai::system system (24000, 1);
|
||||
rai::frontier frontier;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier));
|
||||
rai::change_block block (key.pub, frontier.hash, rai::test_genesis_key.prv, rai::test_genesis_key.pub);
|
||||
system.clients [0]->work_create (block);
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (block));
|
||||
system.nodes [0]->work_create (block);
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (block));
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
key.pub.encode_base58check (account);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
|
@ -147,7 +147,7 @@ TEST (rpc, wallet_contains)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -156,7 +156,7 @@ TEST (rpc, wallet_contains)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "wallet_contains");
|
||||
request_tree.put ("account", account);
|
||||
|
@ -176,7 +176,7 @@ TEST (rpc, wallet_doesnt_contain)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
|
@ -184,7 +184,7 @@ TEST (rpc, wallet_doesnt_contain)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "wallet_contains");
|
||||
request_tree.put ("account", account);
|
||||
|
@ -204,7 +204,7 @@ TEST (rpc, validate_account_number)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -230,7 +230,7 @@ TEST (rpc, validate_account_invalid)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
account [0] ^= 0x1;
|
||||
|
@ -257,7 +257,7 @@ TEST (rpc, send_exact)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -268,7 +268,7 @@ TEST (rpc, send_exact)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "send_exact");
|
||||
request_tree.put ("account", account);
|
||||
|
@ -289,7 +289,7 @@ TEST (rpc, send)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -300,7 +300,7 @@ TEST (rpc, send)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "send");
|
||||
request_tree.put ("account", account);
|
||||
|
@ -308,9 +308,9 @@ TEST (rpc, send)
|
|||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, request_tree);
|
||||
request.body = ostream.str ();
|
||||
auto balance1 (system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
auto balance1 (system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
rpc (request, response);
|
||||
ASSERT_EQ (balance1 - rai::scale_64bit_base10, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (balance1 - rai::scale_64bit_base10, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.status);
|
||||
boost::property_tree::ptree response_tree;
|
||||
std::stringstream istream (response.content);
|
||||
|
@ -323,7 +323,7 @@ TEST (rpc, send_fail)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
rai::keypair key1;
|
||||
|
@ -333,7 +333,7 @@ TEST (rpc, send_fail)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "send");
|
||||
request_tree.put ("account", account);
|
||||
|
@ -354,7 +354,7 @@ TEST (rpc, wallet_add)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
rai::keypair key1;
|
||||
std::string key_text;
|
||||
key1.prv.encode_hex (key_text);
|
||||
|
@ -364,7 +364,7 @@ TEST (rpc, wallet_add)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "wallet_add");
|
||||
request_tree.put ("key", key_text);
|
||||
|
@ -386,13 +386,13 @@ TEST (rpc, wallet_password_valid)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "password_valid");
|
||||
std::stringstream ostream;
|
||||
|
@ -411,13 +411,13 @@ TEST (rpc, wallet_password_change)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "password_change");
|
||||
request_tree.put ("password", "test");
|
||||
|
@ -442,13 +442,13 @@ TEST (rpc, wallet_password_enter)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "password_enter");
|
||||
request_tree.put ("password", "");
|
||||
|
@ -468,13 +468,13 @@ TEST (rpc, representative)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "representative");
|
||||
std::stringstream ostream;
|
||||
|
@ -495,13 +495,13 @@ TEST (rpc, representative_set)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
rai::keypair key;
|
||||
std::string representative_l;
|
||||
|
@ -513,14 +513,14 @@ TEST (rpc, representative_set)
|
|||
request.body = ostream.str ();
|
||||
rpc (request, response);
|
||||
ASSERT_EQ (boost::network::http::server <rai::rpc>::response::ok, response.status);
|
||||
ASSERT_EQ (key.pub, system.clients [0]->wallets.items.begin ()->second->store.representative ());
|
||||
ASSERT_EQ (key.pub, system.nodes [0]->wallets.items.begin ()->second->store.representative ());
|
||||
}
|
||||
|
||||
TEST (rpc, account_list)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -531,7 +531,7 @@ TEST (rpc, account_list)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "account_list");
|
||||
std::stringstream ostream;
|
||||
|
@ -562,7 +562,7 @@ TEST (rpc, wallet_key_valid)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
std::string account;
|
||||
rai::test_genesis_key.pub.encode_base58check (account);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
|
@ -571,7 +571,7 @@ TEST (rpc, wallet_key_valid)
|
|||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
std::string wallet;
|
||||
system.clients [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
system.nodes [0]->wallets.items.begin ()->first.encode_hex (wallet);
|
||||
request_tree.put ("wallet", wallet);
|
||||
request_tree.put ("action", "wallet_key_valid");
|
||||
std::stringstream ostream;
|
||||
|
@ -590,7 +590,7 @@ TEST (rpc, wallet_create)
|
|||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
|
@ -607,21 +607,21 @@ TEST (rpc, wallet_create)
|
|||
std::string wallet_text (response_tree.get <std::string> ("wallet"));
|
||||
rai::uint256_union wallet_id;
|
||||
ASSERT_FALSE (wallet_id.decode_hex (wallet_text));
|
||||
ASSERT_NE (system.clients [0]->wallets.items.end (), system.clients [0]->wallets.items.find (wallet_id));
|
||||
ASSERT_NE (system.nodes [0]->wallets.items.end (), system.nodes [0]->wallets.items.find (wallet_id));
|
||||
}
|
||||
|
||||
TEST (rpc, wallet_export)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
request.method = "POST";
|
||||
boost::property_tree::ptree request_tree;
|
||||
request_tree.put ("action", "wallet_export");
|
||||
request_tree.put ("wallet", system.clients [0]->wallets.items.begin ()->first.to_string ());
|
||||
request_tree.put ("wallet", system.nodes [0]->wallets.items.begin ()->first.to_string ());
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, request_tree);
|
||||
request.body = ostream.str ();
|
||||
|
@ -640,9 +640,9 @@ TEST (rpc, wallet_export)
|
|||
TEST (rpc, wallet_destroy)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto wallet_id (system.clients [0]->wallets.items.begin ()->first);
|
||||
auto wallet_id (system.nodes [0]->wallets.items.begin ()->first);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
|
@ -658,20 +658,20 @@ TEST (rpc, wallet_destroy)
|
|||
boost::property_tree::ptree response_tree;
|
||||
std::stringstream istream (response.content);
|
||||
boost::property_tree::read_json (istream, response_tree);
|
||||
ASSERT_EQ (system.clients [0]->wallets.items.end (), system.clients [0]->wallets.items.find (wallet_id));
|
||||
ASSERT_EQ (system.nodes [0]->wallets.items.end (), system.nodes [0]->wallets.items.find (wallet_id));
|
||||
}
|
||||
|
||||
TEST (rpc, account_move)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
auto wallet_id (system.clients [0]->wallets.items.begin ()->first);
|
||||
auto wallet_id (system.nodes [0]->wallets.items.begin ()->first);
|
||||
auto pool (boost::make_shared <boost::network::utils::thread_pool> ());
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.clients [0], true);
|
||||
rai::rpc rpc (system.service, pool, boost::asio::ip::address_v6::loopback (), 25000, *system.nodes [0], true);
|
||||
auto destination (system.wallet (0));
|
||||
destination->store.insert (rai::test_genesis_key.prv);
|
||||
rai::keypair source_id;
|
||||
rai::keypair key;
|
||||
auto source (system.clients [0]->wallets.create (source_id.prv));
|
||||
auto source (system.nodes [0]->wallets.create (source_id.prv));
|
||||
source->store.insert (key.prv);
|
||||
boost::network::http::server <rai::rpc>::request request;
|
||||
boost::network::http::server <rai::rpc>::response response;
|
||||
|
|
|
@ -92,17 +92,17 @@ TEST (wallet, one_spend)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::frontier frontier1;
|
||||
system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1);
|
||||
system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1);
|
||||
rai::keypair key2;
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, std::numeric_limits <rai::uint128_t>::max ()));
|
||||
rai::frontier frontier2;
|
||||
system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier2);
|
||||
system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier2);
|
||||
ASSERT_NE (frontier1, frontier2);
|
||||
auto block (system.clients [0]->store.block_get (frontier2.hash));
|
||||
auto block (system.nodes [0]->store.block_get (frontier2.hash));
|
||||
ASSERT_NE (nullptr, block);
|
||||
ASSERT_EQ (frontier1.hash, block->previous ());
|
||||
ASSERT_TRUE (frontier2.balance.is_zero ());
|
||||
ASSERT_EQ (0, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (wallet, DISABLED_two_spend)
|
||||
|
@ -138,10 +138,10 @@ TEST (wallet, partial_spend)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::frontier frontier1;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
rai::keypair key2;
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 500));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.clients [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.nodes [0]->ledger.account_balance (rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (wallet, spend_no_previous)
|
||||
|
@ -149,7 +149,7 @@ TEST (wallet, spend_no_previous)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
rai::frontier frontier1;
|
||||
ASSERT_FALSE (system.clients [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
ASSERT_FALSE (system.nodes [0]->store.latest_get (rai::test_genesis_key.pub, frontier1));
|
||||
for (auto i (0); i < 50; ++i)
|
||||
{
|
||||
rai::keypair key;
|
||||
|
@ -157,7 +157,7 @@ TEST (wallet, spend_no_previous)
|
|||
}
|
||||
rai::keypair key2;
|
||||
ASSERT_FALSE (system.wallet (0)->send (key2.pub, 500));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.clients [0]->ledger.account_balance(rai::test_genesis_key.pub));
|
||||
ASSERT_EQ (std::numeric_limits <rai::uint128_t>::max () - 500, system.nodes [0]->ledger.account_balance(rai::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
TEST (wallet, find_none)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
TEST (wallets, open_create)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::wallets wallets (*system.clients [0], boost::filesystem::unique_path ());
|
||||
rai::wallets wallets (*system.nodes [0], boost::filesystem::unique_path ());
|
||||
ASSERT_EQ (0, wallets.items.size ());
|
||||
rai::uint256_union id;
|
||||
ASSERT_EQ (nullptr, wallets.open (id));
|
||||
|
@ -19,13 +19,13 @@ TEST (wallets, open_existing)
|
|||
rai::uint256_union id;
|
||||
auto path (boost::filesystem::unique_path ());
|
||||
{
|
||||
rai::wallets wallets (*system.clients [0], path);
|
||||
rai::wallets wallets (*system.nodes [0], path);
|
||||
ASSERT_EQ (0, wallets.items.size ());
|
||||
auto wallet (wallets.create (id));
|
||||
ASSERT_EQ (wallet, wallets.open (id));
|
||||
}
|
||||
{
|
||||
rai::wallets wallets (*system.clients [0], path);
|
||||
rai::wallets wallets (*system.nodes [0], path);
|
||||
ASSERT_EQ (1, wallets.items.size ());
|
||||
ASSERT_NE (nullptr, wallets.open (id));
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ TEST (wallets, remove)
|
|||
rai::uint256_union one (1);
|
||||
auto path (boost::filesystem::unique_path ());
|
||||
{
|
||||
rai::wallets wallets (*system.clients [0], path);
|
||||
rai::wallets wallets (*system.nodes [0], path);
|
||||
ASSERT_EQ (0, wallets.items.size ());
|
||||
auto wallet (wallets.create (one));
|
||||
ASSERT_EQ (1, wallets.items.size ());
|
||||
|
@ -45,7 +45,7 @@ TEST (wallets, remove)
|
|||
ASSERT_EQ (0, wallets.items.size ());
|
||||
}
|
||||
{
|
||||
rai::wallets wallets (*system.clients [0], path);
|
||||
rai::wallets wallets (*system.nodes [0], path);
|
||||
ASSERT_EQ (0, wallets.items.size ());
|
||||
}
|
||||
}
|
|
@ -132,7 +132,7 @@ namespace landing
|
|||
config_a.serialize (config_file);
|
||||
}
|
||||
}
|
||||
void distribute (rai::client & client_a, std::shared_ptr <rai::wallet> wallet_a, rai::landing::config & config_a, boost::filesystem::path working_path_a)
|
||||
void distribute (rai::node & node_a, std::shared_ptr <rai::wallet> wallet_a, rai::landing::config & config_a, boost::filesystem::path working_path_a)
|
||||
{
|
||||
auto now (rai::landing::minutes_since_epoch ());
|
||||
auto error (false);
|
||||
|
@ -152,7 +152,7 @@ namespace landing
|
|||
}
|
||||
}
|
||||
std::cout << "Waiting for next distribution cycle\n";
|
||||
client_a.service.add (std::chrono::system_clock::now () + std::chrono::minutes (1), [&client_a, &config_a, working_path_a, wallet_a] () {rai::landing::distribute (client_a, wallet_a, config_a, working_path_a);});
|
||||
node_a.service.add (std::chrono::system_clock::now () + std::chrono::minutes (1), [&node_a, &config_a, working_path_a, wallet_a] () {rai::landing::distribute (node_a, wallet_a, config_a, working_path_a);});
|
||||
}
|
||||
rai::landing::config read_config (bool & config_error, boost::filesystem::path working_path_a)
|
||||
{
|
||||
|
@ -181,10 +181,10 @@ int main (int argc, char * const * argv)
|
|||
rai::landing::config config (rai::landing::read_config (config_error, working));
|
||||
if (!config_error)
|
||||
{
|
||||
rai::client_init init;
|
||||
rai::node_init init;
|
||||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::processor_service processor;
|
||||
auto client (std::make_shared <rai::client> (init, service, config.peering_port, working, processor));
|
||||
auto client (std::make_shared <rai::node> (init, service, config.peering_port, working, processor));
|
||||
if (!init.error ())
|
||||
{
|
||||
client->bootstrap_peers = config.bootstrap_peers;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -86,11 +86,11 @@ struct hash <rai::endpoint>
|
|||
|
||||
namespace rai
|
||||
{
|
||||
class client;
|
||||
class node;
|
||||
class election : public std::enable_shared_from_this <rai::election>
|
||||
{
|
||||
public:
|
||||
election (std::shared_ptr <rai::client>, rai::block const &);
|
||||
election (std::shared_ptr <rai::node>, rai::block const &);
|
||||
void start ();
|
||||
void vote (rai::vote const &);
|
||||
void announce_vote ();
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
rai::uint128_t uncontested_threshold (rai::ledger &);
|
||||
rai::uint128_t contested_threshold (rai::ledger &);
|
||||
rai::votes votes;
|
||||
std::weak_ptr <rai::client> client;
|
||||
std::weak_ptr <rai::node> node;
|
||||
std::chrono::system_clock::time_point last_vote;
|
||||
std::unique_ptr <rai::block> last_winner;
|
||||
bool confirmed;
|
||||
|
@ -107,13 +107,13 @@ public:
|
|||
class conflicts
|
||||
{
|
||||
public:
|
||||
conflicts (rai::client &);
|
||||
conflicts (rai::node &);
|
||||
void start (rai::block const &, bool);
|
||||
bool no_conflict (rai::block_hash const &);
|
||||
void update (rai::vote const &);
|
||||
void stop (rai::block_hash const &);
|
||||
std::unordered_map <rai::block_hash, std::shared_ptr <rai::election>> roots;
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
std::mutex mutex;
|
||||
};
|
||||
enum class message_type : uint8_t
|
||||
|
@ -313,25 +313,25 @@ public:
|
|||
class wallet
|
||||
{
|
||||
public:
|
||||
wallet (bool &, rai::client &, boost::filesystem::path const &);
|
||||
wallet (bool &, rai::client &, boost::filesystem::path const &, std::string const &);
|
||||
wallet (bool &, rai::node &, boost::filesystem::path const &);
|
||||
wallet (bool &, rai::node &, boost::filesystem::path const &, std::string const &);
|
||||
bool receive (rai::send_block const &, rai::private_key const &, rai::account const &);
|
||||
bool send (rai::account const &, rai::uint128_t const &);
|
||||
bool import (std::string const &, std::string const &);
|
||||
std::mutex mutex;
|
||||
rai::wallet_store store;
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
};
|
||||
class wallets
|
||||
{
|
||||
public:
|
||||
wallets (rai::client &, boost::filesystem::path const &);
|
||||
wallets (rai::node &, boost::filesystem::path const &);
|
||||
std::shared_ptr <rai::wallet> open (rai::uint256_union const &);
|
||||
std::shared_ptr <rai::wallet> create (rai::uint256_union const &);
|
||||
void destroy (rai::uint256_union const &);
|
||||
std::unordered_map <rai::uint256_union, std::shared_ptr <rai::wallet>> items;
|
||||
boost::filesystem::path const path;
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
};
|
||||
class operation
|
||||
{
|
||||
|
@ -368,7 +368,7 @@ public:
|
|||
class gap_cache
|
||||
{
|
||||
public:
|
||||
gap_cache (rai::client &);
|
||||
gap_cache (rai::node &);
|
||||
void add (rai::block const &, rai::block_hash);
|
||||
std::unique_ptr <rai::block> get (rai::block_hash const &);
|
||||
void vote (rai::vote const &);
|
||||
|
@ -385,12 +385,12 @@ public:
|
|||
> blocks;
|
||||
size_t const max = 128;
|
||||
std::mutex mutex;
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
};
|
||||
class processor
|
||||
{
|
||||
public:
|
||||
processor (rai::client &);
|
||||
processor (rai::node &);
|
||||
void stop ();
|
||||
void contacted (rai::endpoint const &);
|
||||
void find_network (std::vector <std::pair <std::string, std::string>> const &);
|
||||
|
@ -403,7 +403,7 @@ public:
|
|||
void process_confirmed (rai::block const &);
|
||||
void search_pending ();
|
||||
void ongoing_keepalive ();
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
static std::chrono::seconds constexpr period = std::chrono::seconds (60);
|
||||
static std::chrono::seconds constexpr cutoff = period * 5;
|
||||
std::mutex mutex;
|
||||
|
@ -443,12 +443,12 @@ public:
|
|||
class bootstrap_client : public std::enable_shared_from_this <bootstrap_client>
|
||||
{
|
||||
public:
|
||||
bootstrap_client (std::shared_ptr <rai::client>, std::function <void ()> const & = [] () {});
|
||||
bootstrap_client (std::shared_ptr <rai::node>, std::function <void ()> const & = [] () {});
|
||||
~bootstrap_client ();
|
||||
void run (rai::tcp_endpoint const &);
|
||||
void connect_action (boost::system::error_code const &);
|
||||
void sent_request (boost::system::error_code const &, size_t);
|
||||
std::shared_ptr <rai::client> client;
|
||||
std::shared_ptr <rai::node> node;
|
||||
boost::asio::ip::tcp::socket socket;
|
||||
std::function <void ()> completion_action;
|
||||
};
|
||||
|
@ -557,7 +557,7 @@ public:
|
|||
class network
|
||||
{
|
||||
public:
|
||||
network (boost::asio::io_service &, uint16_t, rai::client &);
|
||||
network (boost::asio::io_service &, uint16_t, rai::node &);
|
||||
void receive ();
|
||||
void stop ();
|
||||
void receive_action (boost::system::error_code const &, size_t);
|
||||
|
@ -578,7 +578,7 @@ public:
|
|||
std::mutex socket_mutex;
|
||||
boost::asio::io_service & service;
|
||||
boost::asio::ip::udp::resolver resolver;
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
uint64_t bad_sender_count;
|
||||
std::queue <std::tuple <uint8_t const *, size_t, rai::endpoint, std::function <void (boost::system::error_code const &, size_t)>>> sends;
|
||||
bool on;
|
||||
|
@ -594,20 +594,20 @@ public:
|
|||
class bootstrap_initiator
|
||||
{
|
||||
public:
|
||||
bootstrap_initiator (rai::client &);
|
||||
bootstrap_initiator (rai::node &);
|
||||
void warmup (rai::endpoint const &);
|
||||
void bootstrap (rai::endpoint const &);
|
||||
void bootstrap_any ();
|
||||
void initiate (rai::endpoint const &);
|
||||
std::mutex mutex;
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
bool in_progress;
|
||||
bool warmed_up;
|
||||
};
|
||||
class bootstrap_listener
|
||||
{
|
||||
public:
|
||||
bootstrap_listener (boost::asio::io_service &, uint16_t, rai::client &);
|
||||
bootstrap_listener (boost::asio::io_service &, uint16_t, rai::node &);
|
||||
void start ();
|
||||
void stop ();
|
||||
void accept_connection ();
|
||||
|
@ -616,13 +616,13 @@ public:
|
|||
boost::asio::ip::tcp::acceptor acceptor;
|
||||
rai::tcp_endpoint local;
|
||||
boost::asio::io_service & service;
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
bool on;
|
||||
};
|
||||
class bootstrap_server : public std::enable_shared_from_this <rai::bootstrap_server>
|
||||
{
|
||||
public:
|
||||
bootstrap_server (std::shared_ptr <boost::asio::ip::tcp::socket>, std::shared_ptr <rai::client>);
|
||||
bootstrap_server (std::shared_ptr <boost::asio::ip::tcp::socket>, std::shared_ptr <rai::node>);
|
||||
~bootstrap_server ();
|
||||
void receive ();
|
||||
void receive_header_action (boost::system::error_code const &, size_t);
|
||||
|
@ -634,7 +634,7 @@ public:
|
|||
void run_next ();
|
||||
std::array <uint8_t, 128> receive_buffer;
|
||||
std::shared_ptr <boost::asio::ip::tcp::socket> socket;
|
||||
std::shared_ptr <rai::client> client;
|
||||
std::shared_ptr <rai::node> node;
|
||||
std::mutex mutex;
|
||||
std::queue <std::unique_ptr <rai::message>> requests;
|
||||
};
|
||||
|
@ -684,35 +684,35 @@ public:
|
|||
class rpc
|
||||
{
|
||||
public:
|
||||
rpc (boost::shared_ptr <boost::asio::io_service>, boost::shared_ptr <boost::network::utils::thread_pool>, boost::asio::ip::address_v6 const &, uint16_t, rai::client &, bool);
|
||||
rpc (boost::shared_ptr <boost::asio::io_service>, boost::shared_ptr <boost::network::utils::thread_pool>, boost::asio::ip::address_v6 const &, uint16_t, rai::node &, bool);
|
||||
void start ();
|
||||
void stop ();
|
||||
boost::network::http::server <rai::rpc> server;
|
||||
void operator () (boost::network::http::server <rai::rpc>::request const &, boost::network::http::server <rai::rpc>::response &);
|
||||
void log (const char *) {}
|
||||
rai::client & client;
|
||||
rai::node & node;
|
||||
bool on;
|
||||
bool enable_control;
|
||||
};
|
||||
class client_init
|
||||
class node_init
|
||||
{
|
||||
public:
|
||||
client_init ();
|
||||
node_init ();
|
||||
bool error ();
|
||||
leveldb::Status block_store_init;
|
||||
bool wallet_init;
|
||||
bool ledger_init;
|
||||
};
|
||||
class client : public std::enable_shared_from_this <rai::client>
|
||||
class node : public std::enable_shared_from_this <rai::node>
|
||||
{
|
||||
public:
|
||||
client (rai::client_init &, boost::shared_ptr <boost::asio::io_service>, uint16_t, boost::filesystem::path const &, rai::processor_service &);
|
||||
client (rai::client_init &, boost::shared_ptr <boost::asio::io_service>, uint16_t, rai::processor_service &);
|
||||
~client ();
|
||||
node (rai::node_init &, boost::shared_ptr <boost::asio::io_service>, uint16_t, boost::filesystem::path const &, rai::processor_service &);
|
||||
node (rai::node_init &, boost::shared_ptr <boost::asio::io_service>, uint16_t, rai::processor_service &);
|
||||
~node ();
|
||||
void send_keepalive (rai::endpoint const &);
|
||||
void start ();
|
||||
void stop ();
|
||||
std::shared_ptr <rai::client> shared ();
|
||||
std::shared_ptr <rai::node> shared ();
|
||||
bool representative_vote (rai::election &, rai::block const &);
|
||||
void work_create (rai::block &);
|
||||
void vote (rai::vote const &);
|
||||
|
@ -740,17 +740,17 @@ class system
|
|||
public:
|
||||
system (uint16_t, size_t);
|
||||
~system ();
|
||||
void generate_activity (rai::client &);
|
||||
void generate_mass_activity (uint32_t, rai::client &);
|
||||
void generate_activity (rai::node &);
|
||||
void generate_mass_activity (uint32_t, rai::node &);
|
||||
void generate_usage_traffic (uint32_t, uint32_t, size_t);
|
||||
void generate_usage_traffic (uint32_t, uint32_t);
|
||||
rai::uint128_t get_random_amount (rai::client &);
|
||||
void generate_send_new (rai::client &);
|
||||
void generate_send_existing (rai::client &);
|
||||
rai::uint128_t get_random_amount (rai::node &);
|
||||
void generate_send_new (rai::node &);
|
||||
void generate_send_existing (rai::node &);
|
||||
std::shared_ptr <rai::wallet> wallet (size_t);
|
||||
boost::shared_ptr <boost::asio::io_service> service;
|
||||
rai::processor_service processor;
|
||||
std::vector <std::shared_ptr <rai::client>> clients;
|
||||
std::vector <std::shared_ptr <rai::node>> nodes;
|
||||
};
|
||||
extern std::chrono::milliseconds const confirm_wait;
|
||||
}
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
rai_qt::client::client (QApplication & application_a, rai::client & client_a, rai::uint256_union const & wallet_a) :
|
||||
client_m (client_a),
|
||||
rai_qt::client::client (QApplication & application_a, rai::node & node_a, rai::uint256_union const & wallet_a) :
|
||||
node (node_a),
|
||||
password_change (*this),
|
||||
enter_password (*this),
|
||||
advanced (*this),
|
||||
|
@ -34,10 +34,10 @@ send_count (new QLineEdit),
|
|||
send_blocks_send (new QPushButton ("Send")),
|
||||
send_blocks_back (new QPushButton ("Back"))
|
||||
{
|
||||
wallet = client_m.wallets.open (wallet_a);
|
||||
wallet = node.wallets.open (wallet_a);
|
||||
if (wallet == nullptr)
|
||||
{
|
||||
wallet = client_m.wallets.create (wallet_a);
|
||||
wallet = node.wallets.create (wallet_a);
|
||||
}
|
||||
send_blocks_layout->addWidget (send_account_label);
|
||||
send_blocks_layout->addWidget (send_account);
|
||||
|
@ -157,21 +157,21 @@ send_blocks_back (new QPushButton ("Back"))
|
|||
wallet->store.insert (key.prv);
|
||||
refresh_wallet ();
|
||||
});
|
||||
client_m.send_observers.push_back ([this] (rai::send_block const &, rai::account const & account_a, rai::amount const &)
|
||||
node.send_observers.push_back ([this] (rai::send_block const &, rai::account const & account_a, rai::amount const &)
|
||||
{
|
||||
if (wallet->store.exists (account_a))
|
||||
{
|
||||
refresh_wallet ();
|
||||
}
|
||||
});
|
||||
client_m.receive_observers.push_back ([this] (rai::receive_block const &, rai::account const & account_a, rai::amount const &)
|
||||
node.receive_observers.push_back ([this] (rai::receive_block const &, rai::account const & account_a, rai::amount const &)
|
||||
{
|
||||
if (wallet->store.exists (account_a))
|
||||
{
|
||||
refresh_wallet ();
|
||||
}
|
||||
});
|
||||
client_m.open_observers.push_back ([this] (rai::open_block const &, rai::account const & account_a, rai::amount const &, rai::account const &)
|
||||
node.open_observers.push_back ([this] (rai::open_block const &, rai::account const & account_a, rai::amount const &, rai::account const &)
|
||||
{
|
||||
if (wallet->store.exists (account_a))
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ void rai_qt::client::refresh_wallet ()
|
|||
QList <QStandardItem *> items;
|
||||
std::string account;
|
||||
rai::public_key key (i->first);
|
||||
auto account_balance (client_m.ledger.account_balance (key));
|
||||
auto account_balance (node.ledger.account_balance (key));
|
||||
balance += account_balance;
|
||||
auto balance (std::to_string (rai::scale_down (account_balance)));
|
||||
items.push_back (new QStandardItem (balance.c_str ()));
|
||||
|
@ -457,7 +457,7 @@ client (client_a)
|
|||
});
|
||||
QObject::connect (search_for_receivables, &QPushButton::released, [this] ()
|
||||
{
|
||||
client.client_m.processor.search_pending ();
|
||||
client.node.processor.search_pending ();
|
||||
});
|
||||
QObject::connect (create_block, &QPushButton::released, [this] ()
|
||||
{
|
||||
|
@ -473,7 +473,7 @@ client (client_a)
|
|||
void rai_qt::advanced_actions::refresh_peers ()
|
||||
{
|
||||
QStringList peers;
|
||||
for (auto i: client.client_m.peers.list ())
|
||||
for (auto i: client.node.peers.list ())
|
||||
{
|
||||
std::stringstream endpoint;
|
||||
endpoint << i.endpoint.address ().to_string ();
|
||||
|
@ -492,13 +492,13 @@ void rai_qt::advanced_actions::refresh_peers ()
|
|||
void rai_qt::advanced_actions::refresh_ledger ()
|
||||
{
|
||||
ledger_model->removeRows (0, ledger_model->rowCount ());
|
||||
for (auto i (client.client_m.ledger.store.latest_begin()), j (client.client_m.ledger.store.latest_end ()); i != j; ++i)
|
||||
for (auto i (client.node.ledger.store.latest_begin()), j (client.node.ledger.store.latest_end ()); i != j; ++i)
|
||||
{
|
||||
QList <QStandardItem *> items;
|
||||
std::string account;
|
||||
i->first.encode_base58check (account);
|
||||
items.push_back (new QStandardItem (QString (account.c_str ())));
|
||||
items.push_back (new QStandardItem (QString (std::to_string (rai::scale_down (client.client_m.ledger.balance (i->second.hash))).c_str ())));
|
||||
items.push_back (new QStandardItem (QString (std::to_string (rai::scale_down (client.node.ledger.balance (i->second.hash))).c_str ())));
|
||||
std::string block_hash;
|
||||
i->second.hash.encode_hex (block_hash);
|
||||
items.push_back (new QStandardItem (QString (block_hash.c_str ())));
|
||||
|
@ -531,7 +531,7 @@ client (client_a)
|
|||
auto block_l (rai::deserialize_block_json (tree));
|
||||
if (block_l != nullptr)
|
||||
{
|
||||
client.client_m.processor.process_receive_republish (std::move (block_l));
|
||||
client.node.processor.process_receive_republish (std::move (block_l));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -729,11 +729,11 @@ void rai_qt::block_creation::create_send ()
|
|||
rai::private_key key;
|
||||
if (!client.wallet->store.fetch (account_l, key))
|
||||
{
|
||||
auto balance (client.client_m.ledger.account_balance (account_l));
|
||||
auto balance (client.node.ledger.account_balance (account_l));
|
||||
if (amount_l.number () <= balance)
|
||||
{
|
||||
rai::frontier frontier;
|
||||
auto error (client.client_m.store.latest_get (account_l, frontier));
|
||||
auto error (client.node.store.latest_get (account_l, frontier));
|
||||
assert (!error);
|
||||
rai::send_block send;
|
||||
send.hashables.destination = destination_l;
|
||||
|
@ -741,7 +741,7 @@ void rai_qt::block_creation::create_send ()
|
|||
send.hashables.balance = rai::amount (balance - amount_l.number ());
|
||||
rai::sign_message (key, account_l, send.hash (), send.signature);
|
||||
key.clear ();
|
||||
client.client_m.work_create (send);
|
||||
client.node.work_create (send);
|
||||
std::string block_l;
|
||||
send.serialize_json (block_l);
|
||||
block->setPlainText (QString (block_l.c_str ()));
|
||||
|
@ -786,10 +786,10 @@ void rai_qt::block_creation::create_receive ()
|
|||
if (!error)
|
||||
{
|
||||
rai::receivable receivable;
|
||||
if (!client.client_m.store.pending_get (source_l, receivable))
|
||||
if (!client.node.store.pending_get (source_l, receivable))
|
||||
{
|
||||
rai::frontier frontier;
|
||||
auto error (client.client_m.store.latest_get (receivable.destination, frontier));
|
||||
auto error (client.node.store.latest_get (receivable.destination, frontier));
|
||||
if (!error)
|
||||
{
|
||||
rai::private_key key;
|
||||
|
@ -801,7 +801,7 @@ void rai_qt::block_creation::create_receive ()
|
|||
receive.hashables.source = source_l;
|
||||
rai::sign_message (key, receivable.destination, receive.hash (), receive.signature);
|
||||
key.clear ();
|
||||
client.client_m.work_create (receive);
|
||||
client.node.work_create (receive);
|
||||
std::string block_l;
|
||||
receive.serialize_json (block_l);
|
||||
block->setPlainText (QString (block_l.c_str ()));
|
||||
|
@ -844,7 +844,7 @@ void rai_qt::block_creation::create_change ()
|
|||
if (!error)
|
||||
{
|
||||
rai::frontier frontier;
|
||||
auto error (client.client_m.store.latest_get (account_l, frontier));
|
||||
auto error (client.node.store.latest_get (account_l, frontier));
|
||||
if (!error)
|
||||
{
|
||||
rai::private_key key;
|
||||
|
@ -853,7 +853,7 @@ void rai_qt::block_creation::create_change ()
|
|||
{
|
||||
rai::change_block change (representative_l, frontier.hash, key, account_l);
|
||||
key.clear ();
|
||||
client.client_m.work_create (change);
|
||||
client.node.work_create (change);
|
||||
std::string block_l;
|
||||
change.serialize_json (block_l);
|
||||
block->setPlainText (QString (block_l.c_str ()));
|
||||
|
@ -896,10 +896,10 @@ void rai_qt::block_creation::create_open ()
|
|||
if (!error)
|
||||
{
|
||||
rai::receivable receivable;
|
||||
if (!client.client_m.store.pending_get (source_l, receivable))
|
||||
if (!client.node.store.pending_get (source_l, receivable))
|
||||
{
|
||||
rai::frontier frontier;
|
||||
auto error (client.client_m.store.latest_get (receivable.destination, frontier));
|
||||
auto error (client.node.store.latest_get (receivable.destination, frontier));
|
||||
if (error)
|
||||
{
|
||||
rai::private_key key;
|
||||
|
@ -911,7 +911,7 @@ void rai_qt::block_creation::create_open ()
|
|||
open.hashables.representative = representative_l;
|
||||
rai::sign_message (key, receivable.destination, open.hash (), open.signature);
|
||||
key.clear ();
|
||||
client.client_m.work_create (open);
|
||||
client.node.work_create (open);
|
||||
std::string block_l;
|
||||
open.serialize_json (block_l);
|
||||
block->setPlainText (QString (block_l.c_str ()));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <rai/core/core.hpp>
|
||||
#include <rai/node.hpp>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
|
@ -129,9 +129,9 @@ namespace rai_qt {
|
|||
class client
|
||||
{
|
||||
public:
|
||||
client (QApplication &, rai::client &, rai::uint256_union const &);
|
||||
client (QApplication &, rai::node &, rai::uint256_union const &);
|
||||
~client ();
|
||||
rai::client & client_m;
|
||||
rai::node & node;
|
||||
rai_qt::password_change password_change;
|
||||
rai_qt::enter_password enter_password;
|
||||
rai_qt::advanced_actions advanced;
|
||||
|
|
|
@ -95,8 +95,8 @@ int main (int argc, char * const * argv)
|
|||
QApplication application (argc, const_cast <char **> (argv));
|
||||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::processor_service processor;
|
||||
rai::client_init init;
|
||||
auto client (std::make_shared <rai::client> (init, service, config.peering_port, working, processor));
|
||||
rai::node_init init;
|
||||
auto client (std::make_shared <rai::node> (init, service, config.peering_port, working, processor));
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&] ()
|
||||
{
|
||||
client->stop ();
|
||||
|
|
|
@ -13,7 +13,7 @@ int main (int argc, char ** argv)
|
|||
{
|
||||
rai::uint256_union wallet;
|
||||
rai::random_pool.GenerateBlock (wallet.bytes.data (), wallet.bytes.size ());
|
||||
guis.push_back (std::unique_ptr <rai_qt::client> (new rai_qt::client (application, *system.clients [i], wallet)));
|
||||
guis.push_back (std::unique_ptr <rai_qt::client> (new rai_qt::client (application, *system.nodes [i], wallet)));
|
||||
client_tabs->addTab (guis.back ()->client_window, boost::str (boost::format ("Client %1%") % i).c_str ());
|
||||
}
|
||||
client_tabs->show ();
|
||||
|
@ -41,7 +41,7 @@ int main (int argc, char ** argv)
|
|||
});
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&] ()
|
||||
{
|
||||
for (auto & i: system.clients)
|
||||
for (auto & i: system.nodes)
|
||||
{
|
||||
i->stop ();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ TEST (client, construction)
|
|||
rai::system system (24000, 1);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], rai::uint256_union ());
|
||||
rai_qt::client client (application, *system.nodes [0], rai::uint256_union ());
|
||||
}
|
||||
|
||||
TEST (client, main)
|
||||
|
@ -20,7 +20,7 @@ TEST (client, main)
|
|||
rai::system system (24000, 1);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], rai::uint256_union ());
|
||||
rai_qt::client client (application, *system.nodes [0], rai::uint256_union ());
|
||||
ASSERT_EQ (client.entry_window, client.main_stack->currentWidget ());
|
||||
QTest::mouseClick (client.send_blocks, Qt::LeftButton);
|
||||
ASSERT_EQ (client.send_blocks_window, client.main_stack->currentWidget ());
|
||||
|
@ -48,7 +48,7 @@ TEST (client, password_change)
|
|||
rai::system system (24000, 1);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first);
|
||||
rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first);
|
||||
QTest::mouseClick (client.show_advanced, Qt::LeftButton);
|
||||
QTest::mouseClick (client.advanced.change_password, Qt::LeftButton);
|
||||
ASSERT_NE (system.wallet (0)->store.derive_key ("1"), system.wallet (0)->store.password.value ());
|
||||
|
@ -65,7 +65,7 @@ TEST (client, password_nochange)
|
|||
rai::system system (24000, 1);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first);
|
||||
rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first);
|
||||
QTest::mouseClick (client.show_advanced, Qt::LeftButton);
|
||||
QTest::mouseClick (client.advanced.change_password, Qt::LeftButton);
|
||||
ASSERT_EQ (system.wallet (0)->store.derive_key (""), system.wallet (0)->store.password.value ());
|
||||
|
@ -82,7 +82,7 @@ TEST (client, enter_password)
|
|||
rai::system system (24000, 1);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first);
|
||||
rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first);
|
||||
ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.valid));
|
||||
ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.password));
|
||||
ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.unlock));
|
||||
|
@ -111,17 +111,17 @@ TEST (client, send)
|
|||
system.wallet (1)->store.insert (key1.prv);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first);
|
||||
rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first);
|
||||
QTest::mouseClick (client.send_blocks, Qt::LeftButton);
|
||||
QTest::keyClicks (client.send_account, account.c_str ());
|
||||
QTest::keyClicks (client.send_count, "2");
|
||||
QTest::mouseClick (client.send_blocks_send, Qt::LeftButton);
|
||||
while (client.client_m.ledger.account_balance (key1.pub).is_zero ())
|
||||
while (client.node.ledger.account_balance (key1.pub).is_zero ())
|
||||
{
|
||||
system.service->poll_one ();
|
||||
system.processor.poll_one ();
|
||||
}
|
||||
ASSERT_EQ (rai::scale_up (2), client.client_m.ledger.account_balance (key1.pub));
|
||||
ASSERT_EQ (rai::scale_up (2), client.node.ledger.account_balance (key1.pub));
|
||||
QTest::mouseClick (client.send_blocks_back, Qt::LeftButton);
|
||||
QTest::mouseClick (client.show_advanced, Qt::LeftButton);
|
||||
QTest::mouseClick (client.advanced.show_ledger, Qt::LeftButton);
|
||||
|
@ -138,7 +138,7 @@ TEST (client, process_block)
|
|||
rai::system system (24000, 1);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first);
|
||||
rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first);
|
||||
ASSERT_EQ ("Process", client.block_entry.process->text ());
|
||||
ASSERT_EQ ("Back", client.block_entry.back->text ());
|
||||
rai::keypair key1;
|
||||
|
@ -148,9 +148,9 @@ TEST (client, process_block)
|
|||
ASSERT_EQ (client.block_entry.window, client.main_stack->currentWidget ());
|
||||
rai::send_block send;
|
||||
send.hashables.destination = key1.pub;
|
||||
send.hashables.previous = system.clients [0]->ledger.latest (rai::genesis_account);
|
||||
send.hashables.previous = system.nodes [0]->ledger.latest (rai::genesis_account);
|
||||
send.hashables.balance = 0;
|
||||
system.clients [0]->work_create (send);
|
||||
system.nodes [0]->work_create (send);
|
||||
rai::sign_message (rai::test_genesis_key.prv, rai::test_genesis_key.pub, send.hash (), send.signature);
|
||||
std::string destination;
|
||||
send.hashables.destination.encode_base58check (destination);
|
||||
|
@ -163,7 +163,7 @@ TEST (client, process_block)
|
|||
auto block_json (boost::str (boost::format ("{\"type\": \"send\", \"previous\": \"%1%\", \"balance\": \"%2%\", \"destination\": \"%3%\", \"work\": \"%4%\", \"signature\": \"%5%\"}") % previous % balance % destination % rai::to_string_hex (send.work) % signature));
|
||||
QTest::keyClicks (client.block_entry.block, block_json.c_str ());
|
||||
QTest::mouseClick (client.block_entry.process, Qt::LeftButton);
|
||||
ASSERT_EQ (send.hash (), system.clients [0]->ledger.latest (rai::genesis_account));
|
||||
ASSERT_EQ (send.hash (), system.nodes [0]->ledger.latest (rai::genesis_account));
|
||||
QTest::mouseClick(client.block_entry.back, Qt::LeftButton);
|
||||
ASSERT_EQ (client.advanced.window, client.main_stack->currentWidget ());
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ TEST (client, create_send)
|
|||
system.wallet (0)->store.insert (key.prv);
|
||||
int argc (0);
|
||||
QApplication application (argc, nullptr);
|
||||
rai_qt::client client (application, *system.clients [0], system.clients [0]->wallets.items.begin ()->first);
|
||||
rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first);
|
||||
QTest::mouseClick (client.show_advanced, Qt::LeftButton);
|
||||
QTest::mouseClick (client.advanced.create_block, Qt::LeftButton);
|
||||
QTest::mouseClick (client.block_creation.send, Qt::LeftButton);
|
||||
|
@ -195,6 +195,6 @@ TEST (client, create_send)
|
|||
std::stringstream istream (json);
|
||||
boost::property_tree::read_json (istream, tree1);
|
||||
ASSERT_FALSE (send.deserialize_json (tree1));
|
||||
ASSERT_EQ (rai::process_result::progress, system.clients [0]->ledger.process (send));
|
||||
ASSERT_EQ (rai::process_result::old, system.clients [0]->ledger.process (send));
|
||||
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (send));
|
||||
ASSERT_EQ (rai::process_result::old, system.nodes [0]->ledger.process (send));
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <rai/core/core.hpp>
|
||||
#include <rai/node.hpp>
|
||||
|
||||
#include <thread>
|
||||
|
||||
|
@ -8,9 +8,9 @@ TEST (system, generate_mass_activity)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
size_t count (20);
|
||||
system.generate_mass_activity (count, *system.clients [0]);
|
||||
system.generate_mass_activity (count, *system.nodes [0]);
|
||||
size_t accounts (0);
|
||||
for (auto i (system.clients [0]->store.latest_begin ()), n (system.clients [0]->store.latest_end ()); i != n; ++i)
|
||||
for (auto i (system.nodes [0]->store.latest_begin ()), n (system.nodes [0]->store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
++accounts;
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ TEST (system, generate_mass_activity_long)
|
|||
rai::system system (24000, 1);
|
||||
system.wallet (0)->store.insert (rai::test_genesis_key.prv);
|
||||
size_t count (10000);
|
||||
system.generate_mass_activity (count, *system.clients [0]);
|
||||
system.generate_mass_activity (count, *system.nodes [0]);
|
||||
size_t accounts (0);
|
||||
for (auto i (system.clients [0]->store.latest_begin ()), n (system.clients [0]->store.latest_end ()); i != n; ++i)
|
||||
for (auto i (system.nodes [0]->store.latest_begin ()), n (system.nodes [0]->store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
++accounts;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue