From 2cce32995b840901ce656dd8ec3fcefefff706bf Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Mon, 21 Mar 2016 16:17:03 +0300 Subject: wallet2::store() implemented within wallet2::store_to --- tests/libwallet_api_tests/main.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 9701c300c..da2624387 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -165,6 +165,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet1) ASSERT_TRUE(wmgr->closeWallet(wallet2)); } + TEST_F(WalletManagerTest, WalletManagerStoresWallet2) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -181,6 +182,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } + TEST_F(WalletManagerTest, WalletManagerStoresWallet3) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -204,6 +206,29 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3) } +TEST_F(WalletManagerTest, WalletManagerStoresWallet4) +{ + Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); + std::string seed1 = wallet1->seed(); + std::string address1 = wallet1->address(); + + ASSERT_TRUE(wallet1->store("")); + ASSERT_TRUE(wallet1->status() == Bitmonero::Wallet::Status_Ok); + + ASSERT_TRUE(wallet1->store("")); + ASSERT_TRUE(wallet1->status() == Bitmonero::Wallet::Status_Ok); + + ASSERT_TRUE(wmgr->closeWallet(wallet1)); + + wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS); + ASSERT_TRUE(wallet1->status() == Bitmonero::Wallet::Status_Ok); + ASSERT_TRUE(wallet1->seed() == seed1); + ASSERT_TRUE(wallet1->address() == address1); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); + +} + + int main(int argc, char** argv) { //epee::debug::get_set_enable_assert(true, false); -- cgit v1.2.3 From 8790904cf9ccba56a1cbab51b01f2cbb0a5cb143 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 25 Mar 2016 17:06:30 +0300 Subject: - testnet option added to api; --- tests/libwallet_api_tests/main.cpp | 68 ++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index da2624387..841b5df27 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -41,6 +41,23 @@ using namespace std; //unsigned int epee::g_test_dbg_lock_sleep = 0; +struct Utils +{ + static void deleteWallet(const std::string & walletname) + { + std::cout << "** deleting wallet: " << walletname << std::endl; + boost::filesystem::remove(walletname); + boost::filesystem::remove(walletname + ".address.txt"); + boost::filesystem::remove(walletname + ".keys"); + } + + static void deleteDir(const std::string &path) + { + std::cout << "** removing dir recursively: " << path << std::endl; + boost::filesystem::remove_all(path); + } +}; + struct WalletManagerTest : public testing::Test { @@ -54,12 +71,16 @@ struct WalletManagerTest : public testing::Test const char * WALLET_PASS2 = "password22"; const char * WALLET_LANG = "English"; + // TODO: add test wallets to the source tree (as they have some balance mined)? + const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; + const char * TESTNET_WALLET_PASS = ""; + WalletManagerTest() { std::cout << __FUNCTION__ << std::endl; wmgr = Bitmonero::WalletManagerFactory::getWalletManager(); - deleteWallet(WALLET_NAME); - deleteDir(boost::filesystem::path(WALLET_NAME_WITH_DIR).parent_path().string()); + Utils::deleteWallet(WALLET_NAME); + Utils::deleteDir(boost::filesystem::path(WALLET_NAME_WITH_DIR).parent_path().string()); } @@ -68,29 +89,13 @@ struct WalletManagerTest : public testing::Test std::cout << __FUNCTION__ << std::endl; //deleteWallet(WALLET_NAME); } - - - void deleteWallet(const std::string & walletname) - { - std::cout << "** deleting wallet: " << walletname << std::endl; - boost::filesystem::remove(walletname); - boost::filesystem::remove(walletname + ".address.txt"); - boost::filesystem::remove(walletname + ".keys"); - } - - void deleteDir(const std::string &path) - { - std::cout << "** removing dir recursively: " << path << std::endl; - boost::filesystem::remove_all(path); - } - }; TEST_F(WalletManagerTest, WalletManagerCreatesWallet) { - Bitmonero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); + Bitmonero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, true); ASSERT_TRUE(wallet->status() == Bitmonero::Wallet::Status_Ok); ASSERT_TRUE(!wallet->seed().empty()); std::vector words; @@ -107,16 +112,16 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet) TEST_F(WalletManagerTest, WalletManagerOpensWallet) { - Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); + Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, true); std::string seed1 = wallet1->seed(); ASSERT_TRUE(wmgr->closeWallet(wallet1)); - Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS); + Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, true); ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok); ASSERT_TRUE(wallet2->seed() == seed1); std::cout << "** seed: " << wallet2->seed() << std::endl; } - +/* TEST_F(WalletManagerTest, WalletManagerChangesPassword) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -182,7 +187,6 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } - TEST_F(WalletManagerTest, WalletManagerStoresWallet3) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -205,7 +209,6 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3) } - TEST_F(WalletManagerTest, WalletManagerStoresWallet4) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -225,7 +228,24 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet4) ASSERT_TRUE(wallet1->seed() == seed1); ASSERT_TRUE(wallet1->address() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet1)); +} +*/ + +TEST_F(WalletManagerTest, WalletShowsBalance) +{ + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + std::string seed1 = wallet1->seed(); + std::string address1 = wallet1->address(); + ASSERT_TRUE(wallet1->balance() > 0); + + uint64_t balance1 = wallet1->balance(); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); + Bitmonero::Wallet * wallet2 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + ASSERT_TRUE(seed1 == wallet2->seed()); + ASSERT_TRUE(address1 == wallet2->address()); + ASSERT_TRUE(balance1 == wallet2->balance()); + ASSERT_TRUE(wmgr->closeWallet(wallet2)); } -- cgit v1.2.3 From 2157a9ac4876c2f50421d0e5ad13be3123ff1201 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Thu, 31 Mar 2016 12:48:41 +0300 Subject: testnet option, Wallet::balance(), Wallet::unlockedBalance() --- tests/libwallet_api_tests/main.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 841b5df27..d5bdc8d67 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -95,7 +95,7 @@ struct WalletManagerTest : public testing::Test TEST_F(WalletManagerTest, WalletManagerCreatesWallet) { - Bitmonero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, true); + Bitmonero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); ASSERT_TRUE(wallet->status() == Bitmonero::Wallet::Status_Ok); ASSERT_TRUE(!wallet->seed().empty()); std::vector words; @@ -112,16 +112,16 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet) TEST_F(WalletManagerTest, WalletManagerOpensWallet) { - Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG, true); + Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); ASSERT_TRUE(wmgr->closeWallet(wallet1)); - Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, true); + Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS); ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok); ASSERT_TRUE(wallet2->seed() == seed1); std::cout << "** seed: " << wallet2->seed() << std::endl; } -/* + TEST_F(WalletManagerTest, WalletManagerChangesPassword) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -145,7 +145,7 @@ TEST_F(WalletManagerTest, WalletManagerRecoversWallet) std::string address1 = wallet1->address(); ASSERT_FALSE(address1.empty()); ASSERT_TRUE(wmgr->closeWallet(wallet1)); - deleteWallet(WALLET_NAME); + Utils::deleteWallet(WALLET_NAME); Bitmonero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1); ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok); ASSERT_TRUE(wallet2->seed() == seed1); @@ -229,22 +229,23 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet4) ASSERT_TRUE(wallet1->address() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -*/ + TEST_F(WalletManagerTest, WalletShowsBalance) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); - std::string seed1 = wallet1->seed(); - std::string address1 = wallet1->address(); ASSERT_TRUE(wallet1->balance() > 0); + ASSERT_TRUE(wallet1->unlockedBalance() > 0); uint64_t balance1 = wallet1->balance(); + uint64_t unlockedBalance1 = wallet1->unlockedBalance(); ASSERT_TRUE(wmgr->closeWallet(wallet1)); - Bitmonero::Wallet * wallet2 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); - ASSERT_TRUE(seed1 == wallet2->seed()); - ASSERT_TRUE(address1 == wallet2->address()); + ASSERT_TRUE(balance1 == wallet2->balance()); + std::cout << "wallet balance: " << wallet2->balance() << std::endl; + ASSERT_TRUE(unlockedBalance1 == wallet2->unlockedBalance()); + std::cout << "wallet unlocked balance: " << wallet2->unlockedBalance() << std::endl; ASSERT_TRUE(wmgr->closeWallet(wallet2)); } -- cgit v1.2.3 From 830c19c934f1c621cf8f268772d5ab92f35d75b3 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Thu, 31 Mar 2016 16:38:57 +0300 Subject: Wallet::refresh + tests --- tests/libwallet_api_tests/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index d5bdc8d67..d935a38b7 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -71,10 +71,13 @@ struct WalletManagerTest : public testing::Test const char * WALLET_PASS2 = "password22"; const char * WALLET_LANG = "English"; + // TODO: add test wallets to the source tree (as they have some balance mined)? const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; const char * TESTNET_WALLET_PASS = ""; + const char * TESTNET_DAEMON_ADDRESS = "localhost:38081"; + WalletManagerTest() { std::cout << __FUNCTION__ << std::endl; @@ -249,6 +252,15 @@ TEST_F(WalletManagerTest, WalletShowsBalance) ASSERT_TRUE(wmgr->closeWallet(wallet2)); } +TEST_F(WalletManagerTest, WalletRefresh) +{ + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + // make sure testnet daemon is running + ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet1->refresh()); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); +} + int main(int argc, char** argv) { -- cgit v1.2.3 From ee5bb17f26390ceb55dd277932585b0020077e9e Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Mon, 4 Apr 2016 14:56:17 +0300 Subject: Wallet::transfer() continued --- tests/libwallet_api_tests/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index d935a38b7..970d9a74e 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -77,6 +77,9 @@ struct WalletManagerTest : public testing::Test const char * TESTNET_WALLET_PASS = ""; const char * TESTNET_DAEMON_ADDRESS = "localhost:38081"; + const uint64_t AMOUNT_10XMR = 10000000000000L; + const uint64_t AMOUNT_5XMR = 50000000000000L; + const char * RECIPIENT_WALLET_ADDRESS = "9uekQVGj7NjSAREnZ8cUsRagWDdjvdhpwUKhsL95oXngBnZXZ1RzH8R6UJbU1R7wim9yKbSjxuoQ22ERRkEochGECj66oP3"; WalletManagerTest() { @@ -261,6 +264,19 @@ TEST_F(WalletManagerTest, WalletRefresh) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } +TEST_F(WalletManagerTest, WalletTransfer) +{ + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + // make sure testnet daemon is running + ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet1->refresh()); + uint64_t balance = wallet1->balance(); + ASSERT_TRUE(wallet1->transfer(RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR)); + ASSERT_FALSE(wallet1->balance() == balance); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); +} + + int main(int argc, char** argv) { -- cgit v1.2.3 From 079fbd3d42f74d9bdc268c83677878b9ac5c1047 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 5 Apr 2016 15:24:44 +0300 Subject: Wallet::createTransaction API introduced --- tests/libwallet_api_tests/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 970d9a74e..f073b47b9 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -264,14 +264,20 @@ TEST_F(WalletManagerTest, WalletRefresh) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -TEST_F(WalletManagerTest, WalletTransfer) +TEST_F(WalletManagerTest, WalletTransaction) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); uint64_t balance = wallet1->balance(); - ASSERT_TRUE(wallet1->transfer(RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR)); + + Bitmonero::Transaction * transaction = wallet1->createTransaction( + RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR); + ASSERT_TRUE(transaction->status() == Bitmonero::Transaction::Status_Ok); + + ASSERT_TRUE(wallet1->balance() == balance); + ASSERT_TRUE(transaction->commit()); ASSERT_FALSE(wallet1->balance() == balance); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -- cgit v1.2.3 From d97e9ef8a55f92841b30dd31807beb1c06ec264b Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Wed, 6 Apr 2016 13:56:57 +0300 Subject: Transaction API continued --- tests/libwallet_api_tests/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index f073b47b9..6e993d70c 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -271,12 +271,14 @@ TEST_F(WalletManagerTest, WalletTransaction) ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); uint64_t balance = wallet1->balance(); + ASSERT_TRUE(wallet1->status() == Bitmonero::Transaction::Status_Ok); Bitmonero::Transaction * transaction = wallet1->createTransaction( RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR); ASSERT_TRUE(transaction->status() == Bitmonero::Transaction::Status_Ok); ASSERT_TRUE(wallet1->balance() == balance); + ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR); ASSERT_TRUE(transaction->commit()); ASSERT_FALSE(wallet1->balance() == balance); ASSERT_TRUE(wmgr->closeWallet(wallet1)); -- cgit v1.2.3 From 1774d9574b5c6ebc55b3f4a6adf82d995bfad42f Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 12 Apr 2016 22:30:20 +0300 Subject: TODOs for Transaction/Transfer interface --- tests/libwallet_api_tests/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 6e993d70c..dee874cd6 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -271,11 +271,11 @@ TEST_F(WalletManagerTest, WalletTransaction) ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); uint64_t balance = wallet1->balance(); - ASSERT_TRUE(wallet1->status() == Bitmonero::Transaction::Status_Ok); + ASSERT_TRUE(wallet1->status() == Bitmonero::PendingTransaction::Status_Ok); - Bitmonero::Transaction * transaction = wallet1->createTransaction( + Bitmonero::PendingTransaction * transaction = wallet1->createTransaction( RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR); - ASSERT_TRUE(transaction->status() == Bitmonero::Transaction::Status_Ok); + ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok); ASSERT_TRUE(wallet1->balance() == balance); ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR); @@ -288,7 +288,7 @@ TEST_F(WalletManagerTest, WalletTransaction) int main(int argc, char** argv) { - //epee::debug::get_set_enable_assert(true, false); + ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } -- cgit v1.2.3 From 02c9df5de247d6f8fb95e1b9272cef2b37be10f8 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 22 Apr 2016 13:21:08 +0300 Subject: Wallet API : transaction history in progress --- tests/libwallet_api_tests/main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index dee874cd6..6921e6c3a 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -29,7 +29,10 @@ // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include "gtest/gtest.h" + #include "wallet/wallet2_api.h" +#include "cryptonote_core/cryptonote_format_utils.h" + #include #include @@ -284,6 +287,31 @@ TEST_F(WalletManagerTest, WalletTransaction) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } +TEST_F(WalletManagerTest, WalletHistory) +{ + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + // make sure testnet daemon is running + ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet1->refresh()); + Bitmonero::TransactionHistory * history = wallet1->history(); + history->refresh(); + ASSERT_TRUE(history->count() > 0); + auto transaction_print = [=] (Bitmonero::TransactionInfo * t) { + std::cout << "d: " + << (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out") + << ", a: " << t->amount() + << ", h: " << t->hash() + << std::endl; + }; + + for (auto t: history->getAll()) { + ASSERT_TRUE(t != nullptr); + transaction_print(t); + } + + +} + int main(int argc, char** argv) -- cgit v1.2.3 From 53a97bdcd381342bc7d738946a628654a2261a52 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 22 Apr 2016 13:33:09 +0300 Subject: Wallet API: transaction history in progress --- tests/libwallet_api_tests/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 6921e6c3a..51c0a3ca3 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -31,7 +31,6 @@ #include "gtest/gtest.h" #include "wallet/wallet2_api.h" -#include "cryptonote_core/cryptonote_format_utils.h" #include #include @@ -299,8 +298,11 @@ TEST_F(WalletManagerTest, WalletHistory) auto transaction_print = [=] (Bitmonero::TransactionInfo * t) { std::cout << "d: " << (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out") - << ", a: " << t->amount() + << ", bh: " << t->blockHeight() + << ", a: " << Bitmonero::Wallet::displayAmount(t->amount()) + << ", f: " << Bitmonero::Wallet::displayAmount(t->fee()) << ", h: " << t->hash() + << ", pid: " << t->paymentId() << std::endl; }; @@ -308,8 +310,6 @@ TEST_F(WalletManagerTest, WalletHistory) ASSERT_TRUE(t != nullptr); transaction_print(t); } - - } -- cgit v1.2.3 From 93119344ecb3326b452f2f8e91bc101fe1896f8c Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 29 Apr 2016 16:26:14 +0300 Subject: TransactionHistory continued --- tests/libwallet_api_tests/main.cpp | 66 +++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 11 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 51c0a3ca3..35d0c8e9d 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -76,12 +76,19 @@ struct WalletManagerTest : public testing::Test // TODO: add test wallets to the source tree (as they have some balance mined)? const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; + const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin"; + const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin"; const char * TESTNET_WALLET_PASS = ""; + + const char * TESTNET_DAEMON_ADDRESS = "localhost:38081"; const uint64_t AMOUNT_10XMR = 10000000000000L; const uint64_t AMOUNT_5XMR = 50000000000000L; + const char * RECIPIENT_WALLET_ADDRESS = "9uekQVGj7NjSAREnZ8cUsRagWDdjvdhpwUKhsL95oXngBnZXZ1RzH8R6UJbU1R7wim9yKbSjxuoQ22ERRkEochGECj66oP3"; + const char * TESTNET_WALLET3_ADDRESS = "A11cBpRDqpTCneSL3KNBvGWM6PfxG7QrxNVCcMiZeuAD3fQA9Z366DegFLYHKrMnDm8QixPziRn4kVcWPFtn6aCSR1Hp7sg"; + const char * TESTNET_WALLET4_ADDRESS = "A21wicxbhUSKa6twequhKCCG8wYEGZ7viYRLW7mBXtWyheyY8C8XwUJG5PSjULDs1q7hndkihtFgybWjagvchrNg1Y588hM"; WalletManagerTest() { @@ -97,6 +104,20 @@ struct WalletManagerTest : public testing::Test std::cout << __FUNCTION__ << std::endl; //deleteWallet(WALLET_NAME); } + + static void print_transaction(Bitmonero::TransactionInfo * t) + { + + std::cout << "d: " + << (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out") + << ", pe: " << (t->isPending() ? "true" : "false") + << ", bh: " << t->blockHeight() + << ", a: " << Bitmonero::Wallet::displayAmount(t->amount()) + << ", f: " << Bitmonero::Wallet::displayAmount(t->fee()) + << ", h: " << t->hash() + << ", pid: " << t->paymentId() + << std::endl; + } }; @@ -279,6 +300,7 @@ TEST_F(WalletManagerTest, WalletTransaction) RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR); ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok); + ASSERT_TRUE(wallet1->balance() == balance); ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR); ASSERT_TRUE(transaction->commit()); @@ -295,20 +317,42 @@ TEST_F(WalletManagerTest, WalletHistory) Bitmonero::TransactionHistory * history = wallet1->history(); history->refresh(); ASSERT_TRUE(history->count() > 0); - auto transaction_print = [=] (Bitmonero::TransactionInfo * t) { - std::cout << "d: " - << (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out") - << ", bh: " << t->blockHeight() - << ", a: " << Bitmonero::Wallet::displayAmount(t->amount()) - << ", f: " << Bitmonero::Wallet::displayAmount(t->fee()) - << ", h: " << t->hash() - << ", pid: " << t->paymentId() - << std::endl; - }; + + for (auto t: history->getAll()) { + ASSERT_TRUE(t != nullptr); + print_transaction(t); + } +} + +TEST_F(WalletManagerTest, WalletTransactionAndHistory) +{ + Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); + // make sure testnet daemon is running + ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet_src->refresh()); + Bitmonero::TransactionHistory * history = wallet_src->history(); + history->refresh(); + ASSERT_TRUE(history->count() > 0); + size_t count1 = history->count(); + + std::cout << "**** Transactions before transfer (" << count1 << ")" << std::endl; + for (auto t: history->getAll()) { + ASSERT_TRUE(t != nullptr); + print_transaction(t); + } + + Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_10XMR * 5); + ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok); + ASSERT_TRUE(tx->commit()); + history = wallet_src->history(); + history->refresh(); + ASSERT_TRUE(count1 != history->count()); + + std::cout << "**** Transactions after transfer (" << history->count() << ")" << std::endl; for (auto t: history->getAll()) { ASSERT_TRUE(t != nullptr); - transaction_print(t); + print_transaction(t); } } -- cgit v1.2.3 From 40087a745f7677d29642c9ff86e1583c34ed1748 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Mon, 16 May 2016 13:11:44 +0300 Subject: WalletListener::moneySpent test --- tests/libwallet_api_tests/main.cpp | 207 +++++++++++++++++++++++++++---------- 1 file changed, 154 insertions(+), 53 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 35d0c8e9d..bdcf889ef 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -37,12 +37,47 @@ #include #include +#include +#include using namespace std; //unsigned int epee::g_test_dbg_lock_sleep = 0; +namespace Consts +{ + +// TODO: add test wallets to the source tree (as they have some balance mined)? +// TODO: get rid of hardcoded paths + +const char * WALLET_NAME = "testwallet"; +const char * WALLET_NAME_COPY = "testwallet_copy"; +const char * WALLET_NAME_WITH_DIR = "walletdir/testwallet_test"; +const char * WALLET_NAME_WITH_DIR_NON_WRITABLE = "/var/walletdir/testwallet_test"; +const char * WALLET_PASS = "password"; +const char * WALLET_PASS2 = "password22"; +const char * WALLET_LANG = "English"; + +const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; +const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin"; +const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin"; +const char * TESTNET_WALLET_PASS = ""; + + +const char * TESTNET_DAEMON_ADDRESS = "localhost:38081"; +const uint64_t AMOUNT_10XMR = 10000000000000L; +const uint64_t AMOUNT_5XMR = 50000000000000L; + +const char * RECIPIENT_WALLET_ADDRESS = "9uekQVGj7NjSAREnZ8cUsRagWDdjvdhpwUKhsL95oXngBnZXZ1RzH8R6UJbU1R7wim9yKbSjxuoQ22ERRkEochGECj66oP3"; +const char * TESTNET_WALLET3_ADDRESS = "A11cBpRDqpTCneSL3KNBvGWM6PfxG7QrxNVCcMiZeuAD3fQA9Z366DegFLYHKrMnDm8QixPziRn4kVcWPFtn6aCSR1Hp7sg"; +const char * TESTNET_WALLET4_ADDRESS = "A21wicxbhUSKa6twequhKCCG8wYEGZ7viYRLW7mBXtWyheyY8C8XwUJG5PSjULDs1q7hndkihtFgybWjagvchrNg1Y588hM"; + +} + + +using namespace Consts; + struct Utils { static void deleteWallet(const std::string & walletname) @@ -58,39 +93,29 @@ struct Utils std::cout << "** removing dir recursively: " << path << std::endl; boost::filesystem::remove_all(path); } + + static void print_transaction(Bitmonero::TransactionInfo * t) + { + + std::cout << "d: " + << (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out") + << ", pe: " << (t->isPending() ? "true" : "false") + << ", bh: " << t->blockHeight() + << ", a: " << Bitmonero::Wallet::displayAmount(t->amount()) + << ", f: " << Bitmonero::Wallet::displayAmount(t->fee()) + << ", h: " << t->hash() + << ", pid: " << t->paymentId() + << std::endl; + } }; -struct WalletManagerTest : public testing::Test +struct DISABLED_WalletManagerTest : public testing::Test { Bitmonero::WalletManager * wmgr; - const char * WALLET_NAME = "testwallet"; - const char * WALLET_NAME_COPY = "testwallet_copy"; - const char * WALLET_NAME_WITH_DIR = "walletdir/testwallet_test"; - const char * WALLET_NAME_WITH_DIR_NON_WRITABLE = "/var/walletdir/testwallet_test"; - const char * WALLET_PASS = "password"; - const char * WALLET_PASS2 = "password22"; - const char * WALLET_LANG = "English"; - - - // TODO: add test wallets to the source tree (as they have some balance mined)? - const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; - const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin"; - const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin"; - const char * TESTNET_WALLET_PASS = ""; - - - const char * TESTNET_DAEMON_ADDRESS = "localhost:38081"; - const uint64_t AMOUNT_10XMR = 10000000000000L; - const uint64_t AMOUNT_5XMR = 50000000000000L; - - const char * RECIPIENT_WALLET_ADDRESS = "9uekQVGj7NjSAREnZ8cUsRagWDdjvdhpwUKhsL95oXngBnZXZ1RzH8R6UJbU1R7wim9yKbSjxuoQ22ERRkEochGECj66oP3"; - const char * TESTNET_WALLET3_ADDRESS = "A11cBpRDqpTCneSL3KNBvGWM6PfxG7QrxNVCcMiZeuAD3fQA9Z366DegFLYHKrMnDm8QixPziRn4kVcWPFtn6aCSR1Hp7sg"; - const char * TESTNET_WALLET4_ADDRESS = "A21wicxbhUSKa6twequhKCCG8wYEGZ7viYRLW7mBXtWyheyY8C8XwUJG5PSjULDs1q7hndkihtFgybWjagvchrNg1Y588hM"; - - WalletManagerTest() + DISABLED_WalletManagerTest() { std::cout << __FUNCTION__ << std::endl; wmgr = Bitmonero::WalletManagerFactory::getWalletManager(); @@ -99,29 +124,42 @@ struct WalletManagerTest : public testing::Test } - ~WalletManagerTest() + ~DISABLED_WalletManagerTest() { std::cout << __FUNCTION__ << std::endl; //deleteWallet(WALLET_NAME); } - static void print_transaction(Bitmonero::TransactionInfo * t) +}; + + +struct DISABLED_WalletTest1 : public testing::Test +{ + Bitmonero::WalletManager * wmgr; + + DISABLED_WalletTest1() { + wmgr = Bitmonero::WalletManagerFactory::getWalletManager(); + } - std::cout << "d: " - << (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out") - << ", pe: " << (t->isPending() ? "true" : "false") - << ", bh: " << t->blockHeight() - << ", a: " << Bitmonero::Wallet::displayAmount(t->amount()) - << ", f: " << Bitmonero::Wallet::displayAmount(t->fee()) - << ", h: " << t->hash() - << ", pid: " << t->paymentId() - << std::endl; + +}; + + +struct WalletTest2 : public testing::Test +{ + Bitmonero::WalletManager * wmgr; + + WalletTest2() + { + wmgr = Bitmonero::WalletManagerFactory::getWalletManager(); } + + }; -TEST_F(WalletManagerTest, WalletManagerCreatesWallet) +TEST_F(DISABLED_WalletManagerTest, WalletManagerCreatesWallet) { Bitmonero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -138,7 +176,7 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet) } -TEST_F(WalletManagerTest, WalletManagerOpensWallet) +TEST_F(DISABLED_WalletManagerTest, WalletManagerOpensWallet) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -151,7 +189,7 @@ TEST_F(WalletManagerTest, WalletManagerOpensWallet) } -TEST_F(WalletManagerTest, WalletManagerChangesPassword) +TEST_F(DISABLED_WalletManagerTest, WalletManagerChangesPassword) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -167,7 +205,7 @@ TEST_F(WalletManagerTest, WalletManagerChangesPassword) -TEST_F(WalletManagerTest, WalletManagerRecoversWallet) +TEST_F(DISABLED_WalletManagerTest, WalletManagerRecoversWallet) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -183,7 +221,7 @@ TEST_F(WalletManagerTest, WalletManagerRecoversWallet) } -TEST_F(WalletManagerTest, WalletManagerStoresWallet1) +TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet1) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -200,7 +238,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet1) } -TEST_F(WalletManagerTest, WalletManagerStoresWallet2) +TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet2) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -216,7 +254,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -TEST_F(WalletManagerTest, WalletManagerStoresWallet3) +TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet3) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -238,7 +276,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3) } -TEST_F(WalletManagerTest, WalletManagerStoresWallet4) +TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet4) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -260,7 +298,8 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet4) } -TEST_F(WalletManagerTest, WalletShowsBalance) + +TEST_F(DISABLED_WalletTest1, WalletShowsBalance) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); ASSERT_TRUE(wallet1->balance() > 0); @@ -278,7 +317,7 @@ TEST_F(WalletManagerTest, WalletShowsBalance) ASSERT_TRUE(wmgr->closeWallet(wallet2)); } -TEST_F(WalletManagerTest, WalletRefresh) +TEST_F(DISABLED_WalletTest1, WalletRefresh) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running @@ -287,7 +326,7 @@ TEST_F(WalletManagerTest, WalletRefresh) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -TEST_F(WalletManagerTest, WalletTransaction) +TEST_F(DISABLED_WalletTest1, WalletTransaction) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running @@ -308,7 +347,7 @@ TEST_F(WalletManagerTest, WalletTransaction) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -TEST_F(WalletManagerTest, WalletHistory) +TEST_F(DISABLED_WalletTest1, WalletHistory) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running @@ -321,11 +360,11 @@ TEST_F(WalletManagerTest, WalletHistory) for (auto t: history->getAll()) { ASSERT_TRUE(t != nullptr); - print_transaction(t); + Utils::print_transaction(t); } } -TEST_F(WalletManagerTest, WalletTransactionAndHistory) +TEST_F(DISABLED_WalletTest1, WalletTransactionAndHistory) { Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running @@ -339,7 +378,7 @@ TEST_F(WalletManagerTest, WalletTransactionAndHistory) std::cout << "**** Transactions before transfer (" << count1 << ")" << std::endl; for (auto t: history->getAll()) { ASSERT_TRUE(t != nullptr); - print_transaction(t); + Utils::print_transaction(t); } Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_10XMR * 5); @@ -352,11 +391,73 @@ TEST_F(WalletManagerTest, WalletTransactionAndHistory) std::cout << "**** Transactions after transfer (" << history->count() << ")" << std::endl; for (auto t: history->getAll()) { ASSERT_TRUE(t != nullptr); - print_transaction(t); + Utils::print_transaction(t); } } +struct MyWalletListener : public Bitmonero::WalletListener +{ + + Bitmonero::Wallet * wallet; + uint64_t total_tx; + uint64_t total_rx; + std::timed_mutex guard; + + MyWalletListener(Bitmonero::Wallet * wallet) + : total_tx(0), total_rx(0) + { + this->wallet = wallet; + this->wallet->setListener(this); + } + + virtual void moneySpent(const string &txId, uint64_t amount) + { + std::cout << "wallet: " << wallet->address() << " just spent money (" + << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl; + total_tx += amount; + guard.unlock(); + } + + virtual void moneyReceived(const string &txId, uint64_t amount) + { + std::cout << "wallet: " << wallet->address() << " just received money (" + << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl; + total_rx += amount; + guard.unlock(); + } +}; + +TEST_F(WalletTest2, WalletCallbackSent) +{ + + Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); + // make sure testnet daemon is running + ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet_src->refresh()); + MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src); + std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl; + /* + Bitmonero::Wallet * wallet_dst = wmgr->openWallet(TESTNET_WALLET4_NAME, TESTNET_WALLET_PASS, true); + ASSERT_TRUE(wallet_dst->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet_dst->refresh()); + MyWalletListener * wallet_dst_listener = new MyWalletListener(wallet_dst); + */ + + + uint64_t amount = AMOUNT_10XMR * 5; + std::cout << "** Sending " << Bitmonero::Wallet::displayAmount(amount) << " to " << TESTNET_WALLET4_ADDRESS; + Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_10XMR * 5); + ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok); + ASSERT_TRUE(tx->commit()); + + std::chrono::seconds wait_for = std::chrono::seconds(60*3); + + wallet_src_listener->guard.lock(); + wallet_src_listener->guard.try_lock_for(wait_for); + ASSERT_TRUE(wallet_src_listener->total_tx != 0); + +} int main(int argc, char** argv) { -- cgit v1.2.3 From 9ae4e871a3617c931f21456ff30d2fd551a77a26 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 17 May 2016 12:16:11 +0300 Subject: WalletListener::moneyReceived test --- tests/libwallet_api_tests/main.cpp | 50 +++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index bdcf889ef..9ff2fb7c2 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -67,15 +67,16 @@ const char * TESTNET_WALLET_PASS = ""; const char * TESTNET_DAEMON_ADDRESS = "localhost:38081"; const uint64_t AMOUNT_10XMR = 10000000000000L; -const uint64_t AMOUNT_5XMR = 50000000000000L; - -const char * RECIPIENT_WALLET_ADDRESS = "9uekQVGj7NjSAREnZ8cUsRagWDdjvdhpwUKhsL95oXngBnZXZ1RzH8R6UJbU1R7wim9yKbSjxuoQ22ERRkEochGECj66oP3"; -const char * TESTNET_WALLET3_ADDRESS = "A11cBpRDqpTCneSL3KNBvGWM6PfxG7QrxNVCcMiZeuAD3fQA9Z366DegFLYHKrMnDm8QixPziRn4kVcWPFtn6aCSR1Hp7sg"; -const char * TESTNET_WALLET4_ADDRESS = "A21wicxbhUSKa6twequhKCCG8wYEGZ7viYRLW7mBXtWyheyY8C8XwUJG5PSjULDs1q7hndkihtFgybWjagvchrNg1Y588hM"; +const uint64_t AMOUNT_5XMR = 5000000000000L; +const uint64_t AMOUNT_1XMR = 1000000000000L; +const char * RECIPIENT_WALLET_ADDRESS = "9v9wAZ1aNj3CTgTPhEqLameUB25AkXknNHhPNjUozRxX1jrHLb9cdnn8kVf4r8GDJHjCjM5XKAWHp6Z38wsCudGWJ992byk"; +const char * TESTNET_WALLET3_ADDRESS = "A1koTipJ3Y8btatXupU3yYVAZrNG6W9z2WeYcirwHDmfZLaBGMPswq7CrYvemvCvp4atrqRhV1TBj3jYZv133CkAUeykAny"; +const char * TESTNET_WALLET4_ADDRESS = "A1R2sxZb2vY7fBjDxubxNDYfmzPmoWSrSAa7uokvWW2n7beJJnigAP43gfVpopdfd7YCFvMfVCpwQX39sXayicRr32hscyX"; } + using namespace Consts; struct Utils @@ -427,6 +428,7 @@ struct MyWalletListener : public Bitmonero::WalletListener } }; +/* TEST_F(WalletTest2, WalletCallbackSent) { @@ -436,17 +438,11 @@ TEST_F(WalletTest2, WalletCallbackSent) ASSERT_TRUE(wallet_src->refresh()); MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src); std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl; - /* - Bitmonero::Wallet * wallet_dst = wmgr->openWallet(TESTNET_WALLET4_NAME, TESTNET_WALLET_PASS, true); - ASSERT_TRUE(wallet_dst->init(TESTNET_DAEMON_ADDRESS, 0)); - ASSERT_TRUE(wallet_dst->refresh()); - MyWalletListener * wallet_dst_listener = new MyWalletListener(wallet_dst); - */ uint64_t amount = AMOUNT_10XMR * 5; std::cout << "** Sending " << Bitmonero::Wallet::displayAmount(amount) << " to " << TESTNET_WALLET4_ADDRESS; - Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_10XMR * 5); + Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_1XMR * 5); ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok); ASSERT_TRUE(tx->commit()); @@ -456,6 +452,36 @@ TEST_F(WalletTest2, WalletCallbackSent) wallet_src_listener->guard.try_lock_for(wait_for); ASSERT_TRUE(wallet_src_listener->total_tx != 0); +} +*/ + +TEST_F(WalletTest2, WalletCallbackReceived) +{ + + Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); + // make sure testnet daemon is running + ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet_src->refresh()); + std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl; + + Bitmonero::Wallet * wallet_dst = wmgr->openWallet(TESTNET_WALLET4_NAME, TESTNET_WALLET_PASS, true); + ASSERT_TRUE(wallet_dst->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet_dst->refresh()); + MyWalletListener * wallet_dst_listener = new MyWalletListener(wallet_dst); + + + uint64_t amount = AMOUNT_1XMR * 5; + std::cout << "** Sending " << Bitmonero::Wallet::displayAmount(amount) << " to " << TESTNET_WALLET4_ADDRESS; + Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_1XMR * 5); + ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok); + ASSERT_TRUE(tx->commit()); + + std::chrono::seconds wait_for = std::chrono::seconds(60*3); + + wallet_dst_listener->guard.lock(); + wallet_dst_listener->guard.try_lock_for(wait_for); + + ASSERT_TRUE(wallet_dst_listener->total_tx != 0); } -- cgit v1.2.3 From 7f3d28fe1bb730fb4aa8430418f7c207a87dc78b Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 27 May 2016 13:35:00 +0300 Subject: regenerated test wallets, basic functions got broken --- tests/libwallet_api_tests/main.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 9ff2fb7c2..ed85555cd 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -59,7 +59,7 @@ const char * WALLET_PASS = "password"; const char * WALLET_PASS2 = "password22"; const char * WALLET_LANG = "English"; -const char * TESTNET_WALLET_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; +const char * TESTNET_WALLET1_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin"; const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin"; const char * TESTNET_WALLET_PASS = ""; @@ -70,9 +70,10 @@ const uint64_t AMOUNT_10XMR = 10000000000000L; const uint64_t AMOUNT_5XMR = 5000000000000L; const uint64_t AMOUNT_1XMR = 1000000000000L; -const char * RECIPIENT_WALLET_ADDRESS = "9v9wAZ1aNj3CTgTPhEqLameUB25AkXknNHhPNjUozRxX1jrHLb9cdnn8kVf4r8GDJHjCjM5XKAWHp6Z38wsCudGWJ992byk"; -const char * TESTNET_WALLET3_ADDRESS = "A1koTipJ3Y8btatXupU3yYVAZrNG6W9z2WeYcirwHDmfZLaBGMPswq7CrYvemvCvp4atrqRhV1TBj3jYZv133CkAUeykAny"; -const char * TESTNET_WALLET4_ADDRESS = "A1R2sxZb2vY7fBjDxubxNDYfmzPmoWSrSAa7uokvWW2n7beJJnigAP43gfVpopdfd7YCFvMfVCpwQX39sXayicRr32hscyX"; + +const char * TESTNET_WALLET3_ADDRESS = "A2N8LNKkzH2ddepepgvmz9e4JRe5QXkoPjg9kHW5CLWvH7eQNqEvNWmjJziVSqVLfUXVz7CYe5MZ32qJryVr8eBCLG5yJXP"; +const char * TESTNET_WALLET4_ADDRESS = "9yMPpGDhXrPMEFk2AueB9EVP3oJtovj1zRiSKz481xVAFW6tDyft8H6WE9otfBLzzHCUQ98xRogjk3oiPQA2Qy5tKpsNhyE"; +const char * RECIPIENT_WALLET_ADDRESS = TESTNET_WALLET4_ADDRESS; } @@ -134,11 +135,11 @@ struct DISABLED_WalletManagerTest : public testing::Test }; -struct DISABLED_WalletTest1 : public testing::Test +struct WalletTest1 : public testing::Test { Bitmonero::WalletManager * wmgr; - DISABLED_WalletTest1() + WalletTest1() { wmgr = Bitmonero::WalletManagerFactory::getWalletManager(); } @@ -300,16 +301,16 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet4) -TEST_F(DISABLED_WalletTest1, WalletShowsBalance) +TEST_F(WalletTest1, WalletShowsBalance) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); ASSERT_TRUE(wallet1->balance() > 0); ASSERT_TRUE(wallet1->unlockedBalance() > 0); uint64_t balance1 = wallet1->balance(); uint64_t unlockedBalance1 = wallet1->unlockedBalance(); ASSERT_TRUE(wmgr->closeWallet(wallet1)); - Bitmonero::Wallet * wallet2 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet2 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); ASSERT_TRUE(balance1 == wallet2->balance()); std::cout << "wallet balance: " << wallet2->balance() << std::endl; @@ -318,18 +319,18 @@ TEST_F(DISABLED_WalletTest1, WalletShowsBalance) ASSERT_TRUE(wmgr->closeWallet(wallet2)); } -TEST_F(DISABLED_WalletTest1, WalletRefresh) +TEST_F(WalletTest1, WalletRefresh) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -TEST_F(DISABLED_WalletTest1, WalletTransaction) +TEST_F(WalletTest1, WalletTransaction) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); @@ -348,9 +349,9 @@ TEST_F(DISABLED_WalletTest1, WalletTransaction) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -TEST_F(DISABLED_WalletTest1, WalletHistory) +TEST_F(WalletTest1, WalletHistory) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); @@ -365,7 +366,7 @@ TEST_F(DISABLED_WalletTest1, WalletHistory) } } -TEST_F(DISABLED_WalletTest1, WalletTransactionAndHistory) +TEST_F(WalletTest1, WalletTransactionAndHistory) { Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running @@ -455,6 +456,7 @@ TEST_F(WalletTest2, WalletCallbackSent) } */ +/* TEST_F(WalletTest2, WalletCallbackReceived) { @@ -476,7 +478,7 @@ TEST_F(WalletTest2, WalletCallbackReceived) ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok); ASSERT_TRUE(tx->commit()); - std::chrono::seconds wait_for = std::chrono::seconds(60*3); + std::chrono::seconds wait_for = std::chrono::seconds(60*4); wallet_dst_listener->guard.lock(); wallet_dst_listener->guard.try_lock_for(wait_for); @@ -484,6 +486,7 @@ TEST_F(WalletTest2, WalletCallbackReceived) ASSERT_TRUE(wallet_dst_listener->total_tx != 0); } +*/ int main(int argc, char** argv) { -- cgit v1.2.3 From ec949c383c1829536874550b84d9966d20707f60 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Wed, 1 Jun 2016 17:06:10 +0300 Subject: scripts for faster test wallets generation --- tests/libwallet_api_tests/main.cpp | 64 +++++++++++++++------- .../libwallet_api_tests/scripts/create_wallets.sh | 20 +++++++ tests/libwallet_api_tests/scripts/mining_start.sh | 4 ++ tests/libwallet_api_tests/scripts/mining_stop.sh | 4 ++ tests/libwallet_api_tests/scripts/open_wallet_1.sh | 5 ++ tests/libwallet_api_tests/scripts/open_wallet_2.sh | 5 ++ tests/libwallet_api_tests/scripts/open_wallet_3.sh | 4 ++ tests/libwallet_api_tests/scripts/open_wallet_4.sh | 4 ++ tests/libwallet_api_tests/scripts/open_wallet_5.sh | 4 ++ .../scripts/open_wallet_miner.sh | 4 ++ tests/libwallet_api_tests/scripts/send_funds.sh | 21 +++++++ 11 files changed, 120 insertions(+), 19 deletions(-) create mode 100755 tests/libwallet_api_tests/scripts/create_wallets.sh create mode 100755 tests/libwallet_api_tests/scripts/mining_start.sh create mode 100755 tests/libwallet_api_tests/scripts/mining_stop.sh create mode 100755 tests/libwallet_api_tests/scripts/open_wallet_1.sh create mode 100755 tests/libwallet_api_tests/scripts/open_wallet_2.sh create mode 100755 tests/libwallet_api_tests/scripts/open_wallet_3.sh create mode 100755 tests/libwallet_api_tests/scripts/open_wallet_4.sh create mode 100755 tests/libwallet_api_tests/scripts/open_wallet_5.sh create mode 100755 tests/libwallet_api_tests/scripts/open_wallet_miner.sh create mode 100755 tests/libwallet_api_tests/scripts/send_funds.sh (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index ed85555cd..ebd29ee1e 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -44,11 +44,10 @@ using namespace std; //unsigned int epee::g_test_dbg_lock_sleep = 0; - namespace Consts { -// TODO: add test wallets to the source tree (as they have some balance mined)? + // TODO: get rid of hardcoded paths const char * WALLET_NAME = "testwallet"; @@ -59,21 +58,32 @@ const char * WALLET_PASS = "password"; const char * WALLET_PASS2 = "password22"; const char * WALLET_LANG = "English"; -const char * TESTNET_WALLET1_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; -const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin"; -const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin"; +// change this according your environment + +const std::string WALLETS_ROOT_DIR = "/home/mbg033/dev/monero/testnet/"; + +//const char * TESTNET_WALLET1_NAME = "/home/mbg033/dev/monero/testnet/wallet_01.bin"; +//const char * TESTNET_WALLET2_NAME = "/home/mbg033/dev/monero/testnet/wallet_02.bin"; +//const char * TESTNET_WALLET3_NAME = "/home/mbg033/dev/monero/testnet/wallet_03.bin"; +//const char * TESTNET_WALLET4_NAME = "/home/mbg033/dev/monero/testnet/wallet_04.bin"; +//const char * TESTNET_WALLET5_NAME = "/home/mbg033/dev/monero/testnet/wallet_05.bin"; + +const std::string TESTNET_WALLET1_NAME = WALLETS_ROOT_DIR + "wallet_01.bin"; +const std::string TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "wallet_02.bin"; +const std::string TESTNET_WALLET3_NAME = WALLETS_ROOT_DIR + "wallet_03.bin"; +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 char * TESTNET_WALLET_PASS = ""; +const std::string CURRENT_SRC_WALLET = TESTNET_WALLET1_NAME; +const std::string CURRENT_DST_WALLET = TESTNET_WALLET5_NAME; 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_1XMR = 1000000000000L; - -const char * TESTNET_WALLET3_ADDRESS = "A2N8LNKkzH2ddepepgvmz9e4JRe5QXkoPjg9kHW5CLWvH7eQNqEvNWmjJziVSqVLfUXVz7CYe5MZ32qJryVr8eBCLG5yJXP"; -const char * TESTNET_WALLET4_ADDRESS = "9yMPpGDhXrPMEFk2AueB9EVP3oJtovj1zRiSKz481xVAFW6tDyft8H6WE9otfBLzzHCUQ98xRogjk3oiPQA2Qy5tKpsNhyE"; -const char * RECIPIENT_WALLET_ADDRESS = TESTNET_WALLET4_ADDRESS; } @@ -109,6 +119,15 @@ struct Utils << ", pid: " << t->paymentId() << std::endl; } + + static std::string get_wallet_address(const std::string &filename, const std::string &password) + { + Bitmonero::WalletManager *wmgr = Bitmonero::WalletManagerFactory::getWalletManager(); + Bitmonero::Wallet * w = wmgr->openWallet(filename, password, true); + std::string result = w->address(); + wmgr->closeWallet(w); + return result; + } }; @@ -303,14 +322,16 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet4) TEST_F(WalletTest1, WalletShowsBalance) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); + // TODO: temporary disabled; + return; + Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); ASSERT_TRUE(wallet1->balance() > 0); ASSERT_TRUE(wallet1->unlockedBalance() > 0); uint64_t balance1 = wallet1->balance(); uint64_t unlockedBalance1 = wallet1->unlockedBalance(); ASSERT_TRUE(wmgr->closeWallet(wallet1)); - Bitmonero::Wallet * wallet2 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet2 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); ASSERT_TRUE(balance1 == wallet2->balance()); std::cout << "wallet balance: " << wallet2->balance() << std::endl; @@ -321,7 +342,7 @@ TEST_F(WalletTest1, WalletShowsBalance) TEST_F(WalletTest1, WalletRefresh) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); @@ -330,17 +351,19 @@ TEST_F(WalletTest1, WalletRefresh) TEST_F(WalletTest1, WalletTransaction) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); uint64_t balance = wallet1->balance(); ASSERT_TRUE(wallet1->status() == Bitmonero::PendingTransaction::Status_Ok); + std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS); + Bitmonero::PendingTransaction * transaction = wallet1->createTransaction( - RECIPIENT_WALLET_ADDRESS, AMOUNT_10XMR); + recepient_address, AMOUNT_10XMR); ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok); - + wallet1->refresh(); ASSERT_TRUE(wallet1->balance() == balance); ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR); @@ -351,7 +374,7 @@ TEST_F(WalletTest1, WalletTransaction) TEST_F(WalletTest1, WalletHistory) { - Bitmonero::Wallet * wallet1 = wmgr->openWallet(TESTNET_WALLET1_NAME, TESTNET_WALLET_PASS, true); + Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); @@ -368,7 +391,8 @@ TEST_F(WalletTest1, WalletHistory) TEST_F(WalletTest1, WalletTransactionAndHistory) { - Bitmonero::Wallet * wallet_src = wmgr->openWallet(TESTNET_WALLET3_NAME, TESTNET_WALLET_PASS, true); + return; + Bitmonero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); // make sure testnet daemon is running ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet_src->refresh()); @@ -383,7 +407,9 @@ TEST_F(WalletTest1, WalletTransactionAndHistory) Utils::print_transaction(t); } - Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_10XMR * 5); + std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS); + + Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr, AMOUNT_10XMR * 5); ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok); ASSERT_TRUE(tx->commit()); history = wallet_src->history(); diff --git a/tests/libwallet_api_tests/scripts/create_wallets.sh b/tests/libwallet_api_tests/scripts/create_wallets.sh new file mode 100755 index 000000000..fd3db838c --- /dev/null +++ b/tests/libwallet_api_tests/scripts/create_wallets.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +function create_wallet { + wallet_name=$1 + echo 0 | simplewallet --testnet --trusted-daemon --daemon-address localhost:38081 --generate-new-wallet $wallet_name --password "" --restore-height=1 +} + + + +create_wallet wallet_01.bin +create_wallet wallet_02.bin +create_wallet wallet_03.bin +#create_wallet wallet_04.bin +create_wallet wallet_05.bin +create_wallet wallet_06.bin + + +#create_wallet wallet_m + + diff --git a/tests/libwallet_api_tests/scripts/mining_start.sh b/tests/libwallet_api_tests/scripts/mining_start.sh new file mode 100755 index 000000000..76eabfc55 --- /dev/null +++ b/tests/libwallet_api_tests/scripts/mining_start.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_m.log start_mining + diff --git a/tests/libwallet_api_tests/scripts/mining_stop.sh b/tests/libwallet_api_tests/scripts/mining_stop.sh new file mode 100755 index 000000000..640e56943 --- /dev/null +++ b/tests/libwallet_api_tests/scripts/mining_stop.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_miner.log stop_mining + diff --git a/tests/libwallet_api_tests/scripts/open_wallet_1.sh b/tests/libwallet_api_tests/scripts/open_wallet_1.sh new file mode 100755 index 000000000..08f4e28ab --- /dev/null +++ b/tests/libwallet_api_tests/scripts/open_wallet_1.sh @@ -0,0 +1,5 @@ +#!/bin/bash + + +rlwrap simplewallet --wallet-file wallet_01.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log + diff --git a/tests/libwallet_api_tests/scripts/open_wallet_2.sh b/tests/libwallet_api_tests/scripts/open_wallet_2.sh new file mode 100755 index 000000000..8a16a6647 --- /dev/null +++ b/tests/libwallet_api_tests/scripts/open_wallet_2.sh @@ -0,0 +1,5 @@ +#!/bin/bash + + +rlwrap simplewallet --wallet-file wallet_02.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_01.log + diff --git a/tests/libwallet_api_tests/scripts/open_wallet_3.sh b/tests/libwallet_api_tests/scripts/open_wallet_3.sh new file mode 100755 index 000000000..64a04b3c4 --- /dev/null +++ b/tests/libwallet_api_tests/scripts/open_wallet_3.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rlwrap simplewallet --wallet-file wallet_03.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_03.log + diff --git a/tests/libwallet_api_tests/scripts/open_wallet_4.sh b/tests/libwallet_api_tests/scripts/open_wallet_4.sh new file mode 100755 index 000000000..8ebf0a4c7 --- /dev/null +++ b/tests/libwallet_api_tests/scripts/open_wallet_4.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rlwrap simplewallet --wallet-file wallet_04.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_04.log + diff --git a/tests/libwallet_api_tests/scripts/open_wallet_5.sh b/tests/libwallet_api_tests/scripts/open_wallet_5.sh new file mode 100755 index 000000000..8ebf0a4c7 --- /dev/null +++ b/tests/libwallet_api_tests/scripts/open_wallet_5.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rlwrap simplewallet --wallet-file wallet_04.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_04.log + diff --git a/tests/libwallet_api_tests/scripts/open_wallet_miner.sh b/tests/libwallet_api_tests/scripts/open_wallet_miner.sh new file mode 100755 index 000000000..07a4e58ea --- /dev/null +++ b/tests/libwallet_api_tests/scripts/open_wallet_miner.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +rlwrap simplewallet --wallet-file wallet_m --password "" --testnet --trusted-daemon --daemon-address 127.0.0.1:38081 --log-file wallet_m.log + diff --git a/tests/libwallet_api_tests/scripts/send_funds.sh b/tests/libwallet_api_tests/scripts/send_funds.sh new file mode 100755 index 000000000..801d63609 --- /dev/null +++ b/tests/libwallet_api_tests/scripts/send_funds.sh @@ -0,0 +1,21 @@ +#!/bin/bash + + + +function send_funds { + local amount=$1 + local dest=$(cat "$2.address.txt") + + simplewallet --wallet-file wallet_m --password "" \ + --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_m.log \ + --command transfer $dest $amount +} + + +send_funds 100 wallet_01.bin +send_funds 100 wallet_02.bin +send_funds 100 wallet_03.bin +send_funds 100 wallet_04.bin +send_funds 100 wallet_05.bin + + -- cgit v1.2.3 From 2facbe77e485e8a824a08d862aa63f3f179480e9 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 3 Jun 2016 14:52:58 +0300 Subject: Wallet API : WalletManager::findWallets() added --- tests/libwallet_api_tests/main.cpp | 39 ++++++++++++++-------- .../libwallet_api_tests/scripts/create_wallets.sh | 2 +- tests/libwallet_api_tests/scripts/open_wallet_5.sh | 2 +- tests/libwallet_api_tests/scripts/send_funds.sh | 1 + 4 files changed, 29 insertions(+), 15 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index ebd29ee1e..91636d522 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -73,11 +73,12 @@ const std::string TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "wallet_02.bin"; const std::string TESTNET_WALLET3_NAME = WALLETS_ROOT_DIR + "wallet_03.bin"; 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 std::string CURRENT_SRC_WALLET = TESTNET_WALLET1_NAME; -const std::string CURRENT_DST_WALLET = TESTNET_WALLET5_NAME; +const std::string CURRENT_DST_WALLET = TESTNET_WALLET6_NAME; const char * TESTNET_DAEMON_ADDRESS = "localhost:38081"; const uint64_t AMOUNT_10XMR = 10000000000000L; @@ -131,12 +132,12 @@ struct Utils }; -struct DISABLED_WalletManagerTest : public testing::Test +struct WalletManagerTest : public testing::Test { Bitmonero::WalletManager * wmgr; - DISABLED_WalletManagerTest() + WalletManagerTest() { std::cout << __FUNCTION__ << std::endl; wmgr = Bitmonero::WalletManagerFactory::getWalletManager(); @@ -145,7 +146,7 @@ struct DISABLED_WalletManagerTest : public testing::Test } - ~DISABLED_WalletManagerTest() + ~WalletManagerTest() { std::cout << __FUNCTION__ << std::endl; //deleteWallet(WALLET_NAME); @@ -180,7 +181,7 @@ struct WalletTest2 : public testing::Test }; -TEST_F(DISABLED_WalletManagerTest, WalletManagerCreatesWallet) +TEST_F(WalletManagerTest, WalletManagerCreatesWallet) { Bitmonero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -197,7 +198,7 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerCreatesWallet) } -TEST_F(DISABLED_WalletManagerTest, WalletManagerOpensWallet) +TEST_F(WalletManagerTest, WalletManagerOpensWallet) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); @@ -209,8 +210,8 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerOpensWallet) std::cout << "** seed: " << wallet2->seed() << std::endl; } - -TEST_F(DISABLED_WalletManagerTest, WalletManagerChangesPassword) +/* +TEST_F(WalletManagerTest, WalletManagerChangesPassword) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -226,7 +227,7 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerChangesPassword) -TEST_F(DISABLED_WalletManagerTest, WalletManagerRecoversWallet) +TEST_F(WalletManagerTest, WalletManagerRecoversWallet) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -242,7 +243,7 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerRecoversWallet) } -TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet1) +TEST_F(WalletManagerTest, WalletManagerStoresWallet1) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -259,7 +260,7 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet1) } -TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet2) +TEST_F(WalletManagerTest, WalletManagerStoresWallet2) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -275,7 +276,7 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet2) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } -TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet3) +TEST_F(WalletManagerTest, WalletManagerStoresWallet3) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -297,7 +298,7 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet3) } -TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet4) +TEST_F(WalletManagerTest, WalletManagerStoresWallet4) { Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); @@ -317,7 +318,17 @@ TEST_F(DISABLED_WalletManagerTest, WalletManagerStoresWallet4) ASSERT_TRUE(wallet1->address() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } +*/ +TEST_F(WalletManagerTest, WalletManagerFindsWallet) +{ + std::vector wallets = wmgr->findWallets(WALLETS_ROOT_DIR); + ASSERT_FALSE(wallets.empty()); + std::cout << "Found wallets: " << std::endl; + for (auto wallet_path: wallets) { + std::cout << wallet_path << std::endl; + } +} TEST_F(WalletTest1, WalletShowsBalance) @@ -349,6 +360,8 @@ TEST_F(WalletTest1, WalletRefresh) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } + + TEST_F(WalletTest1, WalletTransaction) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); diff --git a/tests/libwallet_api_tests/scripts/create_wallets.sh b/tests/libwallet_api_tests/scripts/create_wallets.sh index fd3db838c..6abad84f9 100755 --- a/tests/libwallet_api_tests/scripts/create_wallets.sh +++ b/tests/libwallet_api_tests/scripts/create_wallets.sh @@ -10,7 +10,7 @@ function create_wallet { create_wallet wallet_01.bin create_wallet wallet_02.bin create_wallet wallet_03.bin -#create_wallet wallet_04.bin +create_wallet wallet_04.bin create_wallet wallet_05.bin create_wallet wallet_06.bin diff --git a/tests/libwallet_api_tests/scripts/open_wallet_5.sh b/tests/libwallet_api_tests/scripts/open_wallet_5.sh index 8ebf0a4c7..bbeb702c0 100755 --- a/tests/libwallet_api_tests/scripts/open_wallet_5.sh +++ b/tests/libwallet_api_tests/scripts/open_wallet_5.sh @@ -1,4 +1,4 @@ #!/bin/bash -rlwrap simplewallet --wallet-file wallet_04.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_04.log +rlwrap simplewallet --wallet-file wallet_05.bin --password "" --testnet --trusted-daemon --daemon-address localhost:38081 --log-file wallet_05.log diff --git a/tests/libwallet_api_tests/scripts/send_funds.sh b/tests/libwallet_api_tests/scripts/send_funds.sh index 801d63609..306b06a40 100755 --- a/tests/libwallet_api_tests/scripts/send_funds.sh +++ b/tests/libwallet_api_tests/scripts/send_funds.sh @@ -17,5 +17,6 @@ send_funds 100 wallet_02.bin send_funds 100 wallet_03.bin send_funds 100 wallet_04.bin send_funds 100 wallet_05.bin +send_funds 100 wallet_06.bin -- cgit v1.2.3 From c554055ce435ae2752820ba317d801f143804b3c Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 10 Jun 2016 12:51:09 +0300 Subject: Wallet::filename, Wallet::keysFilename, tests for move wallet --- tests/libwallet_api_tests/main.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 91636d522..595e3ccfb 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -210,6 +210,35 @@ TEST_F(WalletManagerTest, WalletManagerOpensWallet) std::cout << "** seed: " << wallet2->seed() << std::endl; } +TEST_F(WalletManagerTest, WalletManagerStoresWallet) +{ + + Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); + std::string seed1 = wallet1->seed(); + wallet1->store(""); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); + Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS); + ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok); + ASSERT_TRUE(wallet2->seed() == seed1); +} + + +TEST_F(WalletManagerTest, WalletManagerMovesWallet) +{ + + Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); + std::string WALLET_NAME_MOVED = std::string("/tmp/") + WALLET_NAME + ".moved"; + std::string seed1 = wallet1->seed(); + ASSERT_TRUE(wallet1->store(WALLET_NAME_MOVED)); + + Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_MOVED, WALLET_PASS); + ASSERT_TRUE(wallet2->filename() == WALLET_NAME_MOVED); + ASSERT_TRUE(wallet2->keysFilename() == WALLET_NAME_MOVED + ".keys"); + ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok); + ASSERT_TRUE(wallet2->seed() == seed1); +} + + /* TEST_F(WalletManagerTest, WalletManagerChangesPassword) { -- cgit v1.2.3 From 3ac20a46b38f88757c57cbcf8581cade312b7936 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Fri, 10 Jun 2016 13:52:10 +0300 Subject: wallet::default_mixin exposed to public interface as Wallet::setDefaultMixin, Wallet::defaultMixin; wallet::create_transaction_2 used in Wallet::createTransaction --- tests/libwallet_api_tests/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 595e3ccfb..935cfd884 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -401,6 +401,8 @@ TEST_F(WalletTest1, WalletTransaction) ASSERT_TRUE(wallet1->status() == Bitmonero::PendingTransaction::Status_Ok); std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS); + wallet1->setDefaultMixin(1); + ASSERT_TRUE(wallet1->defaultMixin() == 1); Bitmonero::PendingTransaction * transaction = wallet1->createTransaction( recepient_address, AMOUNT_10XMR); -- cgit v1.2.3 From 3318addafaf6ac7b5489f7d774083a84dce7dfa0 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Thu, 16 Jun 2016 16:42:33 +0300 Subject: double/string to monero integer convertion methods --- tests/libwallet_api_tests/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 935cfd884..849d76e1b 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -247,7 +247,7 @@ TEST_F(WalletManagerTest, WalletManagerChangesPassword) ASSERT_TRUE(wallet1->setPassword(WALLET_PASS2)); ASSERT_TRUE(wmgr->closeWallet(wallet1)); Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS2); - ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok); + ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);quint64 ASSERT_TRUE(wallet2->seed() == seed1); ASSERT_TRUE(wmgr->closeWallet(wallet2)); Bitmonero::Wallet * wallet3 = wmgr->openWallet(WALLET_NAME, WALLET_PASS); @@ -390,7 +390,19 @@ TEST_F(WalletTest1, WalletRefresh) } +TEST_F(WalletTest1, WalletConvertsToString) +{ + std::string strAmount = Bitmonero::Wallet::displayAmount(AMOUNT_5XMR); + ASSERT_TRUE(AMOUNT_5XMR == Bitmonero::Wallet::amountFromString(strAmount)); + + ASSERT_TRUE(AMOUNT_5XMR == Bitmonero::Wallet::amountFromDouble(5.0)); + ASSERT_TRUE(AMOUNT_10XMR == Bitmonero::Wallet::amountFromDouble(10.0)); + ASSERT_TRUE(AMOUNT_1XMR == Bitmonero::Wallet::amountFromDouble(1.0)); + +} + +/* TEST_F(WalletTest1, WalletTransaction) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); @@ -415,7 +427,7 @@ TEST_F(WalletTest1, WalletTransaction) ASSERT_FALSE(wallet1->balance() == balance); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } - +*/ TEST_F(WalletTest1, WalletHistory) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); -- cgit v1.2.3 From f1c4a376af916604e2b142a1169d610f631bd91c Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Mon, 20 Jun 2016 22:56:30 +0300 Subject: Wallet::createTransaction: added mixin_count param --- tests/libwallet_api_tests/main.cpp | 41 +++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'tests/libwallet_api_tests') diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 849d76e1b..ddd6969c6 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -428,6 +428,45 @@ TEST_F(WalletTest1, WalletTransaction) ASSERT_TRUE(wmgr->closeWallet(wallet1)); } */ + +TEST_F(WalletTest1, WalletTransactionWithMixin) +{ + + std::vector mixins; + // 2,3,4,5,6,7,8,9,10,15,20,25 can we do it like that? + mixins.push_back(2); mixins.push_back(3); mixins.push_back(4); mixins.push_back(5); mixins.push_back(6); + mixins.push_back(7); mixins.push_back(8); mixins.push_back(9); mixins.push_back(10); mixins.push_back(15); + mixins.push_back(20); mixins.push_back(25); + + + Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); + + + // make sure testnet daemon is running + ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); + ASSERT_TRUE(wallet1->refresh()); + uint64_t balance = wallet1->balance(); + ASSERT_TRUE(wallet1->status() == Bitmonero::PendingTransaction::Status_Ok); + + std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS); + for (auto mixin : mixins) { + std::cerr << "Transaction mixin count: " << mixin << std::endl; + Bitmonero::PendingTransaction * transaction = wallet1->createTransaction( + recepient_address, AMOUNT_5XMR, mixin); + + std::cerr << "Transaction status: " << transaction->status() << std::endl; + std::cerr << "Transaction fee: " << Bitmonero::Wallet::displayAmount(transaction->fee()) << std::endl; + std::cerr << "Transaction error: " << transaction->errorString() << std::endl; + ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok); + wallet1->disposeTransaction(transaction); + } + + wallet1->refresh(); + + ASSERT_TRUE(wallet1->balance() == balance); + ASSERT_TRUE(wmgr->closeWallet(wallet1)); +} + TEST_F(WalletTest1, WalletHistory) { Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); @@ -465,7 +504,7 @@ TEST_F(WalletTest1, WalletTransactionAndHistory) std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS); - Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr, AMOUNT_10XMR * 5); + Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr, AMOUNT_10XMR * 5, 0); ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok); ASSERT_TRUE(tx->commit()); history = wallet_src->history(); -- cgit v1.2.3