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

Implement MembershipNotFound Error Handling #510

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

JiyaGupta-cs
Copy link
Contributor

Fixes #291

Description

This PR enhances the membership management functionality in the pallet-network-membership by introducing tests that validate the behavior of the system when interacting with non-existent memberships. The following tests have been added:

Test for Revoking Non-Existent Membership:

Implemented the test_revoke_membership_non_existent to ensure that attempting to revoke a membership for an account that does not exist correctly raises the MembershipNotFound error.
This test checks that the member count remains unchanged when the revoke operation is attempted on a non-existent account.
Test for Checking Non-Existent Membership:

Added test_check_membership_non_existent to verify that the system correctly identifies a non-existent account as not being a member. This ensures the integrity of the membership verification process.
Test for Auto Expiration of Non-Existent Membership:

Included test_auto_expire_non_existent_membership to confirm that a non-existent account does not trigger any expiration logic. This test advances the block number to simulate the passage of time and checks that the account remains non-existent.

Testing

Tested using cargo test -p pallet-network-membership test

Screenshots

image

run_to_block(1);

// Check if a non-existent account is a member
assert!(!NetworkMembership::is_member(&AccountId::new([99u8; 32])));
Copy link
Member

Choose a reason for hiding this comment

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

Use assert_err to keep consistency, and can check which error code.


// Check that a non-existent account cannot expire
run_to_block(10); // Advance time beyond the expiration period
assert!(!NetworkMembership::is_member(&AccountId::new([99u8; 32]))); // Should still be false
Copy link
Member

Choose a reason for hiding this comment

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

Use this as well.

@JiyaGupta-cs
Copy link
Contributor Author

@vatsa287 I have made the changes

@JiyaGupta-cs
Copy link
Contributor Author

@vatsa287 Please review

@JiyaGupta-cs
Copy link
Contributor Author

@vatsa287 can you pls review this

Copy link
Member

@vatsa287 vatsa287 left a comment

Choose a reason for hiding this comment

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

LGTM

@vatsa287
Copy link
Member

@amarts

The tests were not running for this PR for some reason, I had to checkout, rebase & force-push for it to run. Errors are below.

[Error](https://github.com/dhiway/cord/actions/runs/11050497895/workflow)
An unexpected error has occurred and we've been automatically notified. Errors are sometimes temporary, so please try again.

If the problem persists, please check whether the Actions service is operating normally at https://githubstatus.com/. If not, please try again once the outage has been resolved.

Should you need to contact Support, please visit https://support.github.com/contact and include request ID: F998:13D251:57E6A5:5EC318:67129E93

@vatsa287 vatsa287 requested a review from amarts October 19, 2024 05:33
@amarts amarts merged commit c134755 into dhiway:develop Oct 21, 2024
3 checks passed
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.

[C4GT] Network-Membership: Add tests for MembershipNotFound
3 participants