diff options
Diffstat (limited to 'tests/libwallet_api_tests/main.cpp')
-rw-r--r-- | tests/libwallet_api_tests/main.cpp | 114 |
1 files changed, 59 insertions, 55 deletions
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index d08ab7c75..a3cf227de 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -130,7 +130,7 @@ struct Utils { Monero::WalletManager *wmgr = Monero::WalletManagerFactory::getWalletManager(); Monero::Wallet * w = wmgr->openWallet(filename, password, true); - std::string result = w->address(); + std::string result = w->mainAddress(); wmgr->closeWallet(w); return result; } @@ -215,8 +215,8 @@ TEST_F(WalletManagerTest, WalletManagerCreatesWallet) boost::split(words, seed, boost::is_any_of(" "), boost::token_compress_on); ASSERT_TRUE(words.size() == 25); std::cout << "** seed: " << wallet->seed() << std::endl; - ASSERT_FALSE(wallet->address().empty()); - std::cout << "** address: " << wallet->address() << std::endl; + ASSERT_FALSE(wallet->mainAddress().empty()); + std::cout << "** address: " << wallet->mainAddress() << std::endl; ASSERT_TRUE(wmgr->closeWallet(wallet)); } @@ -261,7 +261,7 @@ void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, co mutex->lock(); 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 address: " << (*wallet)->mainAddress()); LOG_PRINT_L3("wallet status: " << (*wallet)->status()); LOG_PRINT_L3("closing wallet in thread: " << boost::this_thread::get_id()); if (mutex) @@ -371,14 +371,14 @@ TEST_F(WalletManagerTest, WalletManagerRecoversWallet) { Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); - std::string address1 = wallet1->address(); + std::string address1 = wallet1->mainAddress(); ASSERT_FALSE(address1.empty()); ASSERT_TRUE(wmgr->closeWallet(wallet1)); Utils::deleteWallet(WALLET_NAME); Monero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1); ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok); ASSERT_TRUE(wallet2->seed() == seed1); - ASSERT_TRUE(wallet2->address() == address1); + ASSERT_TRUE(wallet2->mainAddress() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet2)); } @@ -387,7 +387,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet1) { Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); - std::string address1 = wallet1->address(); + std::string address1 = wallet1->mainAddress(); ASSERT_TRUE(wallet1->store("")); ASSERT_TRUE(wallet1->store(WALLET_NAME_COPY)); @@ -395,7 +395,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet1) Monero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_COPY, WALLET_PASS); ASSERT_TRUE(wallet2->status() == Monero::Wallet::Status_Ok); ASSERT_TRUE(wallet2->seed() == seed1); - ASSERT_TRUE(wallet2->address() == address1); + ASSERT_TRUE(wallet2->mainAddress() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet2)); } @@ -404,7 +404,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2) { Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); - std::string address1 = wallet1->address(); + std::string address1 = wallet1->mainAddress(); ASSERT_TRUE(wallet1->store(WALLET_NAME_WITH_DIR)); ASSERT_TRUE(wmgr->closeWallet(wallet1)); @@ -412,7 +412,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet2) wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR, WALLET_PASS); ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok); ASSERT_TRUE(wallet1->seed() == seed1); - ASSERT_TRUE(wallet1->address() == address1); + ASSERT_TRUE(wallet1->mainAddress() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } @@ -421,7 +421,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3) { Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); - std::string address1 = wallet1->address(); + std::string address1 = wallet1->mainAddress(); ASSERT_FALSE(wallet1->store(WALLET_NAME_WITH_DIR_NON_WRITABLE)); ASSERT_TRUE(wmgr->closeWallet(wallet1)); @@ -435,7 +435,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet3) wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS); ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok); ASSERT_TRUE(wallet1->seed() == seed1); - ASSERT_TRUE(wallet1->address() == address1); + ASSERT_TRUE(wallet1->mainAddress() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } @@ -445,7 +445,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet4) { Monero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG); std::string seed1 = wallet1->seed(); - std::string address1 = wallet1->address(); + std::string address1 = wallet1->mainAddress(); ASSERT_TRUE(wallet1->store("")); ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok); @@ -458,7 +458,7 @@ TEST_F(WalletManagerTest, WalletManagerStoresWallet4) wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS); ASSERT_TRUE(wallet1->status() == Monero::Wallet::Status_Ok); ASSERT_TRUE(wallet1->seed() == seed1); - ASSERT_TRUE(wallet1->address() == address1); + ASSERT_TRUE(wallet1->mainAddress() == address1); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } @@ -496,18 +496,18 @@ TEST_F(WalletTest1, WalletGeneratesIntegratedAddress) TEST_F(WalletTest1, WalletShowsBalance) { Monero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); - ASSERT_TRUE(wallet1->balance() > 0); - ASSERT_TRUE(wallet1->unlockedBalance() > 0); + ASSERT_TRUE(wallet1->balance(0) > 0); + ASSERT_TRUE(wallet1->unlockedBalance(0) > 0); - uint64_t balance1 = wallet1->balance(); - uint64_t unlockedBalance1 = wallet1->unlockedBalance(); + uint64_t balance1 = wallet1->balance(0); + uint64_t unlockedBalance1 = wallet1->unlockedBalance(0); ASSERT_TRUE(wmgr->closeWallet(wallet1)); Monero::Wallet * wallet2 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true); - 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(balance1 == wallet2->balance(0)); + std::cout << "wallet balance: " << wallet2->balance(0) << std::endl; + ASSERT_TRUE(unlockedBalance1 == wallet2->unlockedBalance(0)); + std::cout << "wallet unlocked balance: " << wallet2->unlockedBalance(0) << std::endl; ASSERT_TRUE(wmgr->closeWallet(wallet2)); } @@ -569,7 +569,7 @@ TEST_F(WalletTest1, WalletTransaction) // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); - uint64_t balance = wallet1->balance(); + uint64_t balance = wallet1->balance(0); ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok); std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS); @@ -580,14 +580,16 @@ TEST_F(WalletTest1, WalletTransaction) PAYMENT_ID_EMPTY, AMOUNT_10XMR, MIXIN_COUNT, + 0, + std::set<uint32_t>{}, Monero::PendingTransaction::Priority_Medium); ASSERT_TRUE(transaction->status() == Monero::PendingTransaction::Status_Ok); wallet1->refresh(); - ASSERT_TRUE(wallet1->balance() == balance); + ASSERT_TRUE(wallet1->balance(0) == balance); ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR); ASSERT_TRUE(transaction->commit()); - ASSERT_FALSE(wallet1->balance() == balance); + ASSERT_FALSE(wallet1->balance(0) == balance); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } @@ -611,14 +613,15 @@ TEST_F(WalletTest1, WalletTransactionWithMixin) // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); - uint64_t balance = wallet1->balance(); + uint64_t balance = wallet1->balance(0); ASSERT_TRUE(wallet1->status() == Monero::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; + Monero::PendingTransaction * transaction = wallet1->createTransaction( - recepient_address, payment_id, AMOUNT_5XMR, mixin); + recepient_address, payment_id, AMOUNT_5XMR, mixin, 0, std::set<uint32_t>{}); std::cerr << "Transaction status: " << transaction->status() << std::endl; std::cerr << "Transaction fee: " << Monero::Wallet::displayAmount(transaction->fee()) << std::endl; @@ -629,7 +632,7 @@ TEST_F(WalletTest1, WalletTransactionWithMixin) wallet1->refresh(); - ASSERT_TRUE(wallet1->balance() == balance); + ASSERT_TRUE(wallet1->balance(0) == balance); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } @@ -643,7 +646,7 @@ TEST_F(WalletTest1, WalletTransactionWithPriority) // make sure testnet daemon is running ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet1->refresh()); - uint64_t balance = wallet1->balance(); + uint64_t balance = wallet1->balance(0); ASSERT_TRUE(wallet1->status() == Monero::PendingTransaction::Status_Ok); std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS); @@ -658,8 +661,9 @@ TEST_F(WalletTest1, WalletTransactionWithPriority) for (auto it = priorities.begin(); it != priorities.end(); ++it) { std::cerr << "Transaction priority: " << *it << std::endl; + Monero::PendingTransaction * transaction = wallet1->createTransaction( - recepient_address, payment_id, AMOUNT_5XMR, mixin, *it); + recepient_address, payment_id, AMOUNT_5XMR, mixin, 0, std::set<uint32_t>{}, *it); std::cerr << "Transaction status: " << transaction->status() << std::endl; std::cerr << "Transaction fee: " << Monero::Wallet::displayAmount(transaction->fee()) << std::endl; std::cerr << "Transaction error: " << transaction->errorString() << std::endl; @@ -669,7 +673,7 @@ TEST_F(WalletTest1, WalletTransactionWithPriority) wallet1->disposeTransaction(transaction); } wallet1->refresh(); - ASSERT_TRUE(wallet1->balance() == balance); + ASSERT_TRUE(wallet1->balance(0) == balance); ASSERT_TRUE(wmgr->closeWallet(wallet1)); } @@ -715,7 +719,7 @@ TEST_F(WalletTest1, WalletTransactionAndHistory) Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr, PAYMENT_ID_EMPTY, - AMOUNT_10XMR * 5, 1); + AMOUNT_10XMR * 5, 1, 0, std::set<uint32_t>{}); ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok); ASSERT_TRUE(tx->commit()); @@ -757,7 +761,7 @@ TEST_F(WalletTest1, WalletTransactionWithPaymentId) Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr, payment_id, - AMOUNT_1XMR, 1); + AMOUNT_1XMR, 1, 0, std::set<uint32_t>{}); ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok); ASSERT_TRUE(tx->commit()); @@ -816,7 +820,7 @@ struct MyWalletListener : public Monero::WalletListener virtual void moneySpent(const string &txId, uint64_t amount) { - std::cerr << "wallet: " << wallet->address() << "**** just spent money (" + std::cerr << "wallet: " << wallet->mainAddress() << "**** just spent money (" << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl; total_tx += amount; send_triggered = true; @@ -825,7 +829,7 @@ struct MyWalletListener : public Monero::WalletListener virtual void moneyReceived(const string &txId, uint64_t amount) { - std::cout << "wallet: " << wallet->address() << "**** just received money (" + std::cout << "wallet: " << wallet->mainAddress() << "**** just received money (" << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl; total_rx += amount; receive_triggered = true; @@ -834,7 +838,7 @@ struct MyWalletListener : public Monero::WalletListener virtual void unconfirmedMoneyReceived(const string &txId, uint64_t amount) { - std::cout << "wallet: " << wallet->address() << "**** just received unconfirmed money (" + std::cout << "wallet: " << wallet->mainAddress() << "**** just received unconfirmed money (" << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl; // Don't trigger recieve until tx is mined // total_rx += amount; @@ -844,7 +848,7 @@ struct MyWalletListener : public Monero::WalletListener virtual void newBlock(uint64_t height) { -// std::cout << "wallet: " << wallet->address() +// std::cout << "wallet: " << wallet->mainAddress() // <<", new block received, blockHeight: " << height << std::endl; static int bc_height = wallet->daemonBlockChainHeight(); std::cout << height @@ -920,17 +924,17 @@ TEST_F(WalletTest2, WalletCallbackSent) ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet_src->refresh()); MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src); - uint64_t balance = wallet_src->balance(); - std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl; + uint64_t balance = wallet_src->balance(0); + std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl; Monero::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, true); uint64_t amount = AMOUNT_1XMR * 5; - std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->address(); + std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress(); - Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->address(), + Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(), PAYMENT_ID_EMPTY, - amount, 1); + amount, 1, 0, std::set<uint32_t>{}); std::cout << "** Committing transaction: " << Monero::Wallet::displayAmount(tx->amount()) << " with fee: " << Monero::Wallet::displayAmount(tx->fee()); @@ -944,8 +948,8 @@ TEST_F(WalletTest2, WalletCallbackSent) std::cerr << "TEST: send lock acquired...\n"; ASSERT_TRUE(wallet_src_listener->send_triggered); ASSERT_TRUE(wallet_src_listener->update_triggered); - std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl; - ASSERT_TRUE(wallet_src->balance() < balance); + std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl; + ASSERT_TRUE(wallet_src->balance(0) < balance); wmgr->closeWallet(wallet_src); wmgr->closeWallet(wallet_dst); } @@ -958,20 +962,20 @@ TEST_F(WalletTest2, WalletCallbackReceived) // make sure testnet daemon is running ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet_src->refresh()); - std::cout << "** Balance src1: " << wallet_src->displayAmount(wallet_src->balance()) << std::endl; + std::cout << "** Balance src1: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl; Monero::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, true); ASSERT_TRUE(wallet_dst->init(TESTNET_DAEMON_ADDRESS, 0)); ASSERT_TRUE(wallet_dst->refresh()); - uint64_t balance = wallet_dst->balance(); - std::cout << "** Balance dst1: " << wallet_dst->displayAmount(wallet_dst->balance()) << std::endl; + uint64_t balance = wallet_dst->balance(0); + std::cout << "** Balance dst1: " << wallet_dst->displayAmount(wallet_dst->balance(0)) << std::endl; std::unique_ptr<MyWalletListener> wallet_dst_listener (new MyWalletListener(wallet_dst)); uint64_t amount = AMOUNT_1XMR * 5; - std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->address(); - Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->address(), + std::cout << "** Sending " << Monero::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress(); + Monero::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(), PAYMENT_ID_EMPTY, - amount, 1); + amount, 1, 0, std::set<uint32_t>{}); std::cout << "** Committing transaction: " << Monero::Wallet::displayAmount(tx->amount()) << " with fee: " << Monero::Wallet::displayAmount(tx->fee()); @@ -987,10 +991,10 @@ TEST_F(WalletTest2, WalletCallbackReceived) ASSERT_TRUE(wallet_dst_listener->receive_triggered); ASSERT_TRUE(wallet_dst_listener->update_triggered); - std::cout << "** Balance src2: " << wallet_dst->displayAmount(wallet_src->balance()) << std::endl; - std::cout << "** Balance dst2: " << wallet_dst->displayAmount(wallet_dst->balance()) << std::endl; + std::cout << "** Balance src2: " << wallet_dst->displayAmount(wallet_src->balance(0)) << std::endl; + std::cout << "** Balance dst2: " << wallet_dst->displayAmount(wallet_dst->balance(0)) << std::endl; - ASSERT_TRUE(wallet_dst->balance() > balance); + ASSERT_TRUE(wallet_dst->balance(0) > balance); wmgr->closeWallet(wallet_src); wmgr->closeWallet(wallet_dst); @@ -1099,7 +1103,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync) int SECONDS_TO_REFRESH = 120; Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG); std::string seed = wallet->seed(); - std::string address = wallet->address(); + std::string address = wallet->mainAddress(); wmgr->closeWallet(wallet); // deleting wallet files @@ -1108,7 +1112,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync) wallet = wmgr->recoveryWallet(WALLET_NAME_MAINNET, seed); ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok); - ASSERT_TRUE(wallet->address() == address); + ASSERT_TRUE(wallet->mainAddress() == address); std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet)); boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH); boost::unique_lock<boost::mutex> lock (wallet_listener->mutex); |