diff options
author | luigi1111 <luigi1111w@gmail.com> | 2022-12-01 01:08:53 -0600 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2022-12-01 01:08:53 -0600 |
commit | 2f168da7f7e09e3351db95e66623759f11a83191 (patch) | |
tree | d8b22a9f60781b09ba6ebe702b2b6181b3428f84 /tests | |
parent | Merge pull request #8616 (diff) | |
parent | fix(trezor-tests): fix trezor tests build, fix integrated addr test (diff) | |
download | monero-2f168da7f7e09e3351db95e66623759f11a83191.tar.xz |
Merge pull request #8618
1114e7e fix(trezor-tests): fix trezor tests build, fix integrated addr test (Dusan Klinec)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core_tests/wallet_tools.h | 8 | ||||
-rw-r--r-- | tests/trezor/daemon.cpp | 2 | ||||
-rw-r--r-- | tests/trezor/trezor_tests.cpp | 19 |
3 files changed, 24 insertions, 5 deletions
diff --git a/tests/core_tests/wallet_tools.h b/tests/core_tests/wallet_tools.h index 982862d45..20cd2c4d9 100644 --- a/tests/core_tests/wallet_tools.h +++ b/tests/core_tests/wallet_tools.h @@ -32,6 +32,7 @@ #include "chaingen.h" #include "wallet/wallet2.h" +#include "wallet/api/wallet.h" typedef struct { tools::wallet2::transfer_details * td; @@ -57,6 +58,13 @@ public: static void process_parsed_blocks(tools::wallet2 * wallet, uint64_t start_height, const std::vector<cryptonote::block_complete_entry> &blocks, const std::vector<tools::wallet2::parsed_block> &parsed_blocks, uint64_t& blocks_added); }; +// Wallet API friend, direct access to required fields and private methods +class WalletApiAccessorTest +{ +public: + static void allow_mismatched_daemon_version(Monero::WalletImpl * wallet, bool allow_mismatch) { wallet->m_wallet->allow_mismatched_daemon_version(allow_mismatch); } +}; + class wallet_tools { public: diff --git a/tests/trezor/daemon.cpp b/tests/trezor/daemon.cpp index 546a8a180..be13f6d19 100644 --- a/tests/trezor/daemon.cpp +++ b/tests/trezor/daemon.cpp @@ -313,7 +313,7 @@ void mock_daemon::mine_blocks(size_t num_blocks, const std::string &miner_addres { bool blocks_mined = false; const uint64_t start_height = get_height(); - const auto mining_timeout = std::chrono::seconds(120); + const auto mining_timeout = std::chrono::seconds(360); MDEBUG("Current height before mining: " << start_height); start_mining(miner_address); diff --git a/tests/trezor/trezor_tests.cpp b/tests/trezor/trezor_tests.cpp index 0d61610be..cf85ffb30 100644 --- a/tests/trezor/trezor_tests.cpp +++ b/tests/trezor/trezor_tests.cpp @@ -137,8 +137,8 @@ int main(int argc, char* argv[]) hw::register_device(HW_TREZOR_NAME, ensure_trezor_test_device()); // shim device for call tracking // Bootstrapping common chain & accounts - const uint8_t initial_hf = (uint8_t)get_env_long("TEST_MIN_HF", HF_VERSION_CLSAG); - const uint8_t max_hf = (uint8_t)get_env_long("TEST_MAX_HF", HF_VERSION_CLSAG); + const uint8_t initial_hf = (uint8_t)get_env_long("TEST_MIN_HF", HF_VERSION_BULLETPROOF_PLUS); + const uint8_t max_hf = (uint8_t)get_env_long("TEST_MAX_HF", HF_VERSION_BULLETPROOF_PLUS); auto sync_test = get_env_long("TEST_KI_SYNC", 1); MINFO("Test versions " << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")"); MINFO("Testing hardforks [" << (int)initial_hf << ", " << (int)max_hf << "], sync-test: " << sync_test); @@ -1025,7 +1025,8 @@ void gen_trezor_base::test_trezor_tx(std::vector<test_event_entry>& events, std: for(auto &ptx : ptxs) { txs.txes.push_back(get_construction_data_with_decrypted_short_payment_id(ptx, *m_trezor)); } - txs.transfers = std::make_pair(0, wallet_accessor_test::get_transfers(m_wl_alice.get())); + const auto transfers = wallet_accessor_test::get_transfers(m_wl_alice.get()); + txs.transfers = std::make_tuple(0, transfers.size(), transfers); auto dev_cold = dynamic_cast<::hw::device_cold*>(m_trezor); CHECK_AND_ASSERT_THROW_MES(dev_cold, "Device does not implement cold signing interface"); @@ -1055,7 +1056,10 @@ void gen_trezor_base::test_trezor_tx(std::vector<test_event_entry>& events, std: CHECK_AND_ASSERT_THROW_MES(resy, "Trezor tx_1 Nonsemantics failed"); tx_list.push_back(c_ptx.tx); + const crypto::hash txhash = cryptonote::get_transaction_hash(c_ptx.tx); MDEBUG("Transaction: " << dump_data(c_ptx.tx)); + MDEBUG("Transaction hash: " << epee::string_tools::pod_to_hex(txhash)); + MDEBUG("Serialized transaction: " << epee::string_tools::buff_to_hex_nodelimer(tx_to_blob(c_ptx.tx))); } add_transactions_to_events(events, generator, tx_list); @@ -1384,7 +1388,9 @@ tsx_builder * tsx_builder::add_destination(const tools::wallet2 * wallet, bool i tsx_builder * tsx_builder::set_integrated(size_t idx) { + CHECK_AND_ASSERT_THROW_MES(m_destinations_orig.size() > idx, "Destination size not big enough to set integrated flag"); m_integrated.insert(idx); + m_destinations_orig[idx].is_integrated = true; return this; } @@ -1451,7 +1457,7 @@ tsx_builder * tsx_builder::construct_pending_tx(tools::wallet2::pending_tx &ptx, auto change_addr = m_from->get_account().get_keys().m_account_address; bool r = construct_tx_and_get_tx_key(m_from->get_account().get_keys(), subaddresses, m_sources, destinations_copy, change_addr, extra ? extra.get() : std::vector<uint8_t>(), tx, 0, tx_key, - additional_tx_keys, true, m_rct_config, nullptr); + additional_tx_keys, true, m_rct_config, this->m_tester->cur_hf() >= HF_VERSION_VIEW_TAGS); CHECK_AND_ASSERT_THROW_MES(r, "Transaction construction failed"); // Selected transfers permutation @@ -1927,6 +1933,11 @@ bool wallet_api_tests::generate(std::vector<test_event_entry>& events) Monero::WalletManager *wmgr = Monero::WalletManagerFactory::getWalletManager(); std::unique_ptr<Monero::Wallet> w{wmgr->createWalletFromDevice(wallet_path, "", api_net_type, m_trezor_path, 1)}; CHECK_AND_ASSERT_THROW_MES(w->init(daemon()->rpc_addr(), 0), "Wallet init fail"); + + auto walletImpl = dynamic_cast<Monero::WalletImpl *>(w.get()); + CHECK_AND_ASSERT_THROW_MES(walletImpl, "Dynamic wallet cast failed"); + WalletApiAccessorTest::allow_mismatched_daemon_version(walletImpl, true); + CHECK_AND_ASSERT_THROW_MES(w->refresh(), "Refresh fail"); uint64_t balance = w->balance(0); MDEBUG("Balance: " << balance); |