mirror of
https://github.com/monero-project/monero.git
synced 2025-07-25 07:15:28 -04:00
Merge pull request #8299
a0df140
feat(trezor): add HF15 support, BP+ (Dusan Klinec)
This commit is contained in:
commit
080fc69435
6 changed files with 232 additions and 181 deletions
|
@ -661,7 +661,7 @@ void block_tracker::process(const block* blk, const transaction * tx, size_t i)
|
|||
for (size_t j = 0; j < tx->vout.size(); ++j) {
|
||||
const tx_out &out = tx->vout[j];
|
||||
|
||||
if (typeid(cryptonote::txout_to_key) != out.target.type()) { // out_to_key
|
||||
if (typeid(cryptonote::txout_to_key) != out.target.type() && typeid(cryptonote::txout_to_tagged_key) != out.target.type()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace po = boost::program_options;
|
|||
namespace
|
||||
{
|
||||
const command_line::arg_descriptor<std::string> arg_filter = { "filter", "Regular expression filter for which tests to run" };
|
||||
const command_line::arg_descriptor<bool> arg_generate_and_play_test_data = {"generate_and_play_test_data", ""};
|
||||
const command_line::arg_descriptor<std::string> arg_trezor_path = {"trezor_path", "Path to the trezor device to use, has to support debug link", ""};
|
||||
const command_line::arg_descriptor<bool> arg_heavy_tests = {"heavy_tests", "Runs expensive tests (volume tests with real device)", false};
|
||||
const command_line::arg_descriptor<std::string> arg_chain_path = {"chain_path", "Path to the serialized blockchain, speeds up testing", ""};
|
||||
|
@ -138,7 +137,7 @@ 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", 12);
|
||||
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);
|
||||
auto sync_test = get_env_long("TEST_KI_SYNC", 1);
|
||||
MINFO("Test versions " << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")");
|
||||
|
@ -162,6 +161,10 @@ int main(int argc, char* argv[])
|
|||
// Transaction tests
|
||||
for(uint8_t hf=initial_hf; hf <= max_hf + 1; ++hf)
|
||||
{
|
||||
if (hf == 14) { // HF 14 is skipped.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hf > initial_hf || hf > max_hf)
|
||||
{
|
||||
daemon->stop_and_deinit();
|
||||
|
@ -201,12 +204,14 @@ int main(int argc, char* argv[])
|
|||
TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_1norm_2sub, core, trezor_base);
|
||||
TREZOR_COMMON_TEST_CASE(gen_trezor_2utxo_sub_acc_to_1norm_2sub, core, trezor_base);
|
||||
TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_7outs, core, trezor_base);
|
||||
TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_15outs, core, trezor_base);
|
||||
TREZOR_COMMON_TEST_CASE(wallet_api_tests, core, trezor_base);
|
||||
}
|
||||
|
||||
if (trezor_base.heavy_tests())
|
||||
{
|
||||
TREZOR_COMMON_TEST_CASE(gen_trezor_many_utxo, core, trezor_base);
|
||||
TREZOR_COMMON_TEST_CASE(gen_trezor_many_utxo_many_txo, core, trezor_base);
|
||||
}
|
||||
|
||||
core->deinit();
|
||||
|
@ -555,7 +560,7 @@ static void expand_tsx(cryptonote::transaction &tx)
|
|||
rv.p.MGs[n].II[0] = rct::ki2rct(boost::get<txin_to_key>(tx.vin[n]).k_image);
|
||||
}
|
||||
}
|
||||
else if (rv.type == rct::RCTTypeCLSAG)
|
||||
else if (rv.type == rct::RCTTypeCLSAG || rv.type == rct::RCTTypeBulletproofPlus)
|
||||
{
|
||||
if (!tx.pruned)
|
||||
{
|
||||
|
@ -1269,6 +1274,8 @@ void gen_trezor_base::set_hard_fork(uint8_t hf)
|
|||
rct_config({rct::RangeProofPaddedBulletproof, 2});
|
||||
} else if (hf == HF_VERSION_CLSAG){
|
||||
rct_config({rct::RangeProofPaddedBulletproof, 3});
|
||||
} else if (hf == HF_VERSION_BULLETPROOF_PLUS){
|
||||
rct_config({rct::RangeProofPaddedBulletproof, 4});
|
||||
} else {
|
||||
throw std::runtime_error("Unsupported HF");
|
||||
}
|
||||
|
@ -1655,7 +1662,7 @@ bool gen_trezor_1utxo::generate(std::vector<test_event_entry>& events)
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(boost::none, MK_COINS(1), -1, -1)
|
||||
|
@ -1671,7 +1678,7 @@ bool gen_trezor_1utxo_paymentid_short::generate(std::vector<test_event_entry>& e
|
|||
TREZOR_TEST_PREFIX();
|
||||
TREZOR_SKIP_IF_VERSION_LEQ(hw::trezor::pack_version(2, 0, 9));
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(boost::none, MK_COINS(1), -1, -1)
|
||||
|
@ -1688,7 +1695,7 @@ bool gen_trezor_1utxo_paymentid_short_integrated::generate(std::vector<test_even
|
|||
TREZOR_TEST_PREFIX();
|
||||
TREZOR_SKIP_IF_VERSION_LEQ(hw::trezor::pack_version(2, 0, 9));
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(boost::none, MK_COINS(1), -1, -1)
|
||||
|
@ -1705,7 +1712,7 @@ bool gen_trezor_4utxo::generate(std::vector<test_event_entry>& events)
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(4, MK_COINS(1), -1, -1)
|
||||
|
@ -1720,7 +1727,7 @@ bool gen_trezor_4utxo_acc1::generate(std::vector<test_event_entry>& events)
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 1)
|
||||
->compute_sources(4, MK_COINS(1), -1, -1)
|
||||
|
@ -1735,7 +1742,7 @@ bool gen_trezor_4utxo_to_sub::generate(std::vector<test_event_entry>& events)
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(4, MK_COINS(1), -1, -1)
|
||||
|
@ -1750,7 +1757,7 @@ bool gen_trezor_4utxo_to_2sub::generate(std::vector<test_event_entry>& events)
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(4, MK_COINS(1), -1, -1)
|
||||
|
@ -1766,7 +1773,7 @@ bool gen_trezor_4utxo_to_1norm_2sub::generate(std::vector<test_event_entry>& eve
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(4, MK_COINS(1), -1, -1)
|
||||
|
@ -1783,7 +1790,7 @@ bool gen_trezor_2utxo_sub_acc_to_1norm_2sub::generate(std::vector<test_event_ent
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources_to_sub_acc(2, MK_COINS(1) >> 2, -1, -1)
|
||||
|
@ -1800,7 +1807,7 @@ bool gen_trezor_4utxo_to_7outs::generate(std::vector<test_event_entry>& events)
|
|||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(4, MK_COINS(1), -1, -1)
|
||||
|
@ -1817,11 +1824,39 @@ bool gen_trezor_4utxo_to_7outs::generate(std::vector<test_event_entry>& events)
|
|||
TREZOR_TEST_SUFFIX();
|
||||
}
|
||||
|
||||
bool gen_trezor_4utxo_to_15outs::generate(std::vector<test_event_entry>& events)
|
||||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(4, MK_COINS(1), -1, -1)
|
||||
->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
|
||||
->add_destination(m_wl_eve.get(), false, 1000)
|
||||
->rct_config(m_rct_config)
|
||||
->build_tx();
|
||||
|
||||
TREZOR_TEST_SUFFIX();
|
||||
}
|
||||
|
||||
bool gen_trezor_many_utxo::generate(std::vector<test_event_entry>& events)
|
||||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(TREZOR_TEST_MIXIN)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(110, MK_COINS(1), -1, -1)
|
||||
|
@ -1832,6 +1867,35 @@ bool gen_trezor_many_utxo::generate(std::vector<test_event_entry>& events)
|
|||
TREZOR_TEST_SUFFIX();
|
||||
}
|
||||
|
||||
bool gen_trezor_many_utxo_many_txo::generate(std::vector<test_event_entry>& events)
|
||||
{
|
||||
TREZOR_TEST_PREFIX();
|
||||
t_builder->cur_height(num_blocks(events) - 1)
|
||||
->mixin(num_mixin())
|
||||
->fee(TREZOR_TEST_FEE)
|
||||
->from(m_wl_alice.get(), 0)
|
||||
->compute_sources(40, MK_COINS(1), -1, -1)
|
||||
->add_destination(m_eve_account, false, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({1, 4}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({2, 4}), true, 1000)
|
||||
->add_destination(m_wl_eve->get_subaddress({3, 4}), true, 1000)
|
||||
->rct_config(m_rct_config)
|
||||
->build_tx();
|
||||
|
||||
TREZOR_TEST_SUFFIX();
|
||||
}
|
||||
|
||||
void wallet_api_tests::init()
|
||||
{
|
||||
m_wallet_dir = boost::filesystem::unique_path();
|
||||
|
@ -1873,7 +1937,7 @@ bool wallet_api_tests::generate(std::vector<test_event_entry>& events)
|
|||
Monero::PendingTransaction * transaction = w->createTransaction(recepient_address,
|
||||
"",
|
||||
MK_COINS(10),
|
||||
TREZOR_TEST_MIXIN,
|
||||
num_mixin(),
|
||||
Monero::PendingTransaction::Priority_Medium,
|
||||
0,
|
||||
std::set<uint32_t>{});
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
#include "../core_tests/wallet_tools.h"
|
||||
|
||||
#define TREZOR_TEST_FEE 90000000000
|
||||
#define TREZOR_TEST_MIXIN 11
|
||||
#define TREZOR_TEST_CLSAG_MIXIN 11
|
||||
#define TREZOR_TEST_HF15_MIXIN 16
|
||||
#define TREZOR_TEST_MIXIN TREZOR_TEST_CLSAG_MIXIN
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
|
@ -93,6 +95,7 @@ public:
|
|||
bool heavy_tests() const { return m_heavy_tests; }
|
||||
void rct_config(rct::RCTConfig rct_config) { m_rct_config = rct_config; }
|
||||
uint8_t cur_hf() const { return m_hard_forks.size() > 0 ? m_hard_forks.back().first : 0; }
|
||||
size_t num_mixin() const { return m_top_hard_fork >= HF_VERSION_BULLETPROOF_PLUS ? TREZOR_TEST_HF15_MIXIN : TREZOR_TEST_CLSAG_MIXIN; }
|
||||
cryptonote::network_type nettype() const { return m_network_type; }
|
||||
std::shared_ptr<mock_daemon> daemon() const { return m_daemon; }
|
||||
void daemon(std::shared_ptr<mock_daemon> daemon){ m_daemon = std::move(daemon); }
|
||||
|
@ -306,12 +309,24 @@ public:
|
|||
bool generate(std::vector<test_event_entry>& events) override;
|
||||
};
|
||||
|
||||
class gen_trezor_4utxo_to_15outs : public gen_trezor_base
|
||||
{
|
||||
public:
|
||||
bool generate(std::vector<test_event_entry>& events) override;
|
||||
};
|
||||
|
||||
class gen_trezor_many_utxo : public gen_trezor_base
|
||||
{
|
||||
public:
|
||||
bool generate(std::vector<test_event_entry>& events) override;
|
||||
};
|
||||
|
||||
class gen_trezor_many_utxo_many_txo : public gen_trezor_base
|
||||
{
|
||||
public:
|
||||
bool generate(std::vector<test_event_entry>& events) override;
|
||||
};
|
||||
|
||||
// Wallet::API tests
|
||||
class wallet_api_tests : public gen_trezor_base
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue