Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 change update_x_payment_stream functions to not error out if user is insolvent #273

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TDemeco
Copy link
Contributor

@TDemeco TDemeco commented Nov 26, 2024

This PR changes the logic of updating payment streams. Now, instead of erroring out when the user of the payment stream is insolvent, we charge the payment stream and since the function that does that already manages insolvent users, the payment stream would get charged for its debt and deleted.

@@ -7393,6 +7242,149 @@ mod delete_file_and_pending_deletions_tests {
);
});
}

#[test]
fn delete_file_expired_pending_file_deletion_request_with_insolvent_user() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice test!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! It's just the previous test with some changes hehe

);

// Assert that the payment stream was correctly deleted since the user is without funds
assert!(pallet_payment_streams::FixedRatePaymentStreams::<Test>::get(msp_id, owner_account_id.clone()).is_none());
Copy link
Contributor

Choose a reason for hiding this comment

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

how did the payment stream get automatically deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is that when a provider tries to charge a user that is deemed as without funds, the manage_user_without_funds logic gets executed, which basically charges the debt of the payment stream from the user deposit and then clears it. After this, the provider is free to delete without penalty any files from the user since the runtime knows that it is not getting paid for them

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.

2 participants