|
|
@ -36,6 +36,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
|
|
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
@ -63,29 +65,28 @@ const char * WALLET_PASS = "password";
|
|
|
|
const char * WALLET_PASS2 = "password22";
|
|
|
|
const char * WALLET_PASS2 = "password22";
|
|
|
|
const char * WALLET_LANG = "English";
|
|
|
|
const char * WALLET_LANG = "English";
|
|
|
|
|
|
|
|
|
|
|
|
// change this according your environment
|
|
|
|
std::string WALLETS_ROOT_DIR = "/var/monero/testnet_pvt";
|
|
|
|
|
|
|
|
std::string TESTNET_WALLET1_NAME;
|
|
|
|
const std::string WALLETS_ROOT_DIR = "/home/mbg033/dev/monero/testnet/";
|
|
|
|
std::string TESTNET_WALLET2_NAME;
|
|
|
|
|
|
|
|
std::string TESTNET_WALLET3_NAME;
|
|
|
|
const std::string TESTNET_WALLET1_NAME = WALLETS_ROOT_DIR + "wallet_01.bin";
|
|
|
|
std::string TESTNET_WALLET4_NAME;
|
|
|
|
const std::string TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "wallet_02.bin";
|
|
|
|
std::string TESTNET_WALLET5_NAME;
|
|
|
|
const std::string TESTNET_WALLET3_NAME = WALLETS_ROOT_DIR + "wallet_03.bin";
|
|
|
|
std::string TESTNET_WALLET6_NAME;
|
|
|
|
const std::string TESTNET_WALLET4_NAME = WALLETS_ROOT_DIR + "wallet_04.bin";
|
|
|
|
|
|
|
|
const std::string TESTNET_WALLET5_NAME = WALLETS_ROOT_DIR + "wallet_05.bin";
|
|
|
|
|
|
|
|
const std::string TESTNET_WALLET6_NAME = WALLETS_ROOT_DIR + "wallet_06.bin";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * TESTNET_WALLET_PASS = "";
|
|
|
|
const char * TESTNET_WALLET_PASS = "";
|
|
|
|
|
|
|
|
|
|
|
|
const std::string CURRENT_SRC_WALLET = TESTNET_WALLET1_NAME;
|
|
|
|
std::string CURRENT_SRC_WALLET;
|
|
|
|
const std::string CURRENT_DST_WALLET = TESTNET_WALLET6_NAME;
|
|
|
|
std::string CURRENT_DST_WALLET;
|
|
|
|
|
|
|
|
|
|
|
|
const char * TESTNET_DAEMON_ADDRESS = "localhost:38081";
|
|
|
|
|
|
|
|
const uint64_t AMOUNT_10XMR = 10000000000000L;
|
|
|
|
const uint64_t AMOUNT_10XMR = 10000000000000L;
|
|
|
|
const uint64_t AMOUNT_5XMR = 5000000000000L;
|
|
|
|
const uint64_t AMOUNT_5XMR = 5000000000000L;
|
|
|
|
const uint64_t AMOUNT_1XMR = 1000000000000L;
|
|
|
|
const uint64_t AMOUNT_1XMR = 1000000000000L;
|
|
|
|
|
|
|
|
|
|
|
|
const std::string PAYMENT_ID_EMPTY = "";
|
|
|
|
const std::string PAYMENT_ID_EMPTY = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string TESTNET_DAEMON_ADDRESS = "localhost:38081";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -179,10 +180,8 @@ struct WalletTest2 : public testing::Test
|
|
|
|
wmgr = Bitmonero::WalletManagerFactory::getWalletManager();
|
|
|
|
wmgr = Bitmonero::WalletManagerFactory::getWalletManager();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
|
|
|
|
TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
@ -220,6 +219,7 @@ TEST_F(WalletManagerTest, WalletMaxAmountAsString)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletAmountFromString)
|
|
|
|
TEST_F(WalletManagerTest, WalletAmountFromString)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint64_t amount = Bitmonero::Wallet::amountFromString("18446740");
|
|
|
|
uint64_t amount = Bitmonero::Wallet::amountFromString("18446740");
|
|
|
@ -394,6 +394,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2)
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
|
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
|
|
@ -406,7 +407,8 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
|
|
|
|
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR_NON_WRITABLE, WALLET_PASS);
|
|
|
|
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR_NON_WRITABLE, WALLET_PASS);
|
|
|
|
ASSERT_FALSE(wallet1->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
ASSERT_FALSE(wallet1->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
|
|
|
|
|
|
|
|
ASSERT_FALSE(wmgr->closeWallet(wallet1));
|
|
|
|
// "close" always returns true;
|
|
|
|
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
|
|
|
|
|
|
|
|
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
|
|
|
|
wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
|
|
|
|
ASSERT_TRUE(wallet1->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
ASSERT_TRUE(wallet1->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
@ -416,6 +418,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet4)
|
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet4)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
|
|
@ -451,14 +454,14 @@ TEST_F(WalletManagerTest, WalletManagerFindsWallet)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletGeneratesPaymentId)
|
|
|
|
TEST_F(WalletTest1, WalletGeneratesPaymentId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
|
|
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
|
|
|
ASSERT_TRUE(payment_id.length() == 16);
|
|
|
|
ASSERT_TRUE(payment_id.length() == 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletGeneratesIntegratedAddress)
|
|
|
|
TEST_F(WalletTest1, WalletGeneratesIntegratedAddress)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
|
|
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
|
|
|
|
|
|
|
|
|
|
@ -490,6 +493,7 @@ TEST_F(WalletTest1, WalletShowsBalance)
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletTest1, WalletRefresh)
|
|
|
|
TEST_F(WalletTest1, WalletRefresh)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
|
|
|
// make sure testnet daemon is running
|
|
|
|
// make sure testnet daemon is running
|
|
|
|
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
|
|
|
|
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
|
|
|
@ -497,7 +501,6 @@ TEST_F(WalletTest1, WalletRefresh)
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletTest1, WalletConvertsToString)
|
|
|
|
TEST_F(WalletTest1, WalletConvertsToString)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string strAmount = Bitmonero::Wallet::displayAmount(AMOUNT_5XMR);
|
|
|
|
std::string strAmount = Bitmonero::Wallet::displayAmount(AMOUNT_5XMR);
|
|
|
@ -512,6 +515,7 @@ TEST_F(WalletTest1, WalletConvertsToString)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletTest1, WalletTransaction)
|
|
|
|
TEST_F(WalletTest1, WalletTransaction)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
|
|
|
// make sure testnet daemon is running
|
|
|
|
// make sure testnet daemon is running
|
|
|
@ -538,6 +542,8 @@ TEST_F(WalletTest1, WalletTransaction)
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletTest1, WalletTransactionWithMixin)
|
|
|
|
TEST_F(WalletTest1, WalletTransactionWithMixin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
@ -792,6 +798,8 @@ struct MyWalletListener : public Bitmonero::WalletListener
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletTest2, WalletCallBackRefreshedSync)
|
|
|
|
TEST_F(WalletTest2, WalletCallBackRefreshedSync)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
@ -800,13 +808,15 @@ TEST_F(WalletTest2, WalletCallBackRefreshedSync)
|
|
|
|
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
|
|
|
|
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
|
|
|
|
ASSERT_TRUE(wallet_src_listener->refresh_triggered);
|
|
|
|
ASSERT_TRUE(wallet_src_listener->refresh_triggered);
|
|
|
|
ASSERT_TRUE(wallet_src->connected());
|
|
|
|
ASSERT_TRUE(wallet_src->connected());
|
|
|
|
// std::chrono::seconds wait_for = std::chrono::seconds(60*3);
|
|
|
|
std::chrono::seconds wait_for = std::chrono::seconds(60*3);
|
|
|
|
// std::unique_lock<std::mutex> lock (wallet_src_listener->mutex);
|
|
|
|
std::unique_lock<std::mutex> lock (wallet_src_listener->mutex);
|
|
|
|
// wallet_src_listener->cv_refresh.wait_for(lock, wait_for);
|
|
|
|
wallet_src_listener->cv_refresh.wait_for(lock, wait_for);
|
|
|
|
wmgr->closeWallet(wallet_src);
|
|
|
|
wmgr->closeWallet(wallet_src);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletTest2, WalletCallBackRefreshedAsync)
|
|
|
|
TEST_F(WalletTest2, WalletCallBackRefreshedAsync)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
@ -908,10 +918,32 @@ TEST_F(WalletTest2, WalletCallbackReceived)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// we can override default values for "TESTNET_DAEMON_ADDRESS" and "WALLETS_ROOT_DIR"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * monero_daemon_addr = std::getenv("TESTNET_DAEMON_ADDRESS");
|
|
|
|
|
|
|
|
if (monero_daemon_addr) {
|
|
|
|
|
|
|
|
TESTNET_DAEMON_ADDRESS = monero_daemon_addr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * wallets_root_dir = std::getenv("WALLETS_ROOT_DIR");
|
|
|
|
|
|
|
|
if (wallets_root_dir) {
|
|
|
|
|
|
|
|
WALLETS_ROOT_DIR = wallets_root_dir;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TESTNET_WALLET1_NAME = WALLETS_ROOT_DIR + "/wallet_01.bin";
|
|
|
|
|
|
|
|
TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "/wallet_02.bin";
|
|
|
|
|
|
|
|
TESTNET_WALLET3_NAME = WALLETS_ROOT_DIR + "/wallet_03.bin";
|
|
|
|
|
|
|
|
TESTNET_WALLET4_NAME = WALLETS_ROOT_DIR + "/wallet_04.bin";
|
|
|
|
|
|
|
|
TESTNET_WALLET5_NAME = WALLETS_ROOT_DIR + "/wallet_05.bin";
|
|
|
|
|
|
|
|
TESTNET_WALLET6_NAME = WALLETS_ROOT_DIR + "/wallet_06.bin";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CURRENT_SRC_WALLET = TESTNET_WALLET6_NAME;
|
|
|
|
|
|
|
|
CURRENT_DST_WALLET = TESTNET_WALLET5_NAME;
|
|
|
|
|
|
|
|
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
|
|
|
|
// Bitmonero::WalletManagerFactory::setLogLevel(Bitmonero::WalletManagerFactory::LogLevel_Max);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|
|
|
|
}
|
|
|
|