Monero
Loading...
Searching...
No Matches
trezor_tests.cpp File Reference
#include "include_base_utils.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_basic/account.h"
#include "cryptonote_core/cryptonote_tx_utils.h"
#include "misc_language.h"
#include "string_tools.h"
#include <boost/regex.hpp>
#include <common/apply_permutation.h>
#include <iomanip>
#include "common/util.h"
#include "common/command_line.h"
#include "trezor_tests.h"
#include "tools.h"
#include "device/device_cold.hpp"
#include "device_trezor/device_trezor.hpp"
Include dependency graph for trezor_tests.cpp:

Macros

#define HW_TREZOR_NAME   "Trezor"
#define TREZOR_ACCOUNT_ORDERING   &m_miner_account, &m_alice_account, &m_bob_account, &m_eve_account
#define TREZOR_COMMON_TEST_CASE(genclass, CORE, BASE)
#define TREZOR_SETUP_CHAIN(NAME)
#define TREZOR_TEST_PREFIX()
#define TREZOR_TEST_SUFFIX()
#define TREZOR_SKIP_IF_VERSION_LEQ(x)
#define TREZOR_TEST_PAYMENT_ID   "\xde\xad\xc0\xde\xde\xad\xc0\xde"

Functions

static device_trezor_testensure_trezor_test_device ()
static void rollback_chain (cryptonote::core *core, const cryptonote::block &head)
static void setup_chain (cryptonote::core *core, gen_trezor_base &trezor_base, std::string chain_path, bool fix_chain, const po::variables_map &vm_core)
static long get_env_long (const char *flag_name, boost::optional< long > def=boost::none)
int main (int argc, char *argv[])
static bool unserialize_chain_from_file (std::vector< test_event_entry > &events, gen_trezor_base &test_base, const std::string &file_path)
static bool serialize_chain_to_file (std::vector< test_event_entry > &events, gen_trezor_base &test_base, const std::string &file_path)
template<class t_test_class>
static bool init_core_replay_events (std::vector< test_event_entry > &events, cryptonote::core *core, const po::variables_map &vm_core)
static void add_hforks (std::vector< test_event_entry > &events, const v_hardforks_t &hard_forks)
static void add_top_hfork (std::vector< test_event_entry > &events, const v_hardforks_t &hard_forks)
static crypto::public_key get_tx_pub_key_from_received_outs (const tools::wallet2::transfer_details &td)
static void setup_shim (hw::wallet_shim *shim)
bool get_short_payment_id (crypto::hash8 &payment_id8, const tools::wallet2::pending_tx &ptx, hw::device &hwdev)
static tools::wallet2::tx_construction_data get_construction_data_with_decrypted_short_payment_id (const tools::wallet2::pending_tx &ptx, hw::device &hwdev)
static std::string get_payment_id (const std::vector< uint8_t > &tx_extra)
static crypto::hash8 to_short_payment_id (const std::string &payment_id)
static crypto::hash to_long_payment_id (const std::string &payment_id)
static std::vector< uint8_tbuild_payment_id_extra (const std::string &payment_id)
static cryptonote::address_parse_info init_addr_parse_info (cryptonote::account_public_address &addr, bool is_sub=false, boost::optional< crypto::hash8 > payment_id=boost::none)
static void expand_tsx (cryptonote::transaction &tx)
static std::vector< tools::wallet2 * > vct_wallets (tools::wallet2 *w1=nullptr, tools::wallet2 *w2=nullptr, tools::wallet2 *w3=nullptr, tools::wallet2 *w4=nullptr, tools::wallet2 *w5=nullptr)
static uint64_t get_available_funds (tools::wallet2 *wallet, uint32_t account=0)

Variables

static device_trezor_testtrezor_device = nullptr

Macro Definition Documentation

◆ HW_TREZOR_NAME

#define HW_TREZOR_NAME   "Trezor"

◆ TREZOR_ACCOUNT_ORDERING

#define TREZOR_ACCOUNT_ORDERING   &m_miner_account, &m_alice_account, &m_bob_account, &m_eve_account

◆ TREZOR_COMMON_TEST_CASE

#define TREZOR_COMMON_TEST_CASE ( genclass,
CORE,
BASE )
Value:
do { \
rollback_chain(CORE, BASE.head_block()); \
{ \
genclass ctest; \
BASE.fork(ctest); \
GENERATE_AND_PLAY_INSTANCE(genclass, ctest, *(CORE)); \
} \
} while(0)

◆ TREZOR_SETUP_CHAIN

#define TREZOR_SETUP_CHAIN ( NAME)
Value:
do { \
++tests_count; \
try { \
setup_chain(core, trezor_base, chain_path, fix_chain, vm_core); \
} catch (const std::exception& ex) { \
MERROR("Chain setup failed for " << NAME); \
throw; \
} \
} while(0)
handles core cryptonote functionality
Definition cryptonote_core.h:87
#define NAME(s)
Definition pointertest.cpp:444

◆ TREZOR_SKIP_IF_VERSION_LEQ

#define TREZOR_SKIP_IF_VERSION_LEQ ( x)
Value:
if (m_trezor->get_version() <= x) { MDEBUG("Test skipped"); return true; }

◆ TREZOR_TEST_PAYMENT_ID

#define TREZOR_TEST_PAYMENT_ID   "\xde\xad\xc0\xde\xde\xad\xc0\xde"

◆ TREZOR_TEST_PREFIX

#define TREZOR_TEST_PREFIX ( )
Value:
test_generator generator(m_generator); \
test_setup(events); \
tsx_builder t_builder_o(this); \
tsx_builder * t_builder = &t_builder_o
Definition chaingen.h:183
Definition trezor_tests.h:153

◆ TREZOR_TEST_SUFFIX

#define TREZOR_TEST_SUFFIX ( )
Value:
auto _dsts = t_builder->build(); \
auto _dsts_info = t_builder->dest_info(); \
test_trezor_tx(events, _dsts, _dsts_info, generator, vct_wallets(m_wl_alice.get(), m_wl_bob.get(), m_wl_eve.get())); \
return true
static std::vector< tools::wallet2 * > vct_wallets(tools::wallet2 *w1=nullptr, tools::wallet2 *w2=nullptr, tools::wallet2 *w3=nullptr, tools::wallet2 *w4=nullptr, tools::wallet2 *w5=nullptr)
Definition trezor_tests.cpp:581

Function Documentation

◆ add_hforks()

void add_hforks ( std::vector< test_event_entry > & events,
const v_hardforks_t & hard_forks )
static

◆ add_top_hfork()

void add_top_hfork ( std::vector< test_event_entry > & events,
const v_hardforks_t & hard_forks )
static

◆ build_payment_id_extra()

std::vector< uint8_t > build_payment_id_extra ( const std::string & payment_id)
static

◆ ensure_trezor_test_device()

device_trezor_test * ensure_trezor_test_device ( )
static

◆ expand_tsx()

void expand_tsx ( cryptonote::transaction & tx)
static

◆ get_available_funds()

uint64_t get_available_funds ( tools::wallet2 * wallet,
uint32_t account = 0 )
static

◆ get_construction_data_with_decrypted_short_payment_id()

tools::wallet2::tx_construction_data get_construction_data_with_decrypted_short_payment_id ( const tools::wallet2::pending_tx & ptx,
hw::device & hwdev )
static

◆ get_env_long()

long get_env_long ( const char * flag_name,
boost::optional< long > def = boost::none )
static

◆ get_payment_id()

std::string get_payment_id ( const std::vector< uint8_t > & tx_extra)
static

◆ get_short_payment_id()

bool get_short_payment_id ( crypto::hash8 & payment_id8,
const tools::wallet2::pending_tx & ptx,
hw::device & hwdev )

◆ get_tx_pub_key_from_received_outs()

crypto::public_key get_tx_pub_key_from_received_outs ( const tools::wallet2::transfer_details & td)
static

◆ init_addr_parse_info()

cryptonote::address_parse_info init_addr_parse_info ( cryptonote::account_public_address & addr,
bool is_sub = false,
boost::optional< crypto::hash8 > payment_id = boost::none )
static

◆ init_core_replay_events()

template<class t_test_class>
bool init_core_replay_events ( std::vector< test_event_entry > & events,
cryptonote::core * core,
const po::variables_map & vm_core )
static

◆ main()

int main ( int argc,
char * argv[] )

◆ rollback_chain()

void rollback_chain ( cryptonote::core * core,
const cryptonote::block & head )
static

◆ serialize_chain_to_file()

bool serialize_chain_to_file ( std::vector< test_event_entry > & events,
gen_trezor_base & test_base,
const std::string & file_path )
static

◆ setup_chain()

void setup_chain ( cryptonote::core * core,
gen_trezor_base & trezor_base,
std::string chain_path,
bool fix_chain,
const po::variables_map & vm_core )
static

◆ setup_shim()

void setup_shim ( hw::wallet_shim * shim)
static

◆ to_long_payment_id()

crypto::hash to_long_payment_id ( const std::string & payment_id)
static

◆ to_short_payment_id()

crypto::hash8 to_short_payment_id ( const std::string & payment_id)
static

◆ unserialize_chain_from_file()

bool unserialize_chain_from_file ( std::vector< test_event_entry > & events,
gen_trezor_base & test_base,
const std::string & file_path )
static

◆ vct_wallets()

std::vector< tools::wallet2 * > vct_wallets ( tools::wallet2 * w1 = nullptr,
tools::wallet2 * w2 = nullptr,
tools::wallet2 * w3 = nullptr,
tools::wallet2 * w4 = nullptr,
tools::wallet2 * w5 = nullptr )
static

Variable Documentation

◆ trezor_device

device_trezor_test* trezor_device = nullptr
static