Skip to content

Conversation

@mbjorkqvist
Copy link
Collaborator

Test upgrade and reinstall with the currently installed version, and the latest icrc-ledger-suite-2025-10-27 (pre-)release version of the index canister.

@mbjorkqvist mbjorkqvist marked this pull request as ready for review October 31, 2025 12:21
@mbjorkqvist mbjorkqvist requested a review from a team as a code owner October 31, 2025 12:21
Comment on lines 7804 to 7805
let from_balance = self.expected_ledger_balances.entry(from).or_insert(0);
*from_balance -= amount_with_fee;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't or_insert(0) a bit weird here because the next line would then panic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree! I reworked the code for adding/subtracting to/from the expected balances, hopefully it's more solid and clearer now.

Comment on lines 7810 to 7811
let from_index_balance = self.expected_index_balances.entry(from).or_insert(0);
*from_index_balance -= amount_with_fee;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

index_version: IndexVersion,
) {
env.deposit(account1, DEPOSIT_AMOUNT_ACCOUNT_1 + fee, None);
balances_verifier.record_deposit(env, account1, DEPOSIT_AMOUNT_ACCOUNT_1 + fee);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why isn't the deposit value simply DEPOSIT_AMOUNT_ACCOUNT_1 (i.e., why is the fee added on top)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, it's not really necessary. I simplified this as suggested.

reinstalled_balances_verifier.sync_and_verify_index(&env);

perform_transactions(&mut env);
perform_transactions(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this function called at the end of the test function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The sync_and_verify_index checks that we didn't e.g., lose/corrupt any balances as part of the upgrade/reinstall, and the perform_transactions calls afterward verifies that the upgraded/reinstalled index still pulls transactions from the ledger and updates the balances correctly. If we e.g., introduced a bug that would fail to start the index timer for retrieving ledger transactions in certain scenarios, or corrupted balances when processing new transactions, then we might only catch it in perform_transactions.

@mbjorkqvist mbjorkqvist requested a review from THLO November 11, 2025 17:34
@mbjorkqvist
Copy link
Collaborator Author

Thanks for the review, @THLO! I believe I've addressed all your comments, could you please take another look?

@mbjorkqvist mbjorkqvist merged commit dbebe79 into main Nov 17, 2025
5 of 6 checks passed
@mbjorkqvist mbjorkqvist deleted the mathias-FI-1857-test-with-index-that-handles-burn-and-mint-fees branch November 17, 2025 13:00
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