forked from lthn/blockchain
wallet: set_pos_utxo_count_limits_for_defragmentation_tx() added, coretests: packing_outputs_on_pos_minting_wallet, pos_minting_tx_packing fixed
This commit is contained in:
parent
98d124860c
commit
d933a22154
4 changed files with 12 additions and 19 deletions
|
|
@ -174,15 +174,13 @@ bool wallet2::set_core_proxy(const std::shared_ptr<i_core_proxy>& proxy)
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::set_pos_utxo_count_limits_for_defragmentation_tx(uint64_t min_outs, uint64_t max_outs)
|
||||
void wallet2::set_defragmentation_tx_settings(bool enabled, uint64_t min_outs, uint64_t max_outs, uint64_t max_allowed_amount, size_t decoys_count)
|
||||
{
|
||||
m_min_utxo_count_for_defragmentation_tx = min_outs;
|
||||
m_max_utxo_count_for_defragmentation_tx = max_outs;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::set_pos_decoys_count_for_defragmentation_tx(size_t decoys_count)
|
||||
{
|
||||
m_decoys_count_for_defragmentation_tx = decoys_count;
|
||||
m_defragmentation_tx_enabled = enabled;
|
||||
m_min_utxo_count_for_defragmentation_tx = min_outs;
|
||||
m_max_utxo_count_for_defragmentation_tx = max_outs;
|
||||
m_max_allowed_output_amount_for_defragmentation_tx = max_allowed_amount;
|
||||
m_decoys_count_for_defragmentation_tx = decoys_count;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<i_core_proxy> wallet2::get_core_proxy()
|
||||
|
|
|
|||
|
|
@ -402,8 +402,7 @@ namespace tools
|
|||
bool daemon_get_asset_info(const crypto::public_key& asset_id, currency::asset_descriptor_base& adb);
|
||||
const std::unordered_map<crypto::public_key, wallet_own_asset_context>& get_own_assets() const { return m_own_asset_descriptors; }
|
||||
bool set_core_proxy(const std::shared_ptr<i_core_proxy>& proxy);
|
||||
void set_pos_utxo_count_limits_for_defragmentation_tx(uint64_t min_outs, uint64_t max_outs); // don't create UTXO defrag. tx if there are less than 'min_outs' outs; don't put more than 'max_outs' outs
|
||||
void set_pos_decoys_count_for_defragmentation_tx(size_t decoys_count);
|
||||
void set_defragmentation_tx_settings(bool enabled, uint64_t min_outs, uint64_t max_outs, uint64_t max_allowed_amount = CURRENCY_BLOCK_REWARD, size_t decoys_count = SIZE_MAX);
|
||||
void set_pos_required_decoys_count(size_t v) { m_required_decoys_count = v; }
|
||||
void set_minimum_height(uint64_t h);
|
||||
std::shared_ptr<i_core_proxy> get_core_proxy();
|
||||
|
|
|
|||
|
|
@ -1085,7 +1085,7 @@ bool pos_minting_tx_packing::c1(currency::core& c, size_t ev_index, const std::v
|
|||
m_alice_start_amount + CURRENCY_BLOCK_REWARD * m_pos_mint_packing_size // unlocked
|
||||
), false, "");
|
||||
|
||||
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(m_pos_mint_packing_size + 1, m_pos_mint_packing_size + 1); // +1 because previous implementation () had an error with this limit
|
||||
alice_wlt->set_defragmentation_tx_settings(true, m_pos_mint_packing_size + 1, m_pos_mint_packing_size + 1); // +1 because previous implementation () had an error with this limit
|
||||
|
||||
// no coinbase tx outputs should be packed
|
||||
r = alice_wlt->try_mint_pos();
|
||||
|
|
|
|||
|
|
@ -3440,8 +3440,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
|
|||
|
||||
// 1. Try to defragment the same UTXO that is used for staking
|
||||
// (Bob has two: one UTXO is for staking, other is being defragmented)
|
||||
bob_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(1, 10);
|
||||
bob_wlt->set_pos_decoys_count_for_defragmentation_tx(0);
|
||||
bob_wlt->set_defragmentation_tx_settings(true, 1, 10, CURRENCY_BLOCK_REWARD, 0);
|
||||
bob_wlt->try_mint_pos();
|
||||
|
||||
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 3, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());
|
||||
|
|
@ -3453,8 +3452,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
|
|||
|
||||
|
||||
// 2. Try to mine a PoS block and defragment some of UTXO
|
||||
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(2, 2);
|
||||
alice_wlt->set_pos_decoys_count_for_defragmentation_tx(0);
|
||||
alice_wlt->set_defragmentation_tx_settings(true, 2, 2, CURRENCY_BLOCK_REWARD, 0);
|
||||
alice_wlt->try_mint_pos();
|
||||
|
||||
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 4, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());
|
||||
|
|
@ -3467,8 +3465,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
|
|||
|
||||
// 3. Try to mine a PoS block and defragment with huge decoy set. Make sure block is mined successfully without a defragmentation tx
|
||||
// Alice has one UTXO
|
||||
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(1, 1);
|
||||
alice_wlt->set_pos_decoys_count_for_defragmentation_tx(80);
|
||||
alice_wlt->set_defragmentation_tx_settings(true, 1, 1, CURRENCY_BLOCK_REWARD, 80);
|
||||
alice_wlt->try_mint_pos();
|
||||
|
||||
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 5, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());
|
||||
|
|
@ -3480,8 +3477,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
|
|||
|
||||
|
||||
// 4. Finally mine a PoS and defragment the last one unlocked UTXO
|
||||
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(1, 1);
|
||||
alice_wlt->set_pos_decoys_count_for_defragmentation_tx(0);
|
||||
alice_wlt->set_defragmentation_tx_settings(true, 1, 1, CURRENCY_BLOCK_REWARD, 0);
|
||||
alice_wlt->try_mint_pos();
|
||||
|
||||
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 6, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue