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

#include <trezor_tests.h>

Inheritance diagram for gen_trezor_base:
Collaboration diagram for gen_trezor_base:

Public Member Functions

 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 bool generate (std::vector< test_event_entry > &events)
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 > &)

Static Public Attributes

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

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)

Protected Attributes

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

Friends

class tsx_builder
class boost::serialization::access

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

Detailed Description

Definition at line 46 of file trezor_tests.h.

Constructor & Destructor Documentation

◆ gen_trezor_base() [1/2]

gen_trezor_base::gen_trezor_base ( )

Definition at line 608 of file trezor_tests.cpp.

608 {
610 m_test_get_tx_key = true;
612}
cryptonote::network_type m_network_type
rct::RCTConfig m_rct_config
@ RangeProofPaddedBulletproof
Definition rctTypes.h:235
Here is the caller graph for this function:

◆ gen_trezor_base() [2/2]

gen_trezor_base::gen_trezor_base ( const gen_trezor_base & other)

Definition at line 614 of file trezor_tests.cpp.

614 :
620{
621
622}
cryptonote::account_base m_bob_account
block_tracker m_bt
uint8_t m_top_hard_fork
cryptonote::account_base m_alice_account
bool m_live_refresh_enabled
test_generator m_generator
hw::trezor::device_trezor * m_trezor
v_hardforks_t m_hard_forks
cryptonote::account_base m_miner_account
cryptonote::account_base m_eve_account
std::shared_ptr< mock_daemon > m_daemon
Here is the call graph for this function:

◆ ~gen_trezor_base()

virtual gen_trezor_base::~gen_trezor_base ( )
inlinevirtual

Definition at line 53 of file trezor_tests.h.

53{};

Member Function Documentation

◆ add_shared_events()

void gen_trezor_base::add_shared_events ( std::vector< test_event_entry > & events)
virtual

Definition at line 672 of file trezor_tests.cpp.

673{
674 events.reserve(m_events.size());
675 for(const test_event_entry & c : m_events){
676 events.push_back(c);
677 }
678}
boost::variant< cryptonote::block, cryptonote::transaction, std::vector< cryptonote::transaction >, cryptonote::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_replay_settings > test_event_entry
Definition chaingen.h:162
std::vector< test_event_entry > m_events
Here is the caller graph for this function:

◆ add_transactions_to_events()

void gen_trezor_base::add_transactions_to_events ( std::vector< test_event_entry > & events,
test_generator & generator,
const std::vector< cryptonote::transaction > & txs )
virtual

Definition at line 984 of file trezor_tests.cpp.

988{
989 // If current test requires higher hard-fork, move it up
990 const auto current_hf = m_hard_forks.back().first;
991 const uint8_t tx_hf = m_top_hard_fork;
992 CHECK_AND_ASSERT_THROW_MES(tx_hf <= current_hf, "Too late for HF change: " << (int)tx_hf << " current: " << (int)current_hf);
993 CHECK_AND_ASSERT_THROW_MES(m_rct_config.bp_version < 2 || tx_hf >= 10, "HF too low for BPv2: " << (int)tx_hf);
994
995 std::list<cryptonote::transaction> tx_list;
996 for(const auto & tx : txs)
997 {
998 events.push_back(tx);
999 tx_list.push_back(tx);
1000 }
1001
1002 MAKE_NEXT_BLOCK_TX_LIST_HF(events, blk_new, m_head, m_miner_account, tx_list, tx_hf);
1003 MDEBUG("New tsx: " << (num_blocks(events) - 1) << " at block: " << get_block_hash(blk_new));
1004
1005 m_head = blk_new;
1006}
uint64_t num_blocks(const std::vector< test_event_entry > &events)
#define MAKE_NEXT_BLOCK_TX_LIST_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF)
Definition chaingen.h:872
cryptonote::block m_head
#define MDEBUG(x)
Definition misc_log_ex.h:76
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
crypto::hash get_block_hash(uint64_t height)
unsigned char uint8_t
Definition stdint.h:124
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void gen_trezor_base::clear ( )
virtual

Definition at line 663 of file trezor_tests.cpp.

664{
665 m_generator = test_generator();
666 m_bt = block_tracker();
667 m_events.clear();
668 m_hard_forks.clear();
669 m_trezor = nullptr;
670}

◆ cur_hf()

uint8_t gen_trezor_base::cur_hf ( ) const
inline

Definition at line 95 of file trezor_tests.h.

95{ return m_hard_forks.size() > 0 ? m_hard_forks.back().first : 0; }

◆ daemon() [1/2]

std::shared_ptr< mock_daemon > gen_trezor_base::daemon ( ) const
inline

Definition at line 97 of file trezor_tests.h.

97{ return m_daemon; }
Here is the caller graph for this function:

◆ daemon() [2/2]

void gen_trezor_base::daemon ( std::shared_ptr< mock_daemon > daemon)
inline

Definition at line 98 of file trezor_tests.h.

98{ m_daemon = std::move(daemon); }
std::shared_ptr< mock_daemon > daemon() const
Here is the call graph for this function:

◆ fix_hf()

void gen_trezor_base::fix_hf ( std::vector< test_event_entry > & events)
virtual

Definition at line 929 of file trezor_tests.cpp.

930{
931 // If current test requires higher hard-fork, move it up
932 const auto current_hf = m_hard_forks.back().first;
933
934 if (current_hf > m_top_hard_fork)
935 {
936 throw std::runtime_error("Generated chain hardfork is higher than desired maximum");
937 }
938
939 if (m_rct_config.bp_version == 2 && m_top_hard_fork < 10)
940 {
941 throw std::runtime_error("Desired maximum is too low for BPv2");
942 }
943
944 if (current_hf < m_top_hard_fork)
945 {
946 auto hardfork_height = num_blocks(events);
947 ADD_HARDFORK(m_hard_forks, m_top_hard_fork, hardfork_height);
948 add_top_hfork(events, m_hard_forks);
949 MDEBUG("Hardfork added at height: " << hardfork_height << ", from " << (int)current_hf << " to " << (int)m_top_hard_fork);
950
951 if (current_hf < 10)
952 { // buffer blocks, add 10 to apply v10 rules
953 rewind_blocks(events, 10, m_top_hard_fork);
954 }
955 }
956}
#define ADD_HARDFORK(HARDFORKS, FORK, HEIGHT)
Definition chaingen.h:799
virtual void rewind_blocks(std::vector< test_event_entry > &events, size_t rewind_n, uint8_t hf)
Here is the call graph for this function:

◆ fork()

void gen_trezor_base::fork ( gen_trezor_base & other)
virtual

Definition at line 640 of file trezor_tests.cpp.

Here is the call graph for this function:

◆ generate()

bool gen_trezor_base::generate ( std::vector< test_event_entry > & events)
virtual

Reimplemented in gen_trezor_1utxo, gen_trezor_1utxo_paymentid_long, gen_trezor_1utxo_paymentid_short, gen_trezor_1utxo_paymentid_short_integrated, gen_trezor_2utxo_sub_acc_to_1norm_2sub, gen_trezor_4utxo, gen_trezor_4utxo_acc1, gen_trezor_4utxo_to_1norm_2sub, gen_trezor_4utxo_to_2sub, gen_trezor_4utxo_to_7outs, gen_trezor_4utxo_to_sub, gen_trezor_ki_sync, gen_trezor_ki_sync_with_refresh, gen_trezor_ki_sync_without_refresh, gen_trezor_live_refresh, gen_trezor_many_utxo, and wallet_api_tests.

Definition at line 700 of file trezor_tests.cpp.

701{
702 init_fields();
703 setup_trezor();
704
707
708 m_alice_account.create_from_device(*m_trezor);
709 m_alice_account.set_createtime(m_wallet_ts);
710
711 // Events, custom genesis so it matches wallet genesis
712 auto & generator = m_generator; // macro shortcut
713
714 cryptonote::block blk_gen;
715 std::vector<size_t> block_weights;
716 generate_genesis_block(blk_gen, get_config(m_network_type).GENESIS_TX, get_config(m_network_type).GENESIS_NONCE);
717 events.push_back(blk_gen);
718 generator.add_block(blk_gen, 0, block_weights, 0);
719
720 // First event has to be the genesis block
721 m_bob_account.generate();
722 m_eve_account.generate();
723 m_bob_account.set_createtime(m_wallet_ts);
724 m_eve_account.set_createtime(m_wallet_ts);
725 cryptonote::account_base * accounts[] = {TREZOR_ACCOUNT_ORDERING};
726 for(cryptonote::account_base * ac : accounts){
727 events.push_back(*ac);
728 }
729
730 // Another block with predefined timestamp.
731 // Carefully set reward and already generated coins so it passes miner_tx check.
732 cryptonote::block blk_0;
733 {
734 std::list<cryptonote::transaction> tx_list;
735 const crypto::hash prev_id = get_block_hash(blk_gen);
736 const uint64_t already_generated_coins = generator.get_already_generated_coins(prev_id);
737 block_weights.clear();
738 generator.get_last_n_block_weights(block_weights, prev_id, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
739 generator.construct_block(blk_0, 1, prev_id, m_miner_account, m_ts_start, already_generated_coins, block_weights, tx_list);
740 }
741
742 events.push_back(blk_0);
743 MDEBUG("Gen+1 block has time: " << blk_0.timestamp << " blid: " << get_block_hash(blk_0));
744
745 // Generate some spendable funds on the Miner account
746 REWIND_BLOCKS_N(events, blk_3, blk_0, m_miner_account, 40);
747
748 // Rewind so the miners funds are unlocked for initial transactions.
749 REWIND_BLOCKS(events, blk_3r, blk_3, m_miner_account);
750
751 // Non-rct transactions Miner -> Bob
752 MAKE_TX_LIST_START(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(10), blk_3);
753 MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(7), blk_3);
754 MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(7), blk_3);
755 MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(14), blk_3);
756 MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(20), blk_3);
757 MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(2), blk_3);
758 MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(2), blk_3);
759 MAKE_TX_LIST(events, txs_blk_4, m_miner_account, m_alice_account, MK_COINS(5), blk_3);
760 MAKE_NEXT_BLOCK_TX_LIST(events, blk_4, blk_3r, m_miner_account, txs_blk_4);
761 REWIND_BLOCKS(events, blk_4r, blk_4, m_miner_account); // rewind to unlock
762
763 // Hard fork to bulletproofs version, v9.
764 const uint8_t CUR_HF = 9;
765 auto hardfork_height = num_blocks(events); // next block is v9
766 ADD_HARDFORK(m_hard_forks, CUR_HF, hardfork_height);
767 add_hforks(events, m_hard_forks);
768 MDEBUG("Hardfork height: " << hardfork_height << " at block: " << get_block_hash(blk_4r));
769
770 // RCT transactions, wallets have to be used, wallet init
771 m_wl_alice.reset(new tools::wallet2(m_network_type, 1, true));
772 m_wl_bob.reset(new tools::wallet2(m_network_type, 1, true));
775
776 auto addr_alice_sub_0_1 = m_wl_alice->get_subaddress({0, 1});
777 auto addr_alice_sub_0_2 = m_wl_alice->get_subaddress({0, 2});
778 auto addr_alice_sub_0_3 = m_wl_alice->get_subaddress({0, 3});
779 auto addr_alice_sub_0_4 = m_wl_alice->get_subaddress({0, 4});
780 auto addr_alice_sub_0_5 = m_wl_alice->get_subaddress({0, 5});
781 auto addr_alice_sub_1_0 = m_wl_alice->get_subaddress({1, 0});
782 auto addr_alice_sub_1_1 = m_wl_alice->get_subaddress({1, 1});
783 auto addr_alice_sub_1_2 = m_wl_alice->get_subaddress({1, 2});
784
785 // Miner -> Bob, RCT funds
786 MAKE_TX_LIST_START_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(50), 10, blk_4);
787
788 const size_t target_rct = m_heavy_tests ? 105 : 15;
789 for(size_t i = 0; i < target_rct; ++i)
790 {
791 MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(1) >> 2, 10, blk_4);
792 }
793
794 // Sub-address destinations
795 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_1, true, MK_COINS(1) >> 1), 10, blk_4);
796 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_2, true, MK_COINS(1) >> 1), 10, blk_4);
797 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_3, true, MK_COINS(1) >> 1), 10, blk_4);
798 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_0_4, true, MK_COINS(1) >> 1), 10, blk_4);
799
800 // Sub-address destinations + multi out to force use of additional keys
801 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_0_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}}), 10, blk_4);
802 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_0_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
803 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{m_miner_account, false, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
804 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{m_miner_account, false, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
805
806 // Transfer to other accounts
807 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_1_0, true, MK_COINS(1) >> 1), 10, blk_4);
808 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts(addr_alice_sub_1_1, true, MK_COINS(1) >> 1), 10, blk_4);
809 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_1_0, true, MK_COINS(1) >> 1}, {addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_3, true, MK_COINS(1) >> 1}}), 10, blk_4);
810 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_2, true, MK_COINS(1) >> 1}}), 10, blk_4);
811 MAKE_TX_MIX_DEST_LIST_RCT(events, txs_blk_5, m_miner_account, build_dsts({{addr_alice_sub_1_2, true, MK_COINS(1) >> 1}, {addr_alice_sub_1_1, true, MK_COINS(1) >> 1}, {addr_alice_sub_0_5, true, MK_COINS(1) >> 1}}), 10, blk_4);
812
813 // Simple RCT transactions
814 MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(7), 10, blk_4);
815 MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(10), 10, blk_4);
816 MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(30), 10, blk_4);
817 MAKE_TX_MIX_LIST_RCT(events, txs_blk_5, m_miner_account, m_alice_account, MK_COINS(40), 10, blk_4);
818 MAKE_NEXT_BLOCK_TX_LIST_HF(events, blk_5, blk_4r, m_miner_account, txs_blk_5, CUR_HF);
819
820 // Simple transaction check
821 bool resx = rct::verRctSemanticsSimple(txs_blk_5.begin()->rct_signatures);
822 bool resy = rct::verRctNonSemanticsSimple(txs_blk_5.begin()->rct_signatures);
823 CHECK_AND_ASSERT_THROW_MES(resx, "Tsx5[0] semantics failed");
824 CHECK_AND_ASSERT_THROW_MES(resy, "Tsx5[0] non-semantics failed");
825
826 REWIND_BLOCKS_HF(events, blk_5r, blk_5, m_miner_account, CUR_HF); // rewind to unlock
827
828 // RCT transactions, wallets have to be used
829 wallet_tools::process_transactions(m_wl_alice.get(), events, blk_5r, m_bt);
830 wallet_tools::process_transactions(m_wl_bob.get(), events, blk_5r, m_bt);
831
832 // Send Alice -> Bob, manually constructed. Simple TX test, precondition.
833 cryptonote::transaction tx_1;
834 std::vector<size_t> selected_transfers;
835 std::vector<tx_source_entry> sources;
836 bool res = wallet_tools::fill_tx_sources(m_wl_alice.get(), sources, TREZOR_TEST_MIXIN, boost::none, MK_COINS(2), m_bt, selected_transfers, num_blocks(events) - 1, 0, 1);
837 CHECK_AND_ASSERT_THROW_MES(res, "TX Fill sources failed");
838
840 events.push_back(tx_1);
841 MAKE_NEXT_BLOCK_TX1_HF(events, blk_6, blk_5r, m_miner_account, tx_1, CUR_HF);
842 MDEBUG("Post 1st tsx: " << (num_blocks(events) - 1) << " at block: " << get_block_hash(blk_6));
843
844 // Simple transaction check
847 CHECK_AND_ASSERT_THROW_MES(resx, "tx_1 semantics failed");
848 CHECK_AND_ASSERT_THROW_MES(resy, "tx_1 non-semantics failed");
849
850 REWIND_BLOCKS_N_HF(events, blk_6r, blk_6, m_miner_account, 10, CUR_HF);
852 wallet_tools::process_transactions(m_wl_bob.get(), events, blk_6, m_bt);
853 MDEBUG("Available funds on Alice: " << get_available_funds(m_wl_alice.get()));
854 MDEBUG("Available funds on Bob: " << get_available_funds(m_wl_bob.get()));
855
856 m_head = blk_6r;
857 m_events = events;
858 return true;
859}
std::vector< cryptonote::tx_destination_entry > build_dsts(const var_addr_t &to1, bool sub1, uint64_t am1)
Definition chaingen.cpp:813
bool construct_tx_to_key(const std::vector< test_event_entry > &events, cryptonote::transaction &tx, const cryptonote::block &blk_head, const cryptonote::account_base &from, const var_addr_t &to, uint64_t amount, uint64_t fee, size_t nmix, bool rct, rct::RangeProofType range_proof_type, int bp_version)
Definition chaingen.cpp:872
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition chaingen.h:890
#define MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
Definition chaingen.h:913
#define MAKE_TX_MIX_DEST_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD)
Definition chaingen.h:923
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition chaingen.h:935
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
Definition chaingen.h:867
#define REWIND_BLOCKS_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF)
Definition chaingen.h:891
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition chaingen.h:933
#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT)
Definition chaingen.h:889
#define MK_COINS(amount)
Definition chaingen.h:1060
#define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF)
Definition chaingen.h:858
#define MAKE_TX_LIST_START_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
Definition chaingen.h:939
#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF)
Definition chaingen.h:877
virtual void setup_trezor()
virtual void update_client_settings()
static const uint64_t m_wallet_ts
std::unique_ptr< tools::wallet2 > m_wl_bob
virtual void init_fields()
std::unique_ptr< tools::wallet2 > m_wl_alice
static const uint64_t m_ts_start
static void set_account(tools::wallet2 *wallet, cryptonote::account_base &account)
static bool fill_tx_sources(tools::wallet2 *wallet, std::vector< cryptonote::tx_source_entry > &sources, size_t mixin, const boost::optional< size_t > &num_utxo, const boost::optional< uint64_t > &min_amount, block_tracker &bt, std::vector< size_t > &selected, uint64_t cur_height, ssize_t offset=0, int step=1, const boost::optional< fnc_accept_tx_source_t > &fnc_accept=boost::none)
static void process_transactions(tools::wallet2 *wallet, const std::vector< test_event_entry > &events, const cryptonote::block &blk_head, block_tracker &bt, const boost::optional< crypto::hash > &blk_tail=boost::none)
#define CRYPTONOTE_REWARD_BLOCKS_WINDOW
const char * res
POD_CLASS hash
Definition hash.h:50
bool generate_genesis_block(block &bl, std::string const &genesis_tx, uint32_t nonce)
const config_t & get_config(network_type nettype)
bool verRctSemanticsSimple(const std::vector< const rctSig * > &rvv)
Definition rctSigs.cpp:975
bool verRctNonSemanticsSimple(const rctSig &rv)
Definition rctSigs.cpp:1085
unsigned __int64 uint64_t
Definition stdint.h:136
#define TREZOR_ACCOUNT_ORDERING
#define TREZOR_TEST_FEE
#define TREZOR_TEST_MIXIN
Here is the call graph for this function:

◆ head_block()

cryptonote::block gen_trezor_base::head_block ( ) const
inline

Definition at line 92 of file trezor_tests.h.

92{ return m_head; }
Here is the caller graph for this function:

◆ head_hash()

crypto::hash gen_trezor_base::head_hash ( ) const
inline

Definition at line 91 of file trezor_tests.h.

91{ return get_block_hash(m_head); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ heavy_tests()

bool gen_trezor_base::heavy_tests ( ) const
inline

Definition at line 93 of file trezor_tests.h.

93{ return m_heavy_tests; }
Here is the caller graph for this function:

◆ init_fields()

void gen_trezor_base::init_fields ( )
protectedvirtual

Definition at line 680 of file trezor_tests.cpp.

681{
682 m_miner_account.generate();
684
685 crypto::secret_key master_seed{};
687
688 m_alice_account.generate(master_seed, true);
689 m_alice_account.set_createtime(m_wallet_ts);
690}
#define DEFAULT_HARDFORKS(HARDFORKS)
Definition chaingen.h:795
static const std::string m_master_seed_str
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:82
bool hex_to_pod(const std::string &hex_str, t_pod_type &s)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

void gen_trezor_base::load ( std::vector< test_event_entry > & events)
virtual

Definition at line 861 of file trezor_tests.cpp.

862{
863 init_fields();
864 m_events = events;
865
866 unsigned acc_idx = 0;
867 cryptonote::account_base * accounts[] = {TREZOR_ACCOUNT_ORDERING};
868 unsigned accounts_num = (sizeof(accounts) / sizeof(accounts[0]));
869
870 for(auto & ev : events)
871 {
872 if (typeid(cryptonote::block) == ev.type())
873 {
874 m_head = boost::get<cryptonote::block>(ev);
875 }
876 else if (typeid(cryptonote::account_base) == ev.type()) // accounts
877 {
878 const auto & acc = boost::get<cryptonote::account_base>(ev);
879 if (acc_idx < accounts_num)
880 {
881 *accounts[acc_idx++] = acc;
882 }
883 }
884 else if (typeid(event_replay_settings) == ev.type()) // hard forks
885 {
886 const auto & rep_settings = boost::get<event_replay_settings>(ev);
887 if (rep_settings.hard_forks)
888 {
889 const auto & hf = rep_settings.hard_forks.get();
890 std::copy(hf.begin(), hf.end(), std::back_inserter(m_hard_forks));
891 }
892 }
893 }
894
895 // Setup wallets, synchronize blocks
896 m_bob_account.set_createtime(m_wallet_ts);
897 m_eve_account.set_createtime(m_wallet_ts);
898
899 setup_trezor();
901 m_alice_account.create_from_device(*m_trezor);
902 m_alice_account.set_createtime(m_wallet_ts);
903
904 m_wl_alice.reset(new tools::wallet2(m_network_type, 1, true));
905 m_wl_bob.reset(new tools::wallet2(m_network_type, 1, true));
906 m_wl_eve.reset(new tools::wallet2(m_network_type, 1, true));
910
913 MDEBUG("Available funds on Alice: " << get_available_funds(m_wl_alice.get()));
914 MDEBUG("Available funds on Bob: " << get_available_funds(m_wl_bob.get()));
915}
std::unique_ptr< tools::wallet2 > m_wl_eve
Here is the call graph for this function:

◆ mine_and_test()

void gen_trezor_base::mine_and_test ( std::vector< test_event_entry > & events)
virtual

Definition at line 1231 of file trezor_tests.cpp.

1232{
1233 cryptonote::core * core = daemon()->core();
1234 const uint64_t height_before_mining = daemon()->get_height();
1235
1237 daemon()->mine_blocks(1, miner_address);
1238
1239 const uint64_t cur_height = daemon()->get_height();
1240 CHECK_AND_ASSERT_THROW_MES(height_before_mining < cur_height, "Mining fail");
1241
1242 const crypto::hash top_hash = core->get_blockchain_storage().get_block_id_by_height(height_before_mining);
1243 cryptonote::block top_block{};
1244 CHECK_AND_ASSERT_THROW_MES(core->get_blockchain_storage().get_block_by_hash(top_hash, top_block), "Block fetch fail");
1245 CHECK_AND_ASSERT_THROW_MES(!top_block.tx_hashes.empty(), "Mined block is empty");
1246
1247 std::vector<cryptonote::transaction> txs_found;
1248 std::vector<crypto::hash> txs_missed;
1249 bool r = core->get_blockchain_storage().get_transactions(top_block.tx_hashes, txs_found, txs_missed);
1250 CHECK_AND_ASSERT_THROW_MES(r, "Transaction lookup fail");
1251 CHECK_AND_ASSERT_THROW_MES(!txs_found.empty(), "Transaction lookup fail");
1252
1253 // Transaction is not expanded, but mining verified it.
1254 events.push_back(txs_found[0]);
1255 events.push_back(top_block);
1256}
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition chaingen.cpp:665
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block's hash given a height
bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan=NULL) const
gets the block with a given hash
bool get_transactions(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs) const
Blockchain & get_blockchain_storage()
gets the Blockchain instance
uint64_t get_height()
Definition daemon.cpp:371
cryptonote::core * core() const
Definition daemon.h:153
void mine_blocks(size_t num_blocks, const std::string &miner_address)
Definition daemon.cpp:312
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
std::vector< crypto::hash > tx_hashes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nettype()

cryptonote::network_type gen_trezor_base::nettype ( ) const
inline

Definition at line 96 of file trezor_tests.h.

96{ return m_network_type; }
Here is the caller graph for this function:

◆ rct_config()

void gen_trezor_base::rct_config ( rct::RCTConfig rct_config)
inline

Definition at line 94 of file trezor_tests.h.

void rct_config(rct::RCTConfig rct_config)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rewind_blocks()

void gen_trezor_base::rewind_blocks ( std::vector< test_event_entry > & events,
size_t rewind_n,
uint8_t hf )
virtual

Definition at line 917 of file trezor_tests.cpp.

918{
919 auto & generator = m_generator; // macro shortcut
920 REWIND_BLOCKS_N_HF(events, blk_new, m_head, m_miner_account, rewind_n, hf);
921 m_head = blk_new;
922 m_events = events;
923 MDEBUG("Blocks rewound: " << rewind_n << ", #blocks: " << num_blocks(events) << ", #events: " << events.size());
924
927}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialize()

template<class Archive>
void gen_trezor_base::serialize ( Archive & ar,
const unsigned int  )
inlineprotected

Definition at line 143 of file trezor_tests.h.

144 {
145 ar & m_generator;
146 ar & m_network_type;
147 }

◆ set_hard_fork()

void gen_trezor_base::set_hard_fork ( uint8_t hf)
virtual

Definition at line 1258 of file trezor_tests.cpp.

1259{
1260 m_top_hard_fork = hf;
1261 if (hf < 9){
1262 throw std::runtime_error("Minimal supported Hardfork is 9");
1263 } else if (hf == 9){
1265 } else {
1267 }
1268}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_args()

void gen_trezor_base::setup_args ( const std::string & trezor_path,
bool heavy_tests = false )
virtual

Definition at line 624 of file trezor_tests.cpp.

625{
626 m_trezor_path = trezor_path.empty() ? m_device_name : std::string("Trezor:") + trezor_path;
628}
bool heavy_tests() const
static const std::string m_device_name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_trezor()

void gen_trezor_base::setup_trezor ( )
protectedvirtual

Definition at line 630 of file trezor_tests.cpp.

631{
632 hw::device &hwdev = hw::get_device(m_trezor_path);
633 auto trezor = dynamic_cast<device_trezor_test *>(&hwdev);
634 CHECK_AND_ASSERT_THROW_MES(trezor, "Dynamic cast failed");
635
636 trezor->setup_for_tests(m_trezor_path, m_device_seed, m_network_type);
637 m_trezor = trezor;
638}
static const std::string m_device_seed
device & get_device(const std::string &device_descriptor)
Definition device.cpp:95
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_get_tx()

void gen_trezor_base::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

Definition at line 1175 of file trezor_tests.cpp.

1180{
1181 if (!m_test_get_tx_key)
1182 {
1183 return;
1184 }
1185
1186 auto dev_cold = dynamic_cast<::hw::device_cold*>(m_trezor);
1187 CHECK_AND_ASSERT_THROW_MES(dev_cold, "Device does not implement cold signing interface");
1188
1189 if (!dev_cold->is_get_tx_key_supported())
1190 {
1191 MERROR("Get TX key is not supported by the connected Trezor");
1192 return;
1193 }
1194
1195 subaddresses_t all_subs;
1196 for(tools::wallet2 * wlt : wallets)
1197 {
1198 wlt->expand_subaddresses({10, 20});
1199
1201 all_subs.insert(cur_sub.begin(), cur_sub.end());
1202 }
1203
1204 for(size_t txid = 0; txid < ptxs.size(); ++txid)
1205 {
1206 const auto &c_ptx = ptxs[txid];
1207 const auto &c_tx = c_ptx.tx;
1208 const ::crypto::hash tx_prefix_hash = cryptonote::get_transaction_prefix_hash(c_tx);
1209
1210 auto tx_pub = cryptonote::get_tx_pub_key_from_extra(c_tx.extra);
1211 auto additional_pub_keys = cryptonote::get_additional_tx_pub_keys_from_extra(c_tx.extra);
1212
1213 hw::device_cold:: tx_key_data_t tx_key_data;
1214 std::vector<::crypto::secret_key> tx_keys;
1215
1216 dev_cold->load_tx_key_data(tx_key_data, aux_tx_info[txid]);
1217 CHECK_AND_ASSERT_THROW_MES(std::string(tx_prefix_hash.data, 32) == tx_key_data.tx_prefix_hash, "TX prefix mismatch");
1218
1219 dev_cold->get_tx_key(tx_keys, tx_key_data, m_alice_account.get_keys().m_view_secret_key);
1220 CHECK_AND_ASSERT_THROW_MES(!tx_keys.empty(), "Empty TX keys");
1221 CHECK_AND_ASSERT_THROW_MES(verify_tx_key(tx_keys[0], tx_pub, all_subs), "Tx pub mismatch");
1222 CHECK_AND_ASSERT_THROW_MES(additional_pub_keys.size() == tx_keys.size() - 1, "Invalid additional keys count");
1223
1224 for(size_t i = 0; i < additional_pub_keys.size(); ++i)
1225 {
1226 CHECK_AND_ASSERT_THROW_MES(verify_tx_key(tx_keys[i + 1], additional_pub_keys[i], all_subs), "Tx pub mismatch");
1227 }
1228 }
1229}
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > subaddresses_t
Definition chaingen.h:359
virtual bool verify_tx_key(const ::crypto::secret_key &tx_priv, const ::crypto::public_key &tx_pub, const subaddresses_t &subs)
static subaddresses_t & get_subaddresses(tools::wallet2 *wallet)
#define MERROR(x)
Definition misc_log_ex.h:73
std::vector< crypto::public_key > get_additional_tx_pub_keys_from_extra(const std::vector< uint8_t > &tx_extra)
void get_transaction_prefix_hash(const transaction_prefix &tx, crypto::hash &h)
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_setup()

void gen_trezor_base::test_setup ( std::vector< test_event_entry > & events)
virtual

Definition at line 963 of file trezor_tests.cpp.

964{
965 add_shared_events(events);
966
967 setup_trezor();
969
970 m_alice_account.create_from_device(*m_trezor);
971 m_alice_account.set_createtime(m_wallet_ts);
972
973 m_wl_alice.reset(new tools::wallet2(m_network_type, 1, true));
974 m_wl_bob.reset(new tools::wallet2(m_network_type, 1, true));
975 m_wl_eve.reset(new tools::wallet2(m_network_type, 1, true));
982}
virtual void add_shared_events(std::vector< test_event_entry > &events)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_trezor_tx()

void gen_trezor_base::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

Definition at line 1008 of file trezor_tests.cpp.

1009{
1010 // Construct pending transaction for signature in the Trezor.
1011 const uint64_t height_pre = num_blocks(events) - 1;
1012 cryptonote::block head_block = get_head_block(events);
1014
1015 tools::wallet2::unsigned_tx_set txs;
1016 std::vector<cryptonote::transaction> tx_list;
1017
1018 for(auto &ptx : ptxs) {
1019 txs.txes.push_back(get_construction_data_with_decrypted_short_payment_id(ptx, *m_trezor));
1020 }
1021 txs.transfers = std::make_pair(0, wallet_accessor_test::get_transfers(m_wl_alice.get()));
1022
1023 auto dev_cold = dynamic_cast<::hw::device_cold*>(m_trezor);
1024 CHECK_AND_ASSERT_THROW_MES(dev_cold, "Device does not implement cold signing interface");
1025
1026 tools::wallet2::signed_tx_set exported_txs;
1027 hw::tx_aux_data aux_data;
1029 setup_shim(&wallet_shim);
1030 aux_data.tx_recipients = dsts_info;
1031 aux_data.bp_version = m_rct_config.bp_version;
1032 dev_cold->tx_sign(&wallet_shim, txs, exported_txs, aux_data);
1033
1034 MDEBUG("Signed tx data from hw: " << exported_txs.ptx.size() << " transactions");
1035 CHECK_AND_ASSERT_THROW_MES(exported_txs.ptx.size() == ptxs.size(), "Invalid transaction sizes");
1036
1037 for (size_t i = 0; i < exported_txs.ptx.size(); ++i){
1038 auto &c_ptx = exported_txs.ptx[i];
1039 c_ptx.tx.rct_signatures.mixRing = ptxs[i].tx.rct_signatures.mixRing;
1040 expand_tsx(c_ptx.tx);
1041
1042 // Simple TX tests, more complex are performed in the core.
1044 bool resx = rct::verRctSemanticsSimple(c_ptx.tx.rct_signatures);
1045 bool resy = rct::verRctNonSemanticsSimple(c_ptx.tx.rct_signatures);
1046 CHECK_AND_ASSERT_THROW_MES(resx, "Trezor tx_1 semantics failed");
1047 CHECK_AND_ASSERT_THROW_MES(resy, "Trezor tx_1 Nonsemantics failed");
1048
1049 tx_list.push_back(c_ptx.tx);
1050 MDEBUG("Transaction: " << dump_data(c_ptx.tx));
1051 }
1052
1053 add_transactions_to_events(events, generator, tx_list);
1054
1055 // TX receive test
1056 uint64_t sum_in = 0;
1057 uint64_t sum_out = 0;
1058
1059 for(size_t txid = 0; txid < exported_txs.ptx.size(); ++txid) {
1060 auto &c_ptx = exported_txs.ptx[txid];
1061 auto &c_tx = c_ptx.tx;
1063 const size_t num_outs = c_tx.vout.size();
1064 size_t num_received = 0;
1065 uint64_t cur_sum_in = 0;
1066 uint64_t cur_sum_out = 0;
1067 uint64_t cur_sum_out_recv = 0;
1068 std::unordered_set<size_t> recv_out_idx;
1069 std::string exp_payment_id = get_payment_id(c_ptx.construction_data.extra);
1070 std::string enc_payment_id = get_payment_id(c_tx.extra);
1071 size_t num_payment_id_checks_done = 0;
1072
1073 CHECK_AND_ASSERT_THROW_MES(exp_payment_id.empty() || exp_payment_id.size() == 8 || exp_payment_id.size() == 32, "Required payment ID invalid");
1074 CHECK_AND_ASSERT_THROW_MES((exp_payment_id.size() == 32) == (enc_payment_id.size() == 32), "Required and built payment ID size mismatch");
1075 CHECK_AND_ASSERT_THROW_MES(exp_payment_id.size() <= enc_payment_id.size(), "Required and built payment ID size mismatch");
1076
1077 for(auto &src : c_ptx.construction_data.sources){
1078 cur_sum_in += src.amount;
1079 }
1080
1081 for(auto &dst : c_ptx.construction_data.splitted_dsts){
1082 cur_sum_out += dst.amount;
1083 }
1084
1085 CHECK_AND_ASSERT_THROW_MES(c_tx.rct_signatures.txnFee + cur_sum_out == cur_sum_in, "Tx Input Output amount mismatch");
1086
1087 for (size_t widx = 0; widx < wallets.size(); ++widx) {
1088 const bool sender = widx == 0;
1089 tools::wallet2 *wl = wallets[widx];
1090
1091 wallet_tools::process_transactions(wl, events, m_head, m_bt, boost::make_optional(head_hash));
1092
1095 wl->get_transfers(m_trans);
1096
1097 std::copy_if(m_trans.begin(), m_trans.end(), std::back_inserter(m_trans_txid), [&txhash](const tools::wallet2::transfer_details& item) {
1098 return item.m_txid == txhash;
1099 });
1100
1101 // Testing if the transaction output has been received
1102 num_received += m_trans_txid.size();
1103 for (auto & ctran : m_trans_txid){
1104 cur_sum_out_recv += ctran.amount();
1105 recv_out_idx.insert(ctran.m_internal_output_index);
1106 CHECK_AND_ASSERT_THROW_MES(!ctran.m_spent, "Txout is spent");
1107 CHECK_AND_ASSERT_THROW_MES(!sender || ctran.m_key_image_known, "Key Image unknown for recipient"); // sender is Trezor, does not need to have KI
1108 }
1109
1110 // Sender output payment (contains change and stuff)
1111 if (sender) {
1112 std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> confirmed_transfers; // txid -> tdetail
1113 std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> confirmed_transfers_txid; // txid -> tdetail
1114 wl->get_payments_out(confirmed_transfers, height_pre);
1115
1116 std::copy_if(confirmed_transfers.begin(), confirmed_transfers.end(), std::back_inserter(confirmed_transfers_txid), [&txhash](const std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>& item) {
1117 return item.first == txhash;
1118 });
1119
1120 CHECK_AND_ASSERT_THROW_MES(confirmed_transfers_txid.size() == 1, "Sender does not have outgoing transfer for the transaction");
1121 }
1122
1123 // Received payment from the block
1124 std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments; // payment id -> [payment details] multimap
1125 std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments_txid; // payment id -> [payment details] multimap
1126 wl->get_payments(payments, height_pre);
1127
1128 std::copy_if(payments.begin(), payments.end(), std::back_inserter(payments_txid), [&txhash](const std::pair<crypto::hash, tools::wallet2::payment_details>& item) {
1129 return item.second.m_tx_hash == txhash;
1130 });
1131
1132 for(auto &paydet : payments_txid){
1133 CHECK_AND_ASSERT_THROW_MES(exp_payment_id.empty() || (memcmp(exp_payment_id.data(), paydet.first.data, exp_payment_id.size()) == 0), "Payment ID mismatch");
1134 num_payment_id_checks_done += 1;
1135 }
1136 }
1137
1138 CHECK_AND_ASSERT_THROW_MES(c_tx.rct_signatures.txnFee + cur_sum_out_recv == cur_sum_in, "Tx Input Output amount mismatch");
1139 CHECK_AND_ASSERT_THROW_MES(exp_payment_id.empty() || num_payment_id_checks_done > 0, "No Payment ID checks");
1140
1141 if(!is_sweep){
1142 CHECK_AND_ASSERT_THROW_MES(num_received == num_outs, "Number of received outputs do not match number of outgoing");
1143 CHECK_AND_ASSERT_THROW_MES(recv_out_idx.size() == num_outs, "Num of outs received do not match");
1144 } else {
1145 CHECK_AND_ASSERT_THROW_MES(num_received + 1 >= num_outs, "Number of received outputs do not match number of outgoing");
1146 CHECK_AND_ASSERT_THROW_MES(recv_out_idx.size() + 1 >= num_outs, "Num of outs received do not match"); // can have dummy out
1147 }
1148
1149 sum_in += cur_sum_in;
1150 sum_out += cur_sum_out + c_tx.rct_signatures.txnFee;
1151 }
1152
1153 CHECK_AND_ASSERT_THROW_MES(sum_in == sum_out, "Tx amount mismatch");
1154
1155 // Test get_tx_key feature for stored private tx keys
1156 test_get_tx(events, wallets, exported_txs.ptx, aux_data.tx_device_aux);
1157}
cryptonote::block get_head_block(const std::vector< test_event_entry > &events)
std::string dump_data(const cryptonote::transaction &tx)
Definition chaingen.cpp:617
virtual void add_transactions_to_events(std::vector< test_event_entry > &events, test_generator &generator, const std::vector< cryptonote::transaction > &txs)
crypto::hash head_hash() const
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)
cryptonote::block head_block() const
std::vector< std::string > tx_device_aux
boost::optional< int > bp_version
std::vector< cryptonote::address_parse_info > tx_recipients
void get_payments(const crypto::hash &payment_id, std::list< wallet2::payment_details > &payments, uint64_t min_height=0, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition wallet2.cpp:6320
void get_payments_out(std::list< std::pair< crypto::hash, wallet2::confirmed_transfer_details > > &confirmed_payments, uint64_t min_height, uint64_t max_height=(uint64_t) -1, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition wallet2.cpp:6346
void get_transfers(wallet2::transfer_container &incoming_transfers) const
Definition wallet2.cpp:6315
std::vector< transfer_details > transfer_container
Definition wallet2.h:449
static tools::wallet2::transfer_container & get_transfers(tools::wallet2 *wallet)
#define MTRACE(x)
Definition misc_log_ex.h:77
std::string obj_to_json_str(T &obj)
crypto::hash get_transaction_hash(const transaction &t)
struct hw::wallet_shim wallet_shim
std::vector< pending_tx > ptx
Definition wallet2.h:505
std::vector< tx_construction_data > txes
Definition wallet2.h:499
std::pair< size_t, wallet2::transfer_container > transfers
Definition wallet2.h:500
Here is the call graph for this function:

◆ update_client_settings()

void gen_trezor_base::update_client_settings ( )
protectedvirtual

Definition at line 692 of file trezor_tests.cpp.

693{
694 auto dev_trezor = dynamic_cast<::hw::trezor::device_trezor*>(m_trezor);
695 CHECK_AND_ASSERT_THROW_MES(dev_trezor, "Could not cast to device_trezor");
696
697 dev_trezor->set_live_refresh_enabled(m_live_refresh_enabled);
698}
Here is the caller graph for this function:

◆ update_trackers()

void gen_trezor_base::update_trackers ( std::vector< test_event_entry > & events)
virtual

Definition at line 958 of file trezor_tests.cpp.

959{
961}
Here is the call graph for this function:

◆ verify_tx_key()

bool gen_trezor_base::verify_tx_key ( const ::crypto::secret_key & tx_priv,
const ::crypto::public_key & tx_pub,
const subaddresses_t & subs )
protectedvirtual

Definition at line 1159 of file trezor_tests.cpp.

1160{
1161 ::crypto::public_key tx_pub_c;
1162 ::crypto::secret_key_to_public_key(tx_priv, tx_pub_c);
1163 if (tx_pub == tx_pub_c)
1164 return true;
1165
1166 for(const auto & elem : subs)
1167 {
1168 tx_pub_c = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(elem.first), rct::sk2rct(tx_priv)));
1169 if (tx_pub == tx_pub_c)
1170 return true;
1171 }
1172 return false;
1173}
POD_CLASS public_key
Definition crypto.h:79
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition crypto.h:262
void scalarmultKey(key &aP, const key &P, const key &a)
Definition rctOps.cpp:368
Here is the call graph for this function:
Here is the caller graph for this function:

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 140 of file trezor_tests.h.

◆ tsx_builder

friend class tsx_builder
friend

Definition at line 49 of file trezor_tests.h.

Member Data Documentation

◆ m_alice_account

cryptonote::account_base gen_trezor_base::m_alice_account
protected

Definition at line 133 of file trezor_tests.h.

◆ m_alice_spend_private

const std::string gen_trezor_base::m_alice_spend_private = m_master_seed_str
static

Definition at line 106 of file trezor_tests.h.

◆ m_alice_view_private

const std::string gen_trezor_base::m_alice_view_private = "a6ccd4ac344a295d1387f8d18c81bdd394f1845de84188e204514ef9370fd403"
static

Definition at line 107 of file trezor_tests.h.

◆ m_bob_account

cryptonote::account_base gen_trezor_base::m_bob_account
protected

Definition at line 132 of file trezor_tests.h.

◆ m_bt

block_tracker gen_trezor_base::m_bt
protected

Definition at line 116 of file trezor_tests.h.

◆ m_daemon

std::shared_ptr<mock_daemon> gen_trezor_base::m_daemon
protected

Definition at line 118 of file trezor_tests.h.

◆ m_device_name

const std::string gen_trezor_base::m_device_name = "Trezor:udp"
static

Definition at line 103 of file trezor_tests.h.

◆ m_device_seed

const std::string gen_trezor_base::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

Definition at line 105 of file trezor_tests.h.

◆ m_eve_account

cryptonote::account_base gen_trezor_base::m_eve_account
protected

Definition at line 134 of file trezor_tests.h.

◆ m_events

std::vector<test_event_entry> gen_trezor_base::m_events
protected

Definition at line 123 of file trezor_tests.h.

◆ m_generator

test_generator gen_trezor_base::m_generator
protected

Definition at line 115 of file trezor_tests.h.

◆ m_hard_forks

v_hardforks_t gen_trezor_base::m_hard_forks
protected

Definition at line 121 of file trezor_tests.h.

◆ m_head

cryptonote::block gen_trezor_base::m_head
protected

Definition at line 122 of file trezor_tests.h.

◆ m_heavy_tests

bool gen_trezor_base::m_heavy_tests
protected

Definition at line 126 of file trezor_tests.h.

◆ m_live_refresh_enabled

bool gen_trezor_base::m_live_refresh_enabled
protected

Definition at line 129 of file trezor_tests.h.

◆ m_master_seed_str

const std::string gen_trezor_base::m_master_seed_str = "14821d0bc5659b24cafbc889dc4fc60785ee08b65d71c525f81eeaba4f3a570f"
static

Definition at line 104 of file trezor_tests.h.

◆ m_miner_account

cryptonote::account_base gen_trezor_base::m_miner_account
protected

Definition at line 131 of file trezor_tests.h.

◆ m_network_type

cryptonote::network_type gen_trezor_base::m_network_type
protected

Definition at line 117 of file trezor_tests.h.

◆ m_rct_config

rct::RCTConfig gen_trezor_base::m_rct_config
protected

Definition at line 128 of file trezor_tests.h.

◆ m_test_get_tx_key

bool gen_trezor_base::m_test_get_tx_key
protected

Definition at line 127 of file trezor_tests.h.

◆ m_top_hard_fork

uint8_t gen_trezor_base::m_top_hard_fork
protected

Definition at line 120 of file trezor_tests.h.

◆ m_trezor

hw::trezor::device_trezor* gen_trezor_base::m_trezor
protected

Definition at line 135 of file trezor_tests.h.

◆ m_trezor_path

std::string gen_trezor_base::m_trezor_path
protected

Definition at line 125 of file trezor_tests.h.

◆ m_ts_start

const uint64_t gen_trezor_base::m_ts_start = 1397862000
static

Definition at line 101 of file trezor_tests.h.

◆ m_wallet_ts

const uint64_t gen_trezor_base::m_wallet_ts = m_ts_start - 60*60*24*4
static

Definition at line 102 of file trezor_tests.h.

◆ m_wl_alice

std::unique_ptr<tools::wallet2> gen_trezor_base::m_wl_alice
protected

Definition at line 136 of file trezor_tests.h.

◆ m_wl_bob

std::unique_ptr<tools::wallet2> gen_trezor_base::m_wl_bob
protected

Definition at line 137 of file trezor_tests.h.

◆ m_wl_eve

std::unique_ptr<tools::wallet2> gen_trezor_base::m_wl_eve
protected

Definition at line 138 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