-
Notifications
You must be signed in to change notification settings - Fork 112
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
Conversation
run_to_block(1); | ||
|
||
// Check if a non-existent account is a member | ||
assert!(!NetworkMembership::is_member(&AccountId::new([99u8; 32]))); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use this as well.
@vatsa287 I have made the changes |
@vatsa287 Please review |
@vatsa287 can you pls review this |
Signed-off-by: Shreevatsa N <[email protected]>
c663181
to
e00c8f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
|
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