diff options
author | Dusan Klinec <dusan.klinec@gmail.com> | 2022-10-20 17:23:28 +0200 |
---|---|---|
committer | Dusan Klinec <dusan.klinec@gmail.com> | 2022-11-17 12:12:23 +0100 |
commit | 1114e7eed778b4957561bca4da5c7631f8c60133 (patch) | |
tree | acf440f32a8af468dbdc1b74c4c8ab139f504f7b /tests/trezor | |
parent | Merge pull request #8587 (diff) | |
download | monero-1114e7eed778b4957561bca4da5c7631f8c60133.tar.xz |
fix(trezor-tests): fix trezor tests build, fix integrated addr test
- fix integrated address test, it was not testing integrated address suport
- fix trezor test build as dependent classes were changed
- add a friend test class for Monero::WalletImpl to support wallet api tests
When using wallet_api in tests, synthetic chain is used. Without being able to set `allow_mismatched_daemon_version` in the underlying wallet, we are not able to use a synthetic chain with the tests
Diffstat (limited to 'tests/trezor')
-rw-r--r-- | tests/trezor/daemon.cpp | 2 | ||||
-rw-r--r-- | tests/trezor/trezor_tests.cpp | 19 |
2 files changed, 16 insertions, 5 deletions
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); |