Electroneum
Loading...
Searching...
No Matches
wallet_api_tests Class Reference

#include <trezor_tests.h>

Inheritance diagram for wallet_api_tests:
Collaboration diagram for wallet_api_tests:

Public Member Functions

virtual ~wallet_api_tests ()
void init ()
bool generate (std::vector< test_event_entry > &events) override
Public Member Functions inherited from gen_trezor_base
 gen_trezor_base ()
 gen_trezor_base (const gen_trezor_base &other)
virtual ~gen_trezor_base ()
virtual void setup_args (const std::string &trezor_path, bool heavy_tests=false)
virtual void load (std::vector< test_event_entry > &events)
virtual void fix_hf (std::vector< test_event_entry > &events)
virtual void update_trackers (std::vector< test_event_entry > &events)
virtual void fork (gen_trezor_base &other)
virtual void clear ()
virtual void add_shared_events (std::vector< test_event_entry > &events)
virtual void test_setup (std::vector< test_event_entry > &events)
virtual void add_transactions_to_events (std::vector< test_event_entry > &events, test_generator &generator, const std::vector< cryptonote::transaction > &txs)
virtual void test_trezor_tx (std::vector< test_event_entry > &events, std::vector< tools::wallet2::pending_tx > &ptxs, std::vector< cryptonote::address_parse_info > &dsts_info, test_generator &generator, std::vector< tools::wallet2 * > wallets, bool is_sweep=false)
virtual void test_get_tx (std::vector< test_event_entry > &events, std::vector< tools::wallet2 * > wallets, const std::vector< tools::wallet2::pending_tx > &ptxs, const std::vector< std::string > &aux_tx_info)
virtual void mine_and_test (std::vector< test_event_entry > &events)
virtual void rewind_blocks (std::vector< test_event_entry > &events, size_t rewind_n, uint8_t hf)
virtual void set_hard_fork (uint8_t hf)
crypto::hash head_hash () const
cryptonote::block head_block () const
bool heavy_tests () const
void rct_config (rct::RCTConfig rct_config)
uint8_t cur_hf () const
cryptonote::network_type nettype () const
std::shared_ptr< mock_daemondaemon () const
void daemon (std::shared_ptr< mock_daemon > daemon)
Public Member Functions inherited from test_chain_unit_base
void register_callback (const std::string &cb_name, verify_callback cb)
bool verify (const std::string &cb_name, cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
bool check_tx_verification_context (const cryptonote::tx_verification_context &tvc, bool, size_t, const cryptonote::transaction &)
bool check_tx_verification_context_array (const std::vector< cryptonote::tx_verification_context > &tvcs, size_t, size_t, const std::vector< cryptonote::transaction > &)

Protected Attributes

boost::filesystem::path m_wallet_dir
Protected Attributes inherited from gen_trezor_base
test_generator m_generator
block_tracker m_bt
cryptonote::network_type m_network_type
std::shared_ptr< mock_daemonm_daemon
uint8_t m_top_hard_fork
v_hardforks_t m_hard_forks
cryptonote::block m_head
std::vector< test_event_entrym_events
std::string m_trezor_path
bool m_heavy_tests
bool m_test_get_tx_key
rct::RCTConfig m_rct_config
bool m_live_refresh_enabled
cryptonote::account_base m_miner_account
cryptonote::account_base m_bob_account
cryptonote::account_base m_alice_account
cryptonote::account_base m_eve_account
hw::trezor::device_trezor * m_trezor
std::unique_ptr< tools::wallet2m_wl_alice
std::unique_ptr< tools::wallet2m_wl_bob
std::unique_ptr< tools::wallet2m_wl_eve

Additional Inherited Members

Public Types inherited from test_chain_unit_base
typedef boost::function< bool(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)> verify_callback
typedef std::map< std::string, verify_callbackcallbacks_map
Static Public Attributes inherited from gen_trezor_base
static const uint64_t m_ts_start = 1397862000
static const uint64_t m_wallet_ts = m_ts_start - 60*60*24*4
static const std::string m_device_name = "Trezor:udp"
static const std::string m_master_seed_str = "14821d0bc5659b24cafbc889dc4fc60785ee08b65d71c525f81eeaba4f3a570f"
static const std::string m_device_seed = "permit universe parent weapon amused modify essay borrow tobacco budget walnut lunch consider gallery ride amazing frog forget treat market chapter velvet useless topple"
static const std::string m_alice_spend_private = m_master_seed_str
static const std::string m_alice_view_private = "a6ccd4ac344a295d1387f8d18c81bdd394f1845de84188e204514ef9370fd403"
Protected Member Functions inherited from gen_trezor_base
virtual void setup_trezor ()
virtual void init_fields ()
virtual void update_client_settings ()
virtual bool verify_tx_key (const ::crypto::secret_key &tx_priv, const ::crypto::public_key &tx_pub, const subaddresses_t &subs)
template<class Archive>
void serialize (Archive &ar, const unsigned int)

Detailed Description

Definition at line 322 of file trezor_tests.h.

Constructor & Destructor Documentation

◆ ~wallet_api_tests()

wallet_api_tests::~wallet_api_tests ( )
virtual

Definition at line 1837 of file trezor_tests.cpp.

1838{
1839 try
1840 {
1841 if (!m_wallet_dir.empty() && boost::filesystem::exists(m_wallet_dir))
1842 {
1843 boost::filesystem::remove_all(m_wallet_dir);
1844 }
1845 }
1846 catch(...)
1847 {
1848 MERROR("Could not remove wallet directory");
1849 }
1850}
boost::filesystem::path m_wallet_dir
#define MERROR(x)
Definition misc_log_ex.h:73

Member Function Documentation

◆ generate()

bool wallet_api_tests::generate ( std::vector< test_event_entry > & events)
overridevirtual

Reimplemented from gen_trezor_base.

Definition at line 1852 of file trezor_tests.cpp.

1853{
1854 init();
1855 test_setup(events);
1856 const std::string wallet_path = (m_wallet_dir / "wallet").string();
1857 const auto api_net_type = m_network_type == TESTNET ? Electroneum::TESTNET : Electroneum::MAINNET;
1858
1859 Electroneum::WalletManager *wmgr = Electroneum::WalletManagerFactory::getWalletManager();
1860 std::unique_ptr<Electroneum::Wallet> w{wmgr->createWalletFromDevice(wallet_path, "", api_net_type, m_trezor_path, 1)};
1861 CHECK_AND_ASSERT_THROW_MES(w->init(daemon()->rpc_addr(), 0), "Wallet init fail");
1862 CHECK_AND_ASSERT_THROW_MES(w->refresh(), "Refresh fail");
1863 uint64_t balance = w->balance(0);
1864 MDEBUG("Balance: " << balance);
1866
1867 auto addr = get_address(m_eve_account);
1868 auto recepient_address = cryptonote::get_account_address_as_str(m_network_type, false, addr);
1869 Electroneum::PendingTransaction * transaction = w->createTransaction(recepient_address,
1870 "",
1871 MK_COINS(10),
1874 0,
1875 std::set<uint32_t>{});
1877 w->refresh();
1878
1879 CHECK_AND_ASSERT_THROW_MES(w->balance(0) == balance, "Err");
1880 CHECK_AND_ASSERT_THROW_MES(transaction->amount() == MK_COINS(10), "Err");
1881 CHECK_AND_ASSERT_THROW_MES(transaction->commit(), "Err");
1882 CHECK_AND_ASSERT_THROW_MES(w->balance(0) != balance, "Err");
1883 CHECK_AND_ASSERT_THROW_MES(wmgr->closeWallet(w.get()), "Err");
1884 (void)w.release();
1885
1886 mine_and_test(events);
1887 return true;
1888}
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition chaingen.cpp:665
#define MK_COINS(amount)
Definition chaingen.h:1060
std::shared_ptr< mock_daemon > daemon() const
std::string m_trezor_path
cryptonote::network_type m_network_type
virtual void mine_and_test(std::vector< test_event_entry > &events)
cryptonote::account_base m_eve_account
virtual void test_setup(std::vector< test_event_entry > &events)
#define MDEBUG(x)
Definition misc_log_ex.h:76
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
unsigned __int64 uint64_t
Definition stdint.h:136
virtual int status() const =0
virtual uint64_t amount() const =0
virtual bool commit(const std::string &filename="", bool overwrite=false)=0
static WalletManager * getWalletManager()
virtual Wallet * createWalletFromDevice(const std::string &path, const std::string &password, NetworkType nettype, const std::string &deviceName, uint64_t restoreHeight=0, const std::string &subaddressLookahead="", uint64_t kdf_rounds=1, WalletListener *listener=nullptr)=0
creates wallet using hardware device.
virtual bool closeWallet(Wallet *wallet, bool store=true)=0
Closes wallet. In case operation succeeded, wallet object deleted. in case operation failed,...
#define TREZOR_TEST_MIXIN
Here is the call graph for this function:

◆ init()

void wallet_api_tests::init ( )

Definition at line 1831 of file trezor_tests.cpp.

1832{
1833 m_wallet_dir = boost::filesystem::unique_path();
1834 boost::filesystem::create_directories(m_wallet_dir);
1835}
Here is the caller graph for this function:

Member Data Documentation

◆ m_wallet_dir

boost::filesystem::path wallet_api_tests::m_wallet_dir
protected

Definition at line 330 of file trezor_tests.h.


The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/trezor/trezor_tests.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/trezor/trezor_tests.cpp