Skip to content

Conversation

@rflechtner
Copy link
Contributor

@rflechtner rflechtner commented Nov 7, 2024

re/ KILTProtocol/ticket#3671

Adds unit tests for burning and minting. Tests document EXPECTED behaviour, which currently differs from the actual behaviour in a lot of places.

Currently failing:

  • mint_into::mint_first_coin

    • Fails due to flooring of amount_to_mint during conversion to float; may be fixed by proper rounding, or ignored by changing the assertion to an assert_eq_error_rate! with error 1.
  • mint_into::mint_in_refunding_pool

    • Should give PoolNotLive error but yields NoPermission
  • mint_into::mint_large_quantity

    • Fails because we overflow when converting large amounts of collateral back to a u128. Can be fixed with conversion logic similar to the conversion to fixed.
  • mint_into::multiple_mints_vs_combined_mint

    • fails due to imprecision - not clear if this can be resolved
  • burn_into::burn_in_refunding_pool

    • Should give PoolNotLive error but yields NoPermission
  • burn_into::burn_large_quantity

    • Fails because we overflow when converting large amounts of collateral back to a u128. Can be fixed.
  • burn_into::multiple_burns_vs_combined_burn

  • just like multiple vs single mint fails due to imprecision - not clear if this can be resolved

  • burn_into::multiple_mints_vs_combined_burn

    • Tries to burn more than was minted, yields FundsUnavailable. Must be fixed by improving rounding!
  • burn_into::burn_with_frozen_balance

    • Fails because it tries to re-freeze the account after draining it
  • burn_into::burn_to_other

    • Funds are burnt from the beneficiary instead of the caller, which is wrong

Checklist:

  • I have verified that the code works
    • No panics! (checked arithmetic ops, no indexing array[3] use get(3), ...)
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)
    • Either PR or Ticket to update the Docs
    • Link the PR/Ticket here

@rflechtner rflechtner requested a review from Ad96el November 12, 2024 13:22
@rflechtner rflechtner marked this pull request as ready for review November 20, 2024 09:33
@rflechtner rflechtner mentioned this pull request Nov 20, 2024
6 tasks
@rflechtner rflechtner mentioned this pull request Nov 21, 2024
6 tasks
@rflechtner rflechtner requested a review from Ad96el November 25, 2024 12:27
Copy link
Contributor

@Ad96el Ad96el left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rflechtner rflechtner merged commit 213d030 into pallet_bonded_coins Nov 25, 2024
2 of 7 checks passed
@rflechtner rflechtner deleted the rf-test-mint-and-burn branch November 25, 2024 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants