Electroneum
main.cpp File Reference
#include "gtest/gtest.h"
#include "wallet/api/wallet2_api.h"
#include "wallet/wallet2.h"
#include "include_base_utils.h"
#include "common/util.h"
#include <boost/chrono/chrono.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <iostream>
#include <vector>
#include <atomic>
#include <functional>
Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

struct  Utils
 
struct  WalletManagerTest
 
struct  WalletManagerMainnetTest
 
struct  WalletTest1
 
struct  WalletTest2
 
struct  MyWalletListener
 

Namespaces

 Consts
 

Functions

 TEST_F (WalletManagerTest, WalletManagerCreatesWallet)
 
 TEST_F (WalletManagerTest, WalletManagerOpensWallet)
 
 TEST_F (WalletManagerTest, WalletMaxAmountAsString)
 
 TEST_F (WalletManagerTest, WalletAmountFromString)
 
void open_wallet_helper (Electroneum::WalletManager *wmgr, Electroneum::Wallet **wallet, const std::string &pass, boost::mutex *mutex)
 
 TEST_F (WalletManagerTest, WalletManagerOpensWalletWithPasswordAndReopen)
 
 TEST_F (WalletManagerTest, WalletManagerStoresWallet)
 
 TEST_F (WalletManagerTest, WalletManagerMovesWallet)
 
 TEST_F (WalletManagerTest, WalletManagerChangesPassword)
 
 TEST_F (WalletManagerTest, WalletManagerRecoversWallet)
 
 TEST_F (WalletManagerTest, WalletManagerStoresWallet1)
 
 TEST_F (WalletManagerTest, WalletManagerStoresWallet2)
 
 TEST_F (WalletManagerTest, WalletManagerStoresWallet3)
 
 TEST_F (WalletManagerTest, WalletManagerStoresWallet4)
 
 TEST_F (WalletManagerTest, WalletManagerFindsWallet)
 
 TEST_F (WalletTest1, WalletGeneratesPaymentId)
 
 TEST_F (WalletTest1, WalletGeneratesIntegratedAddress)
 
 TEST_F (WalletTest1, WalletShowsBalance)
 
 TEST_F (WalletTest1, WalletReturnsCurrentBlockHeight)
 
 TEST_F (WalletTest1, WalletReturnsDaemonBlockHeight)
 
 TEST_F (WalletTest1, WalletRefresh)
 
 TEST_F (WalletTest1, WalletConvertsToString)
 
 TEST_F (WalletTest1, WalletTransaction)
 
 TEST_F (WalletTest1, WalletTransactionWithMixin)
 
 TEST_F (WalletTest1, WalletTransactionWithPriority)
 
 TEST_F (WalletTest1, WalletHistory)
 
 TEST_F (WalletTest1, WalletTransactionAndHistory)
 
 TEST_F (WalletTest1, WalletTransactionWithPaymentId)
 
 TEST_F (WalletTest2, WalletCallBackRefreshedSync)
 
 TEST_F (WalletTest2, WalletCallBackRefreshedAsync)
 
 TEST_F (WalletTest2, WalletCallbackSent)
 
 TEST_F (WalletTest2, WalletCallbackReceived)
 
 TEST_F (WalletTest2, WalletCallbackNewBlock)
 
 TEST_F (WalletManagerMainnetTest, CreateOpenAndRefreshWalletMainNetSync)
 
 TEST_F (WalletManagerMainnetTest, CreateAndRefreshWalletMainNetAsync)
 
 TEST_F (WalletManagerMainnetTest, OpenAndRefreshWalletMainNetAsync)
 
 TEST_F (WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
 
int main (int argc, char **argv)
 

Variables

const char * Consts::WALLET_NAME = "testwallet"
 
const char * Consts::WALLET_NAME_MAINNET = "testwallet_mainnet"
 
const char * Consts::WALLET_NAME_COPY = "testwallet_copy"
 
const char * Consts::WALLET_NAME_WITH_DIR = "walletdir/testwallet_test"
 
const char * Consts::WALLET_NAME_WITH_DIR_NON_WRITABLE = "/var/walletdir/testwallet_test"
 
const char * Consts::WALLET_PASS = "password"
 
const char * Consts::WALLET_PASS2 = "password22"
 
const char * Consts::WALLET_LANG = "English"
 
std::string Consts::WALLETS_ROOT_DIR = "/var/electroneum/testnet_pvt"
 
std::string Consts::TESTNET_WALLET1_NAME
 
std::string Consts::TESTNET_WALLET2_NAME
 
std::string Consts::TESTNET_WALLET3_NAME
 
std::string Consts::TESTNET_WALLET4_NAME
 
std::string Consts::TESTNET_WALLET5_NAME
 
std::string Consts::TESTNET_WALLET6_NAME
 
const char * Consts::TESTNET_WALLET_PASS = ""
 
std::string Consts::CURRENT_SRC_WALLET
 
std::string Consts::CURRENT_DST_WALLET
 
const uint64_t Consts::AMOUNT_10ETN = 10000000000000L
 
const uint64_t Consts::AMOUNT_5ETN = 5000000000000L
 
const uint64_t Consts::AMOUNT_1ETN = 1000000000000L
 
const std::string Consts::PAYMENT_ID_EMPTY = ""
 
std::string Consts::TESTNET_DAEMON_ADDRESS = "localhost:36968"
 
std::string Consts::MAINNET_DAEMON_ADDRESS = "localhost:26968"
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1141 of file main.cpp.

1142 {
1143  TRY_ENTRY();
1144 
1146  // we can override default values for "TESTNET_DAEMON_ADDRESS" and "WALLETS_ROOT_DIR"
1147 
1148  const char * testnet_daemon_addr = std::getenv("TESTNET_DAEMON_ADDRESS");
1149  if (testnet_daemon_addr) {
1150  TESTNET_DAEMON_ADDRESS = testnet_daemon_addr;
1151  }
1152 
1153  const char * mainnet_daemon_addr = std::getenv("MAINNET_DAEMON_ADDRESS");
1154  if (mainnet_daemon_addr) {
1155  MAINNET_DAEMON_ADDRESS = mainnet_daemon_addr;
1156  }
1157 
1158 
1159 
1160  const char * wallets_root_dir = std::getenv("WALLETS_ROOT_DIR");
1161  if (wallets_root_dir) {
1162  WALLETS_ROOT_DIR = wallets_root_dir;
1163  }
1164 
1165 
1166  TESTNET_WALLET1_NAME = WALLETS_ROOT_DIR + "/wallet_01.bin";
1167  TESTNET_WALLET2_NAME = WALLETS_ROOT_DIR + "/wallet_02.bin";
1168  TESTNET_WALLET3_NAME = WALLETS_ROOT_DIR + "/wallet_03.bin";
1169  TESTNET_WALLET4_NAME = WALLETS_ROOT_DIR + "/wallet_04.bin";
1170  TESTNET_WALLET5_NAME = WALLETS_ROOT_DIR + "/wallet_05.bin";
1171  TESTNET_WALLET6_NAME = WALLETS_ROOT_DIR + "/wallet_06.bin";
1172 
1175 
1176  ::testing::InitGoogleTest(&argc, argv);
1178  return RUN_ALL_TESTS();
1179  CATCH_ENTRY_L0("main", 1);
1180 }
static void setLogLevel(int level)
std::string TESTNET_WALLET2_NAME
Definition: main.cpp:74
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
std::string TESTNET_WALLET3_NAME
Definition: main.cpp:75
std::string MAINNET_DAEMON_ADDRESS
Definition: main.cpp:92
std::string TESTNET_WALLET1_NAME
Definition: main.cpp:73
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
std::string TESTNET_WALLET6_NAME
Definition: main.cpp:78
std::string TESTNET_WALLET4_NAME
Definition: main.cpp:76
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
bool on_startup()
Definition: util.cpp:778
#define TRY_ENTRY()
Definition: misc_log_ex.h:151
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
std::string WALLETS_ROOT_DIR
Definition: main.cpp:72
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: gtest.h:2232
#define CATCH_ENTRY_L0(lacation, return_val)
Definition: misc_log_ex.h:165
std::string TESTNET_WALLET5_NAME
Definition: main.cpp:77
Here is the call graph for this function:

◆ open_wallet_helper()

void open_wallet_helper ( Electroneum::WalletManager wmgr,
Electroneum::Wallet **  wallet,
const std::string &  pass,
boost::mutex *  mutex 
)

Definition at line 260 of file main.cpp.

261 {
262  if (mutex)
263  mutex->lock();
264  LOG_PRINT_L3("opening wallet in thread: " << boost::this_thread::get_id());
266  LOG_PRINT_L3("wallet address: " << (*wallet)->mainAddress());
267  LOG_PRINT_L3("wallet status: " << (*wallet)->status());
268  LOG_PRINT_L3("closing wallet in thread: " << boost::this_thread::get_id());
269  if (mutex)
270  mutex->unlock();
271 }
virtual Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds=1, WalletListener *listener=nullptr)=0
Opens existing wallet.
#define LOG_PRINT_L3(x)
Definition: misc_log_ex.h:102
const char * WALLET_NAME
Definition: main.cpp:63
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TEST_F() [1/36]

TEST_F ( WalletManagerTest  ,
WalletManagerCreatesWallet   
)

Definition at line 209 of file main.cpp.

210 {
211 
214  ASSERT_TRUE(!wallet->seed().empty());
215  std::vector<std::string> words;
216  std::string seed = wallet->seed();
217  boost::split(words, seed, boost::is_any_of(" "), boost::token_compress_on);
218  ASSERT_TRUE(words.size() == 25);
219  std::cout << "** seed: " << wallet->seed() << std::endl;
220  ASSERT_FALSE(wallet->mainAddress().empty());
221  std::cout << "** address: " << wallet->mainAddress() << std::endl;
222  ASSERT_TRUE(wmgr->closeWallet(wallet));
223 
224 }
::std::string string
Definition: gtest-port.h:1097
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
std::string mainAddress() const
Definition: wallet2_api.h:464
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [2/36]

TEST_F ( WalletManagerTest  ,
WalletManagerOpensWallet   
)

Definition at line 226 of file main.cpp.

227 {
228 
230  std::string seed1 = wallet1->seed();
231  ASSERT_TRUE(wmgr->closeWallet(wallet1));
233  ASSERT_TRUE(wallet2->status() == Electroneum::Wallet::Status_Ok);
234  ASSERT_TRUE(wallet2->seed() == seed1);
235  std::cout << "** seed: " << wallet2->seed() << std::endl;
236 }
::std::string string
Definition: gtest-port.h:1097
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [3/36]

TEST_F ( WalletManagerTest  ,
WalletMaxAmountAsString   
)

Definition at line 239 of file main.cpp.

240 {
243 
244 }
static uint64_t maximumAllowedAmount()
Definition: wallet.cpp:388
static std::string displayAmount(uint64_t amount)
Definition: wallet.cpp:299
#define LOG_PRINT_L3(x)
Definition: misc_log_ex.h:102
Here is the call graph for this function:

◆ TEST_F() [4/36]

TEST_F ( WalletManagerTest  ,
WalletAmountFromString   
)

Definition at line 247 of file main.cpp.

248 {
249  uint64_t amount = Electroneum::Wallet::amountFromString("18446740");
250  ASSERT_TRUE(amount > 0);
251  amount = Electroneum::Wallet::amountFromString("11000000000000");
252  ASSERT_FALSE(amount > 0);
254  ASSERT_FALSE(amount > 0);
255  amount = Electroneum::Wallet::amountFromString("10.1");
256  ASSERT_TRUE(amount > 0);
257 
258 }
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
unsigned __int64 uint64_t
Definition: stdint.h:136
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
static uint64_t amountFromString(const std::string &amount)
Definition: wallet.cpp:304
Here is the call graph for this function:

◆ TEST_F() [5/36]

TEST_F ( WalletManagerTest  ,
WalletManagerOpensWalletWithPasswordAndReopen   
)

Definition at line 302 of file main.cpp.

303 {
304  // create password protected wallet
305  std::string wallet_pass = "password";
306  std::string wrong_wallet_pass = "1111";
307  Electroneum::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, wallet_pass, WALLET_LANG, Electroneum::NetworkType::TESTNET);
308  std::string seed1 = wallet1->seed();
309  ASSERT_TRUE(wmgr->closeWallet(wallet1));
310 
311  Electroneum::Wallet *wallet2 = nullptr;
312  Electroneum::Wallet *wallet3 = nullptr;
313  boost::mutex mutex;
314 
315  open_wallet_helper(wmgr, &wallet2, wrong_wallet_pass, nullptr);
316  ASSERT_TRUE(wallet2 != nullptr);
317  ASSERT_TRUE(wallet2->status() != Electroneum::Wallet::Status_Ok);
318  ASSERT_TRUE(wmgr->closeWallet(wallet2));
319 
320  open_wallet_helper(wmgr, &wallet3, wallet_pass, nullptr);
321  ASSERT_TRUE(wallet3 != nullptr);
323  ASSERT_TRUE(wmgr->closeWallet(wallet3));
324 }
::std::string string
Definition: gtest-port.h:1097
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
void open_wallet_helper(Electroneum::WalletManager *wmgr, Electroneum::Wallet **wallet, const std::string &pass, boost::mutex *mutex)
Definition: main.cpp:260
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [6/36]

TEST_F ( WalletManagerTest  ,
WalletManagerStoresWallet   
)

Definition at line 327 of file main.cpp.

328 {
329 
331  std::string seed1 = wallet1->seed();
332  wallet1->store("");
333  ASSERT_TRUE(wmgr->closeWallet(wallet1));
335  ASSERT_TRUE(wallet2->status() == Electroneum::Wallet::Status_Ok);
336  ASSERT_TRUE(wallet2->seed() == seed1);
337 }
virtual bool store(const std::string &path)=0
store - stores wallet to file.
::std::string string
Definition: gtest-port.h:1097
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [7/36]

TEST_F ( WalletManagerTest  ,
WalletManagerMovesWallet   
)

Definition at line 340 of file main.cpp.

341 {
342 
344  std::string WALLET_NAME_MOVED = std::string("/tmp/") + WALLET_NAME + ".moved";
345  std::string seed1 = wallet1->seed();
346  ASSERT_TRUE(wallet1->store(WALLET_NAME_MOVED));
347 
348  Electroneum::Wallet * wallet2 = wmgr->openWallet(WALLET_NAME_MOVED, WALLET_PASS, Electroneum::NetworkType::MAINNET);
349  ASSERT_TRUE(wallet2->filename() == WALLET_NAME_MOVED);
350  ASSERT_TRUE(wallet2->keysFilename() == WALLET_NAME_MOVED + ".keys");
351  ASSERT_TRUE(wallet2->status() == Electroneum::Wallet::Status_Ok);
352  ASSERT_TRUE(wallet2->seed() == seed1);
353 }
virtual bool store(const std::string &path)=0
store - stores wallet to file.
::std::string string
Definition: gtest-port.h:1097
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [8/36]

TEST_F ( WalletManagerTest  ,
WalletManagerChangesPassword   
)

Definition at line 356 of file main.cpp.

357 {
359  std::string seed1 = wallet1->seed();
361  ASSERT_TRUE(wmgr->closeWallet(wallet1));
363  ASSERT_TRUE(wallet2->status() == Electroneum::Wallet::Status_Ok);
364  ASSERT_TRUE(wallet2->seed() == seed1);
365  ASSERT_TRUE(wmgr->closeWallet(wallet2));
367  ASSERT_FALSE(wallet3->status() == Electroneum::Wallet::Status_Ok);
368 }
::std::string string
Definition: gtest-port.h:1097
virtual bool setPassword(const std::string &password)=0
const char * WALLET_PASS2
Definition: main.cpp:69
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [9/36]

TEST_F ( WalletManagerTest  ,
WalletManagerRecoversWallet   
)

Definition at line 372 of file main.cpp.

373 {
375  std::string seed1 = wallet1->seed();
376  std::string address1 = wallet1->mainAddress();
377  ASSERT_FALSE(address1.empty());
378  ASSERT_TRUE(wmgr->closeWallet(wallet1));
380  Electroneum::Wallet * wallet2 = wmgr->recoveryWallet(WALLET_NAME, seed1, Electroneum::NetworkType::MAINNET);
382  ASSERT_TRUE(wallet2->seed() == seed1);
383  ASSERT_TRUE(wallet2->mainAddress() == address1);
384  ASSERT_TRUE(wmgr->closeWallet(wallet2));
385 }
::std::string string
Definition: gtest-port.h:1097
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
static void deleteWallet(const std::string &walletname)
Definition: main.cpp:103
std::string mainAddress() const
Definition: wallet2_api.h:464
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [10/36]

TEST_F ( WalletManagerTest  ,
WalletManagerStoresWallet1   
)

Definition at line 388 of file main.cpp.

389 {
391  std::string seed1 = wallet1->seed();
392  std::string address1 = wallet1->mainAddress();
393 
394  ASSERT_TRUE(wallet1->store(""));
396  ASSERT_TRUE(wmgr->closeWallet(wallet1));
398  ASSERT_TRUE(wallet2->status() == Electroneum::Wallet::Status_Ok);
399  ASSERT_TRUE(wallet2->seed() == seed1);
400  ASSERT_TRUE(wallet2->mainAddress() == address1);
401  ASSERT_TRUE(wmgr->closeWallet(wallet2));
402 }
virtual bool store(const std::string &path)=0
store - stores wallet to file.
::std::string string
Definition: gtest-port.h:1097
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
const char * WALLET_NAME_COPY
Definition: main.cpp:65
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
std::string mainAddress() const
Definition: wallet2_api.h:464
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [11/36]

TEST_F ( WalletManagerTest  ,
WalletManagerStoresWallet2   
)

Definition at line 405 of file main.cpp.

406 {
408  std::string seed1 = wallet1->seed();
409  std::string address1 = wallet1->mainAddress();
410 
412  ASSERT_TRUE(wmgr->closeWallet(wallet1));
413 
415  ASSERT_TRUE(wallet1->status() == Electroneum::Wallet::Status_Ok);
416  ASSERT_TRUE(wallet1->seed() == seed1);
417  ASSERT_TRUE(wallet1->mainAddress() == address1);
418  ASSERT_TRUE(wmgr->closeWallet(wallet1));
419 }
virtual bool store(const std::string &path)=0
store - stores wallet to file.
::std::string string
Definition: gtest-port.h:1097
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * WALLET_NAME_WITH_DIR
Definition: main.cpp:66
std::string mainAddress() const
Definition: wallet2_api.h:464
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [12/36]

TEST_F ( WalletManagerTest  ,
WalletManagerStoresWallet3   
)

Definition at line 422 of file main.cpp.

423 {
425  std::string seed1 = wallet1->seed();
426  std::string address1 = wallet1->mainAddress();
427 
429  ASSERT_TRUE(wmgr->closeWallet(wallet1));
430 
432  ASSERT_FALSE(wallet1->status() == Electroneum::Wallet::Status_Ok);
433 
434  // "close" always returns true;
435  ASSERT_TRUE(wmgr->closeWallet(wallet1));
436 
437  wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Electroneum::NetworkType::MAINNET);
438  ASSERT_TRUE(wallet1->status() == Electroneum::Wallet::Status_Ok);
439  ASSERT_TRUE(wallet1->seed() == seed1);
440  ASSERT_TRUE(wallet1->mainAddress() == address1);
441  ASSERT_TRUE(wmgr->closeWallet(wallet1));
442 
443 }
virtual bool store(const std::string &path)=0
store - stores wallet to file.
::std::string string
Definition: gtest-port.h:1097
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME_WITH_DIR_NON_WRITABLE
Definition: main.cpp:67
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
std::string mainAddress() const
Definition: wallet2_api.h:464
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [13/36]

TEST_F ( WalletManagerTest  ,
WalletManagerStoresWallet4   
)

Definition at line 446 of file main.cpp.

447 {
449  std::string seed1 = wallet1->seed();
450  std::string address1 = wallet1->mainAddress();
451 
452  ASSERT_TRUE(wallet1->store(""));
454 
455  ASSERT_TRUE(wallet1->store(""));
457 
458  ASSERT_TRUE(wmgr->closeWallet(wallet1));
459 
460  wallet1 = wmgr->openWallet(WALLET_NAME, WALLET_PASS, Electroneum::NetworkType::MAINNET);
461  ASSERT_TRUE(wallet1->status() == Electroneum::Wallet::Status_Ok);
462  ASSERT_TRUE(wallet1->seed() == seed1);
463  ASSERT_TRUE(wallet1->mainAddress() == address1);
464  ASSERT_TRUE(wmgr->closeWallet(wallet1));
465 }
virtual bool store(const std::string &path)=0
store - stores wallet to file.
::std::string string
Definition: gtest-port.h:1097
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
const char * WALLET_LANG
Definition: main.cpp:70
const char * WALLET_NAME
Definition: main.cpp:63
const char * WALLET_PASS
Definition: main.cpp:68
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
std::string mainAddress() const
Definition: wallet2_api.h:464
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [14/36]

TEST_F ( WalletManagerTest  ,
WalletManagerFindsWallet   
)

Definition at line 470 of file main.cpp.

471 {
472  std::vector<std::string> wallets = wmgr->findWallets(WALLETS_ROOT_DIR);
473  ASSERT_FALSE(wallets.empty());
474  std::cout << "Found wallets: " << std::endl;
475  for (auto wallet_path: wallets) {
476  std::cout << wallet_path << std::endl;
477  }
478 }
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
std::string WALLETS_ROOT_DIR
Definition: main.cpp:72

◆ TEST_F() [15/36]

TEST_F ( WalletTest1  ,
WalletGeneratesPaymentId   
)

Definition at line 481 of file main.cpp.

482 {
484  ASSERT_TRUE(payment_id.length() == 16);
485 }
::std::string string
Definition: gtest-port.h:1097
static std::string genPaymentId()
Definition: wallet.cpp:318
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
Here is the call graph for this function:

◆ TEST_F() [16/36]

TEST_F ( WalletTest1  ,
WalletGeneratesIntegratedAddress   
)

Definition at line 488 of file main.cpp.

489 {
491 
493  std::string integrated_address = wallet1->integratedAddress(payment_id);
494  ASSERT_TRUE(integrated_address.length() == 106);
495 }
::std::string string
Definition: gtest-port.h:1097
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual std::string integratedAddress(const std::string &payment_id) const =0
integratedAddress - returns integrated address for current wallet address and given payment_id...
static std::string genPaymentId()
Definition: wallet.cpp:318
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [17/36]

TEST_F ( WalletTest1  ,
WalletShowsBalance   
)

Definition at line 498 of file main.cpp.

499 {
501  ASSERT_TRUE(wallet1->balance(0) > 0);
502  ASSERT_TRUE(wallet1->unlockedBalance(0) > 0);
503 
504  uint64_t balance1 = wallet1->balance(0);
505  uint64_t unlockedBalance1 = wallet1->unlockedBalance(0);
506  ASSERT_TRUE(wmgr->closeWallet(wallet1));
508 
509  ASSERT_TRUE(balance1 == wallet2->balance(0));
510  std::cout << "wallet balance: " << wallet2->balance(0) << std::endl;
511  ASSERT_TRUE(unlockedBalance1 == wallet2->unlockedBalance(0));
512  std::cout << "wallet unlocked balance: " << wallet2->unlockedBalance(0) << std::endl;
513  ASSERT_TRUE(wmgr->closeWallet(wallet2));
514 }
virtual uint64_t unlockedBalance(uint32_t accountIndex=0, bool public_blockchain=false) const =0
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
unsigned __int64 uint64_t
Definition: stdint.h:136
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual uint64_t balance(uint32_t accountIndex=0, bool public_blockchain=false) const =0
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [18/36]

TEST_F ( WalletTest1  ,
WalletReturnsCurrentBlockHeight   
)

Definition at line 516 of file main.cpp.

517 {
519  ASSERT_TRUE(wallet1->blockChainHeight() > 0);
520  wmgr->closeWallet(wallet1);
521 }
virtual uint64_t blockChainHeight() const =0
blockChainHeight - returns current blockchain height
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [19/36]

TEST_F ( WalletTest1  ,
WalletReturnsDaemonBlockHeight   
)

Definition at line 524 of file main.cpp.

525 {
527  // wallet not connected to daemon
528  ASSERT_TRUE(wallet1->daemonBlockChainHeight() == 0);
530  ASSERT_FALSE(wallet1->errorString().empty());
531  wmgr->closeWallet(wallet1);
532 
534  // wallet connected to daemon
535  wallet1->init(TESTNET_DAEMON_ADDRESS, 0);
536  ASSERT_TRUE(wallet1->daemonBlockChainHeight() > 0);
537  std::cout << "daemonBlockChainHeight: " << wallet1->daemonBlockChainHeight() << std::endl;
538  wmgr->closeWallet(wallet1);
539 }
virtual std::string errorString() const =0
in case error status, returns error string
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual uint64_t daemonBlockChainHeight() const =0
daemonBlockChainHeight - returns daemon blockchain height
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [20/36]

TEST_F ( WalletTest1  ,
WalletRefresh   
)

Definition at line 542 of file main.cpp.

543 {
544 
545  std::cout << "Opening wallet: " << CURRENT_SRC_WALLET << std::endl;
547  // make sure testnet daemon is running
548  std::cout << "connecting to daemon: " << TESTNET_DAEMON_ADDRESS << std::endl;
550  ASSERT_TRUE(wallet1->refresh());
551  ASSERT_TRUE(wmgr->closeWallet(wallet1));
552 }
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [21/36]

TEST_F ( WalletTest1  ,
WalletConvertsToString   
)

Definition at line 554 of file main.cpp.

555 {
558 
562 
563 }
::std::string string
Definition: gtest-port.h:1097
const uint64_t AMOUNT_5ETN
Definition: main.cpp:86
static std::string displayAmount(uint64_t amount)
Definition: wallet.cpp:299
static uint64_t amountFromDouble(double amount)
Definition: wallet.cpp:311
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
static uint64_t amountFromString(const std::string &amount)
Definition: wallet.cpp:304
const uint64_t AMOUNT_10ETN
Definition: main.cpp:85
const uint64_t AMOUNT_1ETN
Definition: main.cpp:87
Here is the call graph for this function:

◆ TEST_F() [22/36]

TEST_F ( WalletTest1  ,
WalletTransaction   
)

Definition at line 567 of file main.cpp.

569 {
571  // make sure testnet daemon is running
573  ASSERT_TRUE(wallet1->refresh());
574  uint64_t balance = wallet1->balance(0);
576 
578  const int MIXIN_COUNT = 4;
579 
580 
581  Electroneum::PendingTransaction * transaction = wallet1->createTransaction(recepient_address,
583  AMOUNT_10ETN,
584  MIXIN_COUNT,
586  0,
587  std::set<uint32_t>{});
589  wallet1->refresh();
590 
591  ASSERT_TRUE(wallet1->balance(0) == balance);
592  ASSERT_TRUE(transaction->amount() == AMOUNT_10ETN);
593  ASSERT_TRUE(transaction->commit());
594  ASSERT_FALSE(wallet1->balance(0) == balance);
595  ASSERT_TRUE(wmgr->closeWallet(wallet1));
596 }
virtual int status() const =0
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
::std::string string
Definition: gtest-port.h:1097
virtual bool commit(const std::string &filename="", bool overwrite=false)=0
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
static std::string get_wallet_address(const std::string &filename, const std::string &password)
Definition: main.cpp:131
virtual uint64_t amount() const =0
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={})=0
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
unsigned __int64 uint64_t
Definition: stdint.h:136
Transaction-like interface for sending etn.
Definition: wallet2_api.h:72
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const uint64_t AMOUNT_10ETN
Definition: main.cpp:85
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual uint64_t balance(uint32_t accountIndex=0, bool public_blockchain=false) const =0
const std::string PAYMENT_ID_EMPTY
Definition: main.cpp:89
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [23/36]

TEST_F ( WalletTest1  ,
WalletTransactionWithMixin   
)

Definition at line 600 of file main.cpp.

601 {
602 
603  std::vector<int> mixins;
604  // 2,3,4,5,6,7,8,9,10,15,20,25 can we do it like that?
605  mixins.push_back(2); mixins.push_back(3); mixins.push_back(4); mixins.push_back(5); mixins.push_back(6);
606  mixins.push_back(7); mixins.push_back(8); mixins.push_back(9); mixins.push_back(10); mixins.push_back(15);
607  mixins.push_back(20); mixins.push_back(25);
608 
609 
610  std::string payment_id = "";
611 
613 
614 
615  // make sure testnet daemon is running
617  ASSERT_TRUE(wallet1->refresh());
618  uint64_t balance = wallet1->balance(0);
620 
622  for (auto mixin : mixins) {
623  std::cerr << "Transaction mixin count: " << mixin << std::endl;
624 
625  Electroneum::PendingTransaction * transaction = wallet1->createTransaction(
626  recepient_address, payment_id, AMOUNT_5ETN, mixin, Electroneum::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
627 
628  std::cerr << "Transaction status: " << transaction->status() << std::endl;
629  std::cerr << "Transaction fee: " << Electroneum::Wallet::displayAmount(transaction->fee()) << std::endl;
630  std::cerr << "Transaction error: " << transaction->errorString() << std::endl;
632  wallet1->disposeTransaction(transaction);
633  }
634 
635  wallet1->refresh();
636 
637  ASSERT_TRUE(wallet1->balance(0) == balance);
638  ASSERT_TRUE(wmgr->closeWallet(wallet1));
639 }
virtual int status() const =0
virtual std::string errorString() const =0
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
virtual void disposeTransaction(PendingTransaction *t)=0
disposeTransaction - destroys transaction object
::std::string string
Definition: gtest-port.h:1097
const uint64_t AMOUNT_5ETN
Definition: main.cpp:86
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
virtual uint64_t fee() const =0
static std::string get_wallet_address(const std::string &filename, const std::string &password)
Definition: main.cpp:131
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={})=0
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
unsigned __int64 uint64_t
Definition: stdint.h:136
Transaction-like interface for sending etn.
Definition: wallet2_api.h:72
static std::string displayAmount(uint64_t amount)
Definition: wallet.cpp:299
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual uint64_t balance(uint32_t accountIndex=0, bool public_blockchain=false) const =0
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [24/36]

TEST_F ( WalletTest1  ,
WalletTransactionWithPriority   
)

Definition at line 641 of file main.cpp.

642 {
643 
644  std::string payment_id = "";
645 
647 
648  // make sure testnet daemon is running
650  ASSERT_TRUE(wallet1->refresh());
651  uint64_t balance = wallet1->balance(0);
653 
655  uint32_t mixin = 0;
656  uint64_t fee = 0;
657 
658  std::vector<Electroneum::PendingTransaction::Priority> priorities = {
662  };
663 
664  for (auto it = priorities.begin(); it != priorities.end(); ++it) {
665  std::cerr << "Transaction priority: " << *it << std::endl;
666 
667  Electroneum::PendingTransaction * transaction = wallet1->createTransaction(
668  recepient_address, payment_id, AMOUNT_5ETN, mixin, *it, 0, std::set<uint32_t>{});
669  std::cerr << "Transaction status: " << transaction->status() << std::endl;
670  std::cerr << "Transaction fee: " << Electroneum::Wallet::displayAmount(transaction->fee()) << std::endl;
671  std::cerr << "Transaction error: " << transaction->errorString() << std::endl;
672  ASSERT_TRUE(transaction->fee() > fee);
674  fee = transaction->fee();
675  wallet1->disposeTransaction(transaction);
676  }
677  wallet1->refresh();
678  ASSERT_TRUE(wallet1->balance(0) == balance);
679  ASSERT_TRUE(wmgr->closeWallet(wallet1));
680 }
virtual int status() const =0
virtual std::string errorString() const =0
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
virtual void disposeTransaction(PendingTransaction *t)=0
disposeTransaction - destroys transaction object
::std::string string
Definition: gtest-port.h:1097
const uint64_t AMOUNT_5ETN
Definition: main.cpp:86
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
virtual uint64_t fee() const =0
static std::string get_wallet_address(const std::string &filename, const std::string &password)
Definition: main.cpp:131
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={})=0
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
unsigned int uint32_t
Definition: stdint.h:126
unsigned __int64 uint64_t
Definition: stdint.h:136
Transaction-like interface for sending etn.
Definition: wallet2_api.h:72
static std::string displayAmount(uint64_t amount)
Definition: wallet.cpp:299
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual uint64_t balance(uint32_t accountIndex=0, bool public_blockchain=false) const =0
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [25/36]

TEST_F ( WalletTest1  ,
WalletHistory   
)

Definition at line 684 of file main.cpp.

685 {
687  // make sure testnet daemon is running
689  ASSERT_TRUE(wallet1->refresh());
690  Electroneum::TransactionHistory * history = wallet1->history();
691  history->refresh();
692  ASSERT_TRUE(history->count() > 0);
693 
694 
695  for (auto t: history->getAll()) {
696  ASSERT_TRUE(t != nullptr);
698  }
699 }
The TransactionHistory - interface for displaying transaction history.
Definition: wallet2_api.h:203
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
static void print_transaction(Electroneum::TransactionInfo *t)
Definition: main.cpp:117
virtual TransactionHistory * history()=0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [26/36]

TEST_F ( WalletTest1  ,
WalletTransactionAndHistory   
)

Definition at line 701 of file main.cpp.

702 {
703  return;
705  // make sure testnet daemon is running
706  ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
707  ASSERT_TRUE(wallet_src->refresh());
708  Electroneum::TransactionHistory * history = wallet_src->history();
709  history->refresh();
710  ASSERT_TRUE(history->count() > 0);
711  size_t count1 = history->count();
712 
713  std::cout << "**** Transactions before transfer (" << count1 << ")" << std::endl;
714  for (auto t: history->getAll()) {
715  ASSERT_TRUE(t != nullptr);
717  }
718 
720 
721 
722  Electroneum::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
724  AMOUNT_10ETN * 5, 1, Electroneum::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
725 
727  ASSERT_TRUE(tx->commit());
728  history = wallet_src->history();
729  history->refresh();
730  ASSERT_TRUE(count1 != history->count());
731 
732  std::cout << "**** Transactions after transfer (" << history->count() << ")" << std::endl;
733  for (auto t: history->getAll()) {
734  ASSERT_TRUE(t != nullptr);
736  }
737 }
The TransactionHistory - interface for displaying transaction history.
Definition: wallet2_api.h:203
virtual int status() const =0
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
::std::string string
Definition: gtest-port.h:1097
virtual bool commit(const std::string &filename="", bool overwrite=false)=0
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
static std::string get_wallet_address(const std::string &filename, const std::string &password)
Definition: main.cpp:131
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={})=0
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
static void print_transaction(Electroneum::TransactionInfo *t)
Definition: main.cpp:117
Transaction-like interface for sending etn.
Definition: wallet2_api.h:72
virtual TransactionHistory * history()=0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const uint64_t AMOUNT_10ETN
Definition: main.cpp:85
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
const std::string PAYMENT_ID_EMPTY
Definition: main.cpp:89
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [27/36]

TEST_F ( WalletTest1  ,
WalletTransactionWithPaymentId   
)

Definition at line 740 of file main.cpp.

741 {
742 
744  // make sure testnet daemon is running
745  ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
746  ASSERT_TRUE(wallet_src->refresh());
747  Electroneum::TransactionHistory * history = wallet_src->history();
748  history->refresh();
749  ASSERT_TRUE(history->count() > 0);
750  size_t count1 = history->count();
751 
752  std::cout << "**** Transactions before transfer (" << count1 << ")" << std::endl;
753  for (auto t: history->getAll()) {
754  ASSERT_TRUE(t != nullptr);
756  }
757 
759 
761  ASSERT_TRUE(payment_id.length() == 16);
762 
763 
764  Electroneum::PendingTransaction * tx = wallet_src->createTransaction(wallet4_addr,
765  payment_id,
767 
769  ASSERT_TRUE(tx->commit());
770  history = wallet_src->history();
771  history->refresh();
772  ASSERT_TRUE(count1 != history->count());
773 
774  bool payment_id_in_history = false;
775 
776  std::cout << "**** Transactions after transfer (" << history->count() << ")" << std::endl;
777  for (auto t: history->getAll()) {
778  ASSERT_TRUE(t != nullptr);
780  if (t->paymentId() == payment_id) {
781  payment_id_in_history = true;
782  }
783  }
784 
785  ASSERT_TRUE(payment_id_in_history);
786 }
The TransactionHistory - interface for displaying transaction history.
Definition: wallet2_api.h:203
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
::std::string string
Definition: gtest-port.h:1097
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
static std::string get_wallet_address(const std::string &filename, const std::string &password)
Definition: main.cpp:131
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={})=0
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
static void print_transaction(Electroneum::TransactionInfo *t)
Definition: main.cpp:117
static std::string genPaymentId()
Definition: wallet.cpp:318
Transaction-like interface for sending etn.
Definition: wallet2_api.h:72
virtual TransactionHistory * history()=0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
const uint64_t AMOUNT_1ETN
Definition: main.cpp:87
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [28/36]

TEST_F ( WalletTest2  ,
WalletCallBackRefreshedSync   
)

Definition at line 882 of file main.cpp.

883 {
884 
886  MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
887  ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
888  ASSERT_TRUE(wallet_src_listener->refresh_triggered);
889  ASSERT_TRUE(wallet_src->connected());
890  boost::chrono::seconds wait_for = boost::chrono::seconds(60*3);
891  boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
892  wallet_src_listener->cv_refresh.wait_for(lock, wait_for);
893  wmgr->closeWallet(wallet_src);
894 }
boost::condition_variable cv_refresh
Definition: main.cpp:799
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual ConnectionStatus connected() const =0
connected - checks if the wallet connected to the daemon
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
boost::mutex mutex
Definition: main.cpp:795
bool refresh_triggered
Definition: main.cpp:805
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [29/36]

TEST_F ( WalletTest2  ,
WalletCallBackRefreshedAsync   
)

Definition at line 899 of file main.cpp.

900 {
901 
903  MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
904 
905  boost::chrono::seconds wait_for = boost::chrono::seconds(20);
906  boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
907  wallet_src->init(MAINNET_DAEMON_ADDRESS, 0);
908  wallet_src->startRefresh();
909  std::cerr << "TEST: waiting on refresh lock...\n";
910  wallet_src_listener->cv_refresh.wait_for(lock, wait_for);
911  std::cerr << "TEST: refresh lock acquired...\n";
912  ASSERT_TRUE(wallet_src_listener->refresh_triggered);
913  ASSERT_TRUE(wallet_src->connected());
914  std::cerr << "TEST: closing wallet...\n";
915  wmgr->closeWallet(wallet_src);
916 }
boost::condition_variable cv_refresh
Definition: main.cpp:799
std::string MAINNET_DAEMON_ADDRESS
Definition: main.cpp:92
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual ConnectionStatus connected() const =0
connected - checks if the wallet connected to the daemon
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
boost::mutex mutex
Definition: main.cpp:795
virtual void startRefresh()=0
StartRefresh - Start/resume refresh thread (refresh every 10 seconds)
bool refresh_triggered
Definition: main.cpp:805
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [30/36]

TEST_F ( WalletTest2  ,
WalletCallbackSent   
)

Definition at line 921 of file main.cpp.

922 {
923 
925  // make sure testnet daemon is running
926  ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
927  ASSERT_TRUE(wallet_src->refresh());
928  MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
929  uint64_t balance = wallet_src->balance(0);
930  std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
932 
933  uint64_t amount = AMOUNT_1ETN * 5;
934  std::cout << "** Sending " << Electroneum::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
935 
936 
937  Electroneum::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
939  amount, 1, Electroneum::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
940  std::cout << "** Committing transaction: " << Electroneum::Wallet::displayAmount(tx->amount())
941  << " with fee: " << Electroneum::Wallet::displayAmount(tx->fee());
942 
944  ASSERT_TRUE(tx->commit());
945 
946  boost::chrono::seconds wait_for = boost::chrono::seconds(60*3);
947  boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
948  std::cerr << "TEST: waiting on send lock...\n";
949  wallet_src_listener->cv_send.wait_for(lock, wait_for);
950  std::cerr << "TEST: send lock acquired...\n";
951  ASSERT_TRUE(wallet_src_listener->send_triggered);
952  ASSERT_TRUE(wallet_src_listener->update_triggered);
953  std::cout << "** Balance: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
954  ASSERT_TRUE(wallet_src->balance(0) < balance);
955  wmgr->closeWallet(wallet_src);
956  wmgr->closeWallet(wallet_dst);
957 }
virtual int status() const =0
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
virtual bool commit(const std::string &filename="", bool overwrite=false)=0
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
virtual uint64_t fee() const =0
virtual uint64_t amount() const =0
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={})=0
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
unsigned __int64 uint64_t
Definition: stdint.h:136
Transaction-like interface for sending etn.
Definition: wallet2_api.h:72
static std::string displayAmount(uint64_t amount)
Definition: wallet.cpp:299
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual uint64_t balance(uint32_t accountIndex=0, bool public_blockchain=false) const =0
const uint64_t AMOUNT_1ETN
Definition: main.cpp:87
const std::string PAYMENT_ID_EMPTY
Definition: main.cpp:89
std::string mainAddress() const
Definition: wallet2_api.h:464
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [31/36]

TEST_F ( WalletTest2  ,
WalletCallbackReceived   
)

Definition at line 960 of file main.cpp.

961 {
962 
964  // make sure testnet daemon is running
965  ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
966  ASSERT_TRUE(wallet_src->refresh());
967  std::cout << "** Balance src1: " << wallet_src->displayAmount(wallet_src->balance(0)) << std::endl;
968 
970  ASSERT_TRUE(wallet_dst->init(TESTNET_DAEMON_ADDRESS, 0));
971  ASSERT_TRUE(wallet_dst->refresh());
972  uint64_t balance = wallet_dst->balance(0);
973  std::cout << "** Balance dst1: " << wallet_dst->displayAmount(wallet_dst->balance(0)) << std::endl;
974  std::unique_ptr<MyWalletListener> wallet_dst_listener (new MyWalletListener(wallet_dst));
975 
976  uint64_t amount = AMOUNT_1ETN * 5;
977  std::cout << "** Sending " << Electroneum::Wallet::displayAmount(amount) << " to " << wallet_dst->mainAddress();
978  Electroneum::PendingTransaction * tx = wallet_src->createTransaction(wallet_dst->mainAddress(),
980  amount, 1, Electroneum::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
981 
982  std::cout << "** Committing transaction: " << Electroneum::Wallet::displayAmount(tx->amount())
983  << " with fee: " << Electroneum::Wallet::displayAmount(tx->fee());
984 
986  ASSERT_TRUE(tx->commit());
987 
988  boost::chrono::seconds wait_for = boost::chrono::seconds(60*4);
989  boost::unique_lock<boost::mutex> lock (wallet_dst_listener->mutex);
990  std::cerr << "TEST: waiting on receive lock...\n";
991  wallet_dst_listener->cv_receive.wait_for(lock, wait_for);
992  std::cerr << "TEST: receive lock acquired...\n";
993  ASSERT_TRUE(wallet_dst_listener->receive_triggered);
994  ASSERT_TRUE(wallet_dst_listener->update_triggered);
995 
996  std::cout << "** Balance src2: " << wallet_dst->displayAmount(wallet_src->balance(0)) << std::endl;
997  std::cout << "** Balance dst2: " << wallet_dst->displayAmount(wallet_dst->balance(0)) << std::endl;
998 
999  ASSERT_TRUE(wallet_dst->balance(0) > balance);
1000 
1001  wmgr->closeWallet(wallet_src);
1002  wmgr->closeWallet(wallet_dst);
1003 }
virtual int status() const =0
std::string CURRENT_DST_WALLET
Definition: main.cpp:83
virtual bool commit(const std::string &filename="", bool overwrite=false)=0
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
virtual uint64_t fee() const =0
virtual uint64_t amount() const =0
std::string CURRENT_SRC_WALLET
Definition: main.cpp:82
virtual PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={})=0
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
unsigned __int64 uint64_t
Definition: stdint.h:136
Transaction-like interface for sending etn.
Definition: wallet2_api.h:72
static std::string displayAmount(uint64_t amount)
Definition: wallet.cpp:299
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual uint64_t balance(uint32_t accountIndex=0, bool public_blockchain=false) const =0
const uint64_t AMOUNT_1ETN
Definition: main.cpp:87
const std::string PAYMENT_ID_EMPTY
Definition: main.cpp:89
std::string mainAddress() const
Definition: wallet2_api.h:464
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [32/36]

TEST_F ( WalletTest2  ,
WalletCallbackNewBlock   
)

Definition at line 1007 of file main.cpp.

1008 {
1009 
1011  // make sure testnet daemon is running
1012  ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
1013  ASSERT_TRUE(wallet_src->refresh());
1014  uint64_t bc1 = wallet_src->blockChainHeight();
1015  std::cout << "** Block height: " << bc1 << std::endl;
1016 
1017 
1018  std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet_src));
1019 
1020  // wait max 4 min for new block
1021  boost::chrono::seconds wait_for = boost::chrono::seconds(60*4);
1022  boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
1023  std::cerr << "TEST: waiting on newblock lock...\n";
1024  wallet_listener->cv_newblock.wait_for(lock, wait_for);
1025  std::cerr << "TEST: newblock lock acquired...\n";
1026  ASSERT_TRUE(wallet_listener->newblock_triggered);
1027  uint64_t bc2 = wallet_src->blockChainHeight();
1028  std::cout << "** Block height: " << bc2 << std::endl;
1029  ASSERT_TRUE(bc2 > bc1);
1030  wmgr->closeWallet(wallet_src);
1031 
1032 }
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
std::string TESTNET_DAEMON_ADDRESS
Definition: main.cpp:91
virtual uint64_t blockChainHeight() const =0
blockChainHeight - returns current blockchain height
unsigned __int64 uint64_t
Definition: stdint.h:136
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
const char * TESTNET_WALLET_PASS
Definition: main.cpp:80
virtual bool refresh()=0
refresh - refreshes the wallet, updating transactions from daemon
std::string TESTNET_WALLET5_NAME
Definition: main.cpp:77
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [33/36]

TEST_F ( WalletManagerMainnetTest  ,
CreateOpenAndRefreshWalletMainNetSync   
)

Definition at line 1034 of file main.cpp.

1035 {
1036 
1038  std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
1039  wallet->init(MAINNET_DAEMON_ADDRESS, 0);
1040  std::cerr << "TEST: waiting on refresh lock...\n";
1041  //wallet_listener->cv_refresh.wait_for(lock, wait_for);
1042  std::cerr << "TEST: refresh lock acquired...\n";
1043  ASSERT_TRUE(wallet_listener->refresh_triggered);
1044  ASSERT_TRUE(wallet->connected());
1045  ASSERT_TRUE(wallet->blockChainHeight() == wallet->daemonBlockChainHeight());
1046  std::cerr << "TEST: closing wallet...\n";
1047  wmgr->closeWallet(wallet);
1048 }
std::string MAINNET_DAEMON_ADDRESS
Definition: main.cpp:92
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
virtual uint64_t blockChainHeight() const =0
blockChainHeight - returns current blockchain height
const char * WALLET_LANG
Definition: main.cpp:70
virtual ConnectionStatus connected() const =0
connected - checks if the wallet connected to the daemon
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
virtual uint64_t daemonBlockChainHeight() const =0
daemonBlockChainHeight - returns daemon blockchain height
const char * WALLET_NAME_MAINNET
Definition: main.cpp:64
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [34/36]

TEST_F ( WalletManagerMainnetTest  ,
CreateAndRefreshWalletMainNetAsync   
)

Definition at line 1051 of file main.cpp.

1052 {
1053  // supposing 120 seconds should be enough for fast refresh
1054  int SECONDS_TO_REFRESH = 120;
1055 
1057  std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
1058 
1059  boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
1060  boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
1061  wallet->init(MAINNET_DAEMON_ADDRESS, 0);
1062  wallet->startRefresh();
1063  std::cerr << "TEST: waiting on refresh lock...\n";
1064  wallet_listener->cv_refresh.wait_for(lock, wait_for);
1065  std::cerr << "TEST: refresh lock acquired...\n";
1067  ASSERT_TRUE(wallet_listener->refresh_triggered);
1068  ASSERT_TRUE(wallet->connected());
1069  ASSERT_TRUE(wallet->blockChainHeight() == wallet->daemonBlockChainHeight());
1070  std::cerr << "TEST: closing wallet...\n";
1071  wmgr->closeWallet(wallet);
1072 }
std::string MAINNET_DAEMON_ADDRESS
Definition: main.cpp:92
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
virtual uint64_t blockChainHeight() const =0
blockChainHeight - returns current blockchain height
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
const char * WALLET_LANG
Definition: main.cpp:70
virtual ConnectionStatus connected() const =0
connected - checks if the wallet connected to the daemon
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
virtual uint64_t daemonBlockChainHeight() const =0
daemonBlockChainHeight - returns daemon blockchain height
const char * WALLET_NAME_MAINNET
Definition: main.cpp:64
virtual void startRefresh()=0
StartRefresh - Start/resume refresh thread (refresh every 10 seconds)
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [35/36]

TEST_F ( WalletManagerMainnetTest  ,
OpenAndRefreshWalletMainNetAsync   
)

Definition at line 1074 of file main.cpp.

1075 {
1076 
1077  // supposing 120 seconds should be enough for fast refresh
1078  int SECONDS_TO_REFRESH = 120;
1080  wmgr->closeWallet(wallet);
1081  wallet = wmgr->openWallet(WALLET_NAME_MAINNET, "", Electroneum::NetworkType::MAINNET);
1082 
1083  std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
1084 
1085  boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
1086  boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
1087  wallet->init(MAINNET_DAEMON_ADDRESS, 0);
1088  wallet->startRefresh();
1089  std::cerr << "TEST: waiting on refresh lock...\n";
1090  wallet_listener->cv_refresh.wait_for(lock, wait_for);
1091  std::cerr << "TEST: refresh lock acquired...\n";
1093  ASSERT_TRUE(wallet_listener->refresh_triggered);
1094  ASSERT_TRUE(wallet->connected());
1095  ASSERT_TRUE(wallet->blockChainHeight() == wallet->daemonBlockChainHeight());
1096  std::cerr << "TEST: closing wallet...\n";
1097  wmgr->closeWallet(wallet);
1098 
1099 }
std::string MAINNET_DAEMON_ADDRESS
Definition: main.cpp:92
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
virtual uint64_t blockChainHeight() const =0
blockChainHeight - returns current blockchain height
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
const char * WALLET_LANG
Definition: main.cpp:70
virtual ConnectionStatus connected() const =0
connected - checks if the wallet connected to the daemon
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
virtual uint64_t daemonBlockChainHeight() const =0
daemonBlockChainHeight - returns daemon blockchain height
const char * WALLET_NAME_MAINNET
Definition: main.cpp:64
virtual void startRefresh()=0
StartRefresh - Start/resume refresh thread (refresh every 10 seconds)
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function:

◆ TEST_F() [36/36]

TEST_F ( WalletManagerMainnetTest  ,
RecoverAndRefreshWalletMainNetAsync   
)

Definition at line 1101 of file main.cpp.

1102 {
1103 
1104  // supposing 120 seconds should be enough for fast refresh
1105  int SECONDS_TO_REFRESH = 120;
1107  std::string seed = wallet->seed();
1108  std::string address = wallet->mainAddress();
1109  wmgr->closeWallet(wallet);
1110 
1111  // deleting wallet files
1113  // ..and recovering wallet from seed
1114 
1115  wallet = wmgr->recoveryWallet(WALLET_NAME_MAINNET, seed, Electroneum::NetworkType::MAINNET);
1117  ASSERT_TRUE(wallet->mainAddress() == address);
1118  std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
1119  boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
1120  boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
1121  wallet->init(MAINNET_DAEMON_ADDRESS, 0);
1122  wallet->startRefresh();
1123  std::cerr << "TEST: waiting on refresh lock...\n";
1124 
1125  // here we wait for 120 seconds and test if wallet doesn't syncrnonize blockchain completely,
1126  // as it needs much more than 120 seconds for mainnet
1127 
1128  wallet_listener->cv_refresh.wait_for(lock, wait_for);
1130  ASSERT_FALSE(wallet_listener->refresh_triggered);
1131  ASSERT_TRUE(wallet->connected());
1132  ASSERT_FALSE(wallet->blockChainHeight() == wallet->daemonBlockChainHeight());
1133  std::cerr << "TEST: closing wallet...\n";
1134  wmgr->closeWallet(wallet);
1135  std::cerr << "TEST: wallet closed\n";
1136 
1137 }
::std::string string
Definition: gtest-port.h:1097
std::string MAINNET_DAEMON_ADDRESS
Definition: main.cpp:92
virtual bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false)=0
init - initializes wallet with daemon connection params. if daemon_address is local address...
virtual uint64_t blockChainHeight() const =0
blockChainHeight - returns current blockchain height
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
virtual int status() const =0
returns wallet status (Status_Ok | Status_Error)
const char * WALLET_LANG
Definition: main.cpp:70
virtual ConnectionStatus connected() const =0
connected - checks if the wallet connected to the daemon
virtual std::string seed() const =0
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
static void deleteWallet(const std::string &walletname)
Definition: main.cpp:103
const char * address
Definition: multisig.cpp:37
virtual uint64_t daemonBlockChainHeight() const =0
daemonBlockChainHeight - returns daemon blockchain height
const char * WALLET_NAME_MAINNET
Definition: main.cpp:64
std::string mainAddress() const
Definition: wallet2_api.h:464
virtual void startRefresh()=0
StartRefresh - Start/resume refresh thread (refresh every 10 seconds)
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.
Definition: wallet2_api.h:430
Here is the call graph for this function: