2016-02-20 09:04:56 -07:00
|
|
|
// Copyright (c) 2014-2016, The Monero Project
|
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
// materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
// used to endorse or promote products derived from this software without specific
|
|
|
|
// prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
2016-04-22 04:21:08 -06:00
|
|
|
|
2016-02-20 09:04:56 -07:00
|
|
|
#include "wallet/wallet2_api.h"
|
2016-04-22 04:21:08 -06:00
|
|
|
|
2016-02-21 11:18:16 -07:00
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
2016-02-20 09:04:56 -07:00
|
|
|
|
2016-02-21 11:18:16 -07:00
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
2016-05-16 04:11:44 -06:00
|
|
|
#include <mutex>
|
|
|
|
#include <thread>
|
2016-02-21 11:18:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
2016-02-20 09:04:56 -07:00
|
|
|
//unsigned int epee::g_test_dbg_lock_sleep = 0;
|
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
namespace Consts
|
|
|
|
{
|
|
|
|
|
2016-06-01 08:06:10 -06:00
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
// 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";
|
|
|
|
|
2016-06-01 08:06:10 -06:00
|
|
|
// 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";
|
2016-06-03 05:52:58 -06:00
|
|
|
const std::string TESTNET_WALLET6_NAME = WALLETS_ROOT_DIR + "wallet_06.bin";
|
2016-06-01 08:06:10 -06:00
|
|
|
|
2016-06-23 05:38:22 -06:00
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
const char * TESTNET_WALLET_PASS = "";
|
|
|
|
|
2016-06-01 08:06:10 -06:00
|
|
|
const std::string CURRENT_SRC_WALLET = TESTNET_WALLET1_NAME;
|
2016-06-03 05:52:58 -06:00
|
|
|
const std::string CURRENT_DST_WALLET = TESTNET_WALLET6_NAME;
|
2016-05-16 04:11:44 -06:00
|
|
|
|
|
|
|
const char * TESTNET_DAEMON_ADDRESS = "localhost:38081";
|
2016-06-01 08:06:10 -06:00
|
|
|
const uint64_t AMOUNT_10XMR = 10000000000000L;
|
2016-05-17 03:16:11 -06:00
|
|
|
const uint64_t AMOUNT_5XMR = 5000000000000L;
|
|
|
|
const uint64_t AMOUNT_1XMR = 1000000000000L;
|
2016-05-16 04:11:44 -06:00
|
|
|
|
2016-06-23 05:38:22 -06:00
|
|
|
const std::string PAYMENT_ID_EMPTY = "";
|
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-17 03:16:11 -06:00
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
using namespace Consts;
|
|
|
|
|
2016-03-25 08:06:30 -06:00
|
|
|
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);
|
|
|
|
}
|
2016-05-16 04:11:44 -06:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2016-06-01 08:06:10 -06:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2016-03-25 08:06:30 -06:00
|
|
|
};
|
|
|
|
|
2016-02-20 09:04:56 -07:00
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
struct WalletManagerTest : public testing::Test
|
2016-02-20 09:04:56 -07:00
|
|
|
{
|
|
|
|
Bitmonero::WalletManager * wmgr;
|
|
|
|
|
2016-03-25 08:06:30 -06:00
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
WalletManagerTest()
|
2016-02-20 09:04:56 -07:00
|
|
|
{
|
2016-03-10 09:43:10 -07:00
|
|
|
std::cout << __FUNCTION__ << std::endl;
|
2016-02-20 09:04:56 -07:00
|
|
|
wmgr = Bitmonero::WalletManagerFactory::getWalletManager();
|
2016-03-25 08:06:30 -06:00
|
|
|
Utils::deleteWallet(WALLET_NAME);
|
|
|
|
Utils::deleteDir(boost::filesystem::path(WALLET_NAME_WITH_DIR).parent_path().string());
|
2016-02-20 09:04:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
~WalletManagerTest()
|
2016-02-21 11:18:16 -07:00
|
|
|
{
|
2016-03-10 09:43:10 -07:00
|
|
|
std::cout << __FUNCTION__ << std::endl;
|
2016-03-12 07:41:11 -07:00
|
|
|
//deleteWallet(WALLET_NAME);
|
2016-02-21 11:18:16 -07:00
|
|
|
}
|
2016-04-29 07:26:14 -06:00
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
struct WalletTest1 : public testing::Test
|
2016-05-16 04:11:44 -06:00
|
|
|
{
|
|
|
|
Bitmonero::WalletManager * wmgr;
|
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
WalletTest1()
|
2016-04-29 07:26:14 -06:00
|
|
|
{
|
2016-05-16 04:11:44 -06:00
|
|
|
wmgr = Bitmonero::WalletManagerFactory::getWalletManager();
|
|
|
|
}
|
2016-04-29 07:26:14 -06:00
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct WalletTest2 : public testing::Test
|
|
|
|
{
|
|
|
|
Bitmonero::WalletManager * wmgr;
|
|
|
|
|
|
|
|
WalletTest2()
|
|
|
|
{
|
|
|
|
wmgr = Bitmonero::WalletManagerFactory::getWalletManager();
|
2016-04-29 07:26:14 -06:00
|
|
|
}
|
2016-05-16 04:11:44 -06:00
|
|
|
|
|
|
|
|
2016-02-21 11:18:16 -07:00
|
|
|
};
|
2016-02-20 09:04:56 -07:00
|
|
|
|
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerCreatesWallet)
|
2016-02-20 09:04:56 -07:00
|
|
|
{
|
|
|
|
|
2016-03-31 03:48:41 -06:00
|
|
|
Bitmonero::Wallet * wallet = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
2016-03-10 09:43:10 -07:00
|
|
|
ASSERT_TRUE(wallet->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
ASSERT_TRUE(!wallet->seed().empty());
|
2016-02-21 11:18:16 -07:00
|
|
|
std::vector<std::string> words;
|
|
|
|
std::string seed = wallet->seed();
|
|
|
|
boost::split(words, seed, boost::is_any_of(" "), boost::token_compress_on);
|
2016-03-10 09:43:10 -07:00
|
|
|
ASSERT_TRUE(words.size() == 25);
|
2016-02-21 11:18:16 -07:00
|
|
|
std::cout << "** seed: " << wallet->seed() << std::endl;
|
2016-03-12 07:52:58 -07:00
|
|
|
ASSERT_FALSE(wallet->address().empty());
|
|
|
|
std::cout << "** address: " << wallet->address() << std::endl;
|
2016-03-10 09:43:10 -07:00
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet));
|
2016-03-12 07:52:58 -07:00
|
|
|
|
2016-03-10 09:43:10 -07:00
|
|
|
}
|
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerOpensWallet)
|
2016-03-10 09:43:10 -07:00
|
|
|
{
|
2016-03-11 07:05:36 -07:00
|
|
|
|
2016-03-31 03:48:41 -06:00
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
2016-03-10 09:43:10 -07:00
|
|
|
std::string seed1 = wallet1->seed();
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
2016-03-31 03:48:41 -06:00
|
|
|
Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
|
2016-03-10 09:43:10 -07:00
|
|
|
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
ASSERT_TRUE(wallet2->seed() == seed1);
|
|
|
|
std::cout << "** seed: " << wallet2->seed() << std::endl;
|
2016-02-20 09:04:56 -07:00
|
|
|
}
|
|
|
|
|
2016-06-10 03:51:09 -06:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
/*
|
|
|
|
TEST_F(WalletManagerTest, WalletManagerChangesPassword)
|
2016-03-11 07:05:36 -07:00
|
|
|
{
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
|
|
|
std::string seed1 = wallet1->seed();
|
|
|
|
ASSERT_TRUE(wallet1->setPassword(WALLET_PASS2));
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME, WALLET_PASS2);
|
2016-06-23 05:38:22 -06:00
|
|
|
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
2016-03-11 07:05:36 -07:00
|
|
|
ASSERT_TRUE(wallet2->seed() == seed1);
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
|
|
|
Bitmonero::Wallet * wallet3 = wmgr->openWallet(WALLET_NAME, WALLET_PASS);
|
|
|
|
ASSERT_FALSE(wallet3->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerRecoversWallet)
|
2016-03-12 07:41:11 -07:00
|
|
|
{
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
|
|
|
std::string seed1 = wallet1->seed();
|
2016-03-12 07:52:58 -07:00
|
|
|
std::string address1 = wallet1->address();
|
|
|
|
ASSERT_FALSE(address1.empty());
|
2016-03-12 07:41:11 -07:00
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
2016-03-31 03:48:41 -06:00
|
|
|
Utils::deleteWallet(WALLET_NAME);
|
2016-03-12 07:41:11 -07:00
|
|
|
Bitmonero::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1);
|
|
|
|
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
ASSERT_TRUE(wallet2->seed() == seed1);
|
2016-03-12 07:52:58 -07:00
|
|
|
ASSERT_TRUE(wallet2->address() == address1);
|
2016-03-12 07:41:11 -07:00
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
|
|
|
}
|
|
|
|
|
2016-03-11 07:05:36 -07:00
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet1)
|
2016-03-15 14:11:38 -06:00
|
|
|
{
|
|
|
|
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->store(WALLET_NAME_COPY));
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
Bitmonero::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_COPY, WALLET_PASS);
|
|
|
|
ASSERT_TRUE(wallet2->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
ASSERT_TRUE(wallet2->seed() == seed1);
|
|
|
|
ASSERT_TRUE(wallet2->address() == address1);
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
|
|
|
}
|
|
|
|
|
2016-03-21 07:17:03 -06:00
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet2)
|
2016-03-15 14:11:38 -06:00
|
|
|
{
|
|
|
|
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(WALLET_NAME_WITH_DIR));
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
|
|
|
|
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR, 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));
|
|
|
|
}
|
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet3)
|
2016-03-15 14:11:38 -06:00
|
|
|
{
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
|
|
|
|
std::string seed1 = wallet1->seed();
|
|
|
|
std::string address1 = wallet1->address();
|
|
|
|
|
|
|
|
ASSERT_FALSE(wallet1->store(WALLET_NAME_WITH_DIR_NON_WRITABLE));
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
|
|
|
|
wallet1 = wmgr->openWallet(WALLET_NAME_WITH_DIR_NON_WRITABLE, WALLET_PASS);
|
|
|
|
ASSERT_FALSE(wallet1->status() == Bitmonero::Wallet::Status_Ok);
|
|
|
|
|
|
|
|
ASSERT_FALSE(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));
|
|
|
|
|
|
|
|
}
|
2016-03-12 07:52:58 -07:00
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerStoresWallet4)
|
2016-03-21 07:17:03 -06:00
|
|
|
{
|
|
|
|
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));
|
2016-03-25 08:06:30 -06:00
|
|
|
}
|
2016-06-03 05:52:58 -06:00
|
|
|
*/
|
2016-03-31 03:48:41 -06:00
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletManagerFindsWallet)
|
|
|
|
{
|
|
|
|
std::vector<std::string> 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;
|
|
|
|
}
|
|
|
|
}
|
2016-03-25 08:06:30 -06:00
|
|
|
|
2016-06-23 05:38:22 -06:00
|
|
|
TEST_F(WalletManagerTest, WalletGeneratesPaymentId)
|
|
|
|
{
|
|
|
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
|
|
|
ASSERT_TRUE(payment_id.length() == 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(WalletManagerTest, WalletGeneratesIntegratedAddress)
|
|
|
|
{
|
|
|
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
|
|
|
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
|
|
|
std::string integrated_address = wallet1->integratedAddress(payment_id);
|
|
|
|
ASSERT_TRUE(integrated_address.length() == 106);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
TEST_F(WalletTest1, WalletShowsBalance)
|
2016-03-25 08:06:30 -06:00
|
|
|
{
|
2016-06-01 08:06:10 -06:00
|
|
|
// TODO: temporary disabled;
|
|
|
|
return;
|
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
2016-03-25 08:06:30 -06:00
|
|
|
ASSERT_TRUE(wallet1->balance() > 0);
|
2016-03-31 03:48:41 -06:00
|
|
|
ASSERT_TRUE(wallet1->unlockedBalance() > 0);
|
2016-03-25 08:06:30 -06:00
|
|
|
|
|
|
|
uint64_t balance1 = wallet1->balance();
|
2016-03-31 03:48:41 -06:00
|
|
|
uint64_t unlockedBalance1 = wallet1->unlockedBalance();
|
2016-03-25 08:06:30 -06:00
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
2016-06-01 08:06:10 -06:00
|
|
|
Bitmonero::Wallet * wallet2 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
2016-03-31 03:48:41 -06:00
|
|
|
|
2016-03-25 08:06:30 -06:00
|
|
|
ASSERT_TRUE(balance1 == wallet2->balance());
|
2016-03-31 03:48:41 -06:00
|
|
|
std::cout << "wallet balance: " << wallet2->balance() << std::endl;
|
|
|
|
ASSERT_TRUE(unlockedBalance1 == wallet2->unlockedBalance());
|
|
|
|
std::cout << "wallet unlocked balance: " << wallet2->unlockedBalance() << std::endl;
|
2016-03-25 08:06:30 -06:00
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet2));
|
2016-03-21 07:17:03 -06:00
|
|
|
}
|
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
TEST_F(WalletTest1, WalletRefresh)
|
2016-03-31 07:38:57 -06:00
|
|
|
{
|
2016-06-01 08:06:10 -06:00
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
2016-03-31 07:38:57 -06:00
|
|
|
// make sure testnet daemon is running
|
|
|
|
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
|
|
|
|
ASSERT_TRUE(wallet1->refresh());
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
}
|
|
|
|
|
2016-06-03 05:52:58 -06:00
|
|
|
|
2016-06-16 07:42:33 -06:00
|
|
|
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));
|
|
|
|
|
|
|
|
}
|
2016-06-03 05:52:58 -06:00
|
|
|
|
2016-06-16 07:42:33 -06:00
|
|
|
|
|
|
|
/*
|
2016-05-27 04:35:00 -06:00
|
|
|
TEST_F(WalletTest1, WalletTransaction)
|
2016-04-03 05:34:38 -06:00
|
|
|
{
|
2016-06-01 08:06:10 -06:00
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
2016-04-03 05:34:38 -06:00
|
|
|
// make sure testnet daemon is running
|
|
|
|
ASSERT_TRUE(wallet1->init(TESTNET_DAEMON_ADDRESS, 0));
|
|
|
|
ASSERT_TRUE(wallet1->refresh());
|
|
|
|
uint64_t balance = wallet1->balance();
|
2016-04-05 06:24:44 -06:00
|
|
|
ASSERT_TRUE(wallet1->status() == Bitmonero::PendingTransaction::Status_Ok);
|
|
|
|
|
2016-06-01 08:06:10 -06:00
|
|
|
std::string recepient_address = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
|
2016-06-10 04:52:10 -06:00
|
|
|
wallet1->setDefaultMixin(1);
|
|
|
|
ASSERT_TRUE(wallet1->defaultMixin() == 1);
|
2016-06-01 08:06:10 -06:00
|
|
|
|
2016-04-05 06:24:44 -06:00
|
|
|
Bitmonero::PendingTransaction * transaction = wallet1->createTransaction(
|
2016-06-01 08:06:10 -06:00
|
|
|
recepient_address, AMOUNT_10XMR);
|
2016-04-05 06:24:44 -06:00
|
|
|
ASSERT_TRUE(transaction->status() == Bitmonero::PendingTransaction::Status_Ok);
|
2016-06-01 08:06:10 -06:00
|
|
|
wallet1->refresh();
|
2016-04-29 07:26:14 -06:00
|
|
|
|
2016-04-05 06:24:44 -06:00
|
|
|
ASSERT_TRUE(wallet1->balance() == balance);
|
|
|
|
ASSERT_TRUE(transaction->amount() == AMOUNT_10XMR);
|
|
|
|
ASSERT_TRUE(transaction->commit());
|
2016-04-03 05:34:38 -06:00
|
|
|
ASSERT_FALSE(wallet1->balance() == balance);
|
|
|
|
ASSERT_TRUE(wmgr->closeWallet(wallet1));
|
|
|
|
}
|
2016-06-16 07:42:33 -06:00
|
|
|
*/
|
2016-06-20 13:56:30 -06:00
|
|
|
|
|
|
|
TEST_F(WalletTest1, WalletTransactionWithMixin)
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<int> 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);
|
|
|
|
|
2016-06-23 05:38:22 -06:00
|
|
|
std::string payment_id = "";
|
|
|
|
|
2016-06-20 13:56:30 -06:00
|
|
|
|
|
|
|
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(
|
2016-06-23 05:38:22 -06:00
|
|
|
recepient_address, payment_id, AMOUNT_5XMR, mixin);
|
2016-06-20 13:56:30 -06:00
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
TEST_F(WalletTest1, WalletHistory)
|
2016-04-22 04:21:08 -06:00
|
|
|
{
|
2016-06-01 08:06:10 -06:00
|
|
|
Bitmonero::Wallet * wallet1 = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
2016-04-22 04:21:08 -06:00
|
|
|
// 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);
|
|
|
|
|
2016-04-29 07:26:14 -06:00
|
|
|
|
|
|
|
for (auto t: history->getAll()) {
|
|
|
|
ASSERT_TRUE(t != nullptr);
|
2016-05-16 04:11:44 -06:00
|
|
|
Utils::print_transaction(t);
|
2016-04-29 07:26:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
TEST_F(WalletTest1, WalletTransactionAndHistory)
|
2016-04-29 07:26:14 -06:00
|
|
|
{
|
2016-06-01 08:06:10 -06:00
|
|
|
return;
|
|
|
|
Bitmonero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, true);
|
2016-04-29 07:26:14 -06:00
|
|
|
// 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);
|
2016-05-16 04:11:44 -06:00
|
|
|
Utils::print_transaction(t);
|
2016-04-29 07:26:14 -06:00
|
|
|
}
|
|
|
|
|
2016-06-01 08:06:10 -06:00
|
|
|
std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
|
|
|
|
|
2016-06-23 05:38:22 -06:00
|
|
|
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
|
|
|
|
PAYMENT_ID_EMPTY,
|
|
|
|
AMOUNT_10XMR * 5, 0);
|
|
|
|
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);
|
|
|
|
Utils::print_transaction(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(WalletTest1, WalletTransactionWithPaymentId)
|
|
|
|
{
|
|
|
|
|
|
|
|
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());
|
|
|
|
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);
|
|
|
|
Utils::print_transaction(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string wallet4_addr = Utils::get_wallet_address(CURRENT_DST_WALLET, TESTNET_WALLET_PASS);
|
|
|
|
|
|
|
|
std::string payment_id = Bitmonero::Wallet::genPaymentId();
|
|
|
|
ASSERT_TRUE(payment_id.length() == 16);
|
|
|
|
|
|
|
|
|
|
|
|
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
|
|
|
|
payment_id,
|
|
|
|
AMOUNT_1XMR, 1);
|
|
|
|
|
2016-04-29 07:26:14 -06:00
|
|
|
ASSERT_TRUE(tx->status() == Bitmonero::PendingTransaction::Status_Ok);
|
|
|
|
ASSERT_TRUE(tx->commit());
|
|
|
|
history = wallet_src->history();
|
|
|
|
history->refresh();
|
|
|
|
ASSERT_TRUE(count1 != history->count());
|
|
|
|
|
2016-06-23 05:38:22 -06:00
|
|
|
bool payment_id_in_history = false;
|
|
|
|
|
2016-04-29 07:26:14 -06:00
|
|
|
std::cout << "**** Transactions after transfer (" << history->count() << ")" << std::endl;
|
2016-04-22 04:21:08 -06:00
|
|
|
for (auto t: history->getAll()) {
|
|
|
|
ASSERT_TRUE(t != nullptr);
|
2016-05-16 04:11:44 -06:00
|
|
|
Utils::print_transaction(t);
|
2016-06-23 05:38:22 -06:00
|
|
|
if (t->paymentId() == payment_id) {
|
|
|
|
payment_id_in_history = true;
|
|
|
|
}
|
2016-04-22 04:21:08 -06:00
|
|
|
}
|
2016-06-23 05:38:22 -06:00
|
|
|
|
|
|
|
ASSERT_TRUE(payment_id_in_history);
|
2016-04-22 04:21:08 -06:00
|
|
|
}
|
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-17 03:16:11 -06:00
|
|
|
/*
|
2016-05-16 04:11:44 -06:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t amount = AMOUNT_10XMR * 5;
|
|
|
|
std::cout << "** Sending " << Bitmonero::Wallet::displayAmount(amount) << " to " << TESTNET_WALLET4_ADDRESS;
|
2016-05-17 03:16:11 -06:00
|
|
|
Bitmonero::PendingTransaction * tx = wallet_src->createTransaction(TESTNET_WALLET4_ADDRESS, AMOUNT_1XMR * 5);
|
2016-05-16 04:11:44 -06:00
|
|
|
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);
|
2016-04-03 05:34:38 -06:00
|
|
|
|
2016-05-16 04:11:44 -06:00
|
|
|
ASSERT_TRUE(wallet_src_listener->total_tx != 0);
|
2016-05-17 03:16:11 -06:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
/*
|
2016-05-17 03:16:11 -06:00
|
|
|
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());
|
|
|
|
|
2016-05-27 04:35:00 -06:00
|
|
|
std::chrono::seconds wait_for = std::chrono::seconds(60*4);
|
2016-05-17 03:16:11 -06:00
|
|
|
|
|
|
|
wallet_dst_listener->guard.lock();
|
|
|
|
wallet_dst_listener->guard.try_lock_for(wait_for);
|
|
|
|
|
|
|
|
ASSERT_TRUE(wallet_dst_listener->total_tx != 0);
|
2016-05-16 04:11:44 -06:00
|
|
|
|
|
|
|
}
|
2016-05-27 04:35:00 -06:00
|
|
|
*/
|
2016-03-21 07:17:03 -06:00
|
|
|
|
2016-02-20 09:04:56 -07:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2016-04-05 06:24:44 -06:00
|
|
|
|
2016-02-20 09:04:56 -07:00
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|