aboutsummaryrefslogtreecommitdiff
path: root/tests/libwallet_api_tests/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libwallet_api_tests/main.cpp')
-rw-r--r--tests/libwallet_api_tests/main.cpp59
1 files changed, 30 insertions, 29 deletions
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp
index cb1169df3..f33f41fa4 100644
--- a/tests/libwallet_api_tests/main.cpp
+++ b/tests/libwallet_api_tests/main.cpp
@@ -34,18 +34,19 @@
#include "wallet/wallet2.h"
#include "include_base_utils.h"
+#include <boost/chrono/chrono.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
#include <iostream>
#include <vector>
-#include <mutex>
-#include <thread>
#include <atomic>
#include <functional>
-#include <condition_variable>
using namespace std;
@@ -254,15 +255,15 @@ TEST_F(WalletManagerTest, WalletAmountFromString)
}
-void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, const std::string &pass, std::mutex *mutex)
+void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, const std::string &pass, boost::mutex *mutex)
{
if (mutex)
mutex->lock();
- LOG_PRINT_L3("opening wallet in thread: " << std::this_thread::get_id());
+ LOG_PRINT_L3("opening wallet in thread: " << boost::this_thread::get_id());
*wallet = wmgr->openWallet(WALLET_NAME, pass, true);
LOG_PRINT_L3("wallet address: " << (*wallet)->address());
LOG_PRINT_L3("wallet status: " << (*wallet)->status());
- LOG_PRINT_L3("closing wallet in thread: " << std::this_thread::get_id());
+ LOG_PRINT_L3("closing wallet in thread: " << boost::this_thread::get_id());
if (mutex)
mutex->unlock();
}
@@ -307,7 +308,7 @@ TEST_F(WalletManagerTest, WalletManagerOpensWalletWithPasswordAndReopen)
Monero::Wallet *wallet2 = nullptr;
Monero::Wallet *wallet3 = nullptr;
- std::mutex mutex;
+ boost::mutex mutex;
open_wallet_helper(wmgr, &wallet2, wrong_wallet_pass, nullptr);
ASSERT_TRUE(wallet2 != nullptr);
@@ -785,12 +786,12 @@ struct MyWalletListener : public Monero::WalletListener
Monero::Wallet * wallet;
uint64_t total_tx;
uint64_t total_rx;
- std::mutex mutex;
- std::condition_variable cv_send;
- std::condition_variable cv_receive;
- std::condition_variable cv_update;
- std::condition_variable cv_refresh;
- std::condition_variable cv_newblock;
+ boost::mutex mutex;
+ boost::condition_variable cv_send;
+ boost::condition_variable cv_receive;
+ boost::condition_variable cv_update;
+ boost::condition_variable cv_refresh;
+ boost::condition_variable cv_newblock;
bool send_triggered;
bool receive_triggered;
bool newblock_triggered;
@@ -880,8 +881,8 @@ TEST_F(WalletTest2, WalletCallBackRefreshedSync)
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
ASSERT_TRUE(wallet_src_listener->refresh_triggered);
ASSERT_TRUE(wallet_src->connected());
- std::chrono::seconds wait_for = std::chrono::seconds(60*3);
- std::unique_lock<std::mutex> lock (wallet_src_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(60*3);
+ boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
wallet_src_listener->cv_refresh.wait_for(lock, wait_for);
wmgr->closeWallet(wallet_src);
}
@@ -895,8 +896,8 @@ TEST_F(WalletTest2, WalletCallBackRefreshedAsync)
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
- std::chrono::seconds wait_for = std::chrono::seconds(20);
- std::unique_lock<std::mutex> lock (wallet_src_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(20);
+ boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
wallet_src->init(MAINNET_DAEMON_ADDRESS, 0);
wallet_src->startRefresh();
std::cerr << "TEST: waiting on refresh lock...\n";
@@ -936,8 +937,8 @@ TEST_F(WalletTest2, WalletCallbackSent)
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
- std::chrono::seconds wait_for = std::chrono::seconds(60*3);
- std::unique_lock<std::mutex> lock (wallet_src_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(60*3);
+ boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
std::cerr << "TEST: waiting on send lock...\n";
wallet_src_listener->cv_send.wait_for(lock, wait_for);
std::cerr << "TEST: send lock acquired...\n";
@@ -978,8 +979,8 @@ TEST_F(WalletTest2, WalletCallbackReceived)
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
ASSERT_TRUE(tx->commit());
- std::chrono::seconds wait_for = std::chrono::seconds(60*4);
- std::unique_lock<std::mutex> lock (wallet_dst_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(60*4);
+ boost::unique_lock<boost::mutex> lock (wallet_dst_listener->mutex);
std::cerr << "TEST: waiting on receive lock...\n";
wallet_dst_listener->cv_receive.wait_for(lock, wait_for);
std::cerr << "TEST: receive lock acquired...\n";
@@ -1011,8 +1012,8 @@ TEST_F(WalletTest2, WalletCallbackNewBlock)
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet_src));
// wait max 4 min for new block
- std::chrono::seconds wait_for = std::chrono::seconds(60*4);
- std::unique_lock<std::mutex> lock (wallet_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(60*4);
+ boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
std::cerr << "TEST: waiting on newblock lock...\n";
wallet_listener->cv_newblock.wait_for(lock, wait_for);
std::cerr << "TEST: newblock lock acquired...\n";
@@ -1049,8 +1050,8 @@ TEST_F(WalletManagerMainnetTest, CreateAndRefreshWalletMainNetAsync)
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG);
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
- std::chrono::seconds wait_for = std::chrono::seconds(SECONDS_TO_REFRESH);
- std::unique_lock<std::mutex> lock (wallet_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
+ boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
wallet->init(MAINNET_DAEMON_ADDRESS, 0);
wallet->startRefresh();
std::cerr << "TEST: waiting on refresh lock...\n";
@@ -1075,8 +1076,8 @@ TEST_F(WalletManagerMainnetTest, OpenAndRefreshWalletMainNetAsync)
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
- std::chrono::seconds wait_for = std::chrono::seconds(SECONDS_TO_REFRESH);
- std::unique_lock<std::mutex> lock (wallet_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
+ boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
wallet->init(MAINNET_DAEMON_ADDRESS, 0);
wallet->startRefresh();
std::cerr << "TEST: waiting on refresh lock...\n";
@@ -1109,8 +1110,8 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
ASSERT_TRUE(wallet->address() == address);
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
- std::chrono::seconds wait_for = std::chrono::seconds(SECONDS_TO_REFRESH);
- std::unique_lock<std::mutex> lock (wallet_listener->mutex);
+ boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
+ boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
wallet->init(MAINNET_DAEMON_ADDRESS, 0);
wallet->startRefresh();
std::cerr << "TEST: waiting on refresh lock...\n";