test: complete revoke_attestation coverage (happy path, auth, unknown hash, history interaction) - #298
Open
Mimah97 wants to merge 4 commits into
Open
Conversation
…on get_attestation_history (Lafiya-xyz#168)
|
@Mimah97 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the largest test-coverage gap in the repo:
revoke_attestationhad zero unit tests despite being a public, admin-facing entry point. This PR adds happy-path coverage, non-admin authorization-rejection coverage, and two investigative tests documentingrevoke_attestation's actual current behavior for an unknown hash and its interaction withget_attestation_history— surfacing a bug without silently altering contract logic to paper over it.Changes
#165 — Add revoke_attestation happy-path unit test
get_attestationreturnsNoneafterward.#166 — Add revoke_attestation non-admin authorization test
#167 — Add test for revoking an attestation that was never made
revoke_attestationreturns for an unknown hash.revoke_attestationreturnsError::NotInitializedwhen called with an unknown/never-attested hash, but should returnError::AttestationNotFound(line 371 in lib.rs:.ok_or(Error::NotInitialized)?). This is a bug worth a follow-up fix.#168 — Add test asserting revoke_attestation clears get_attestation_history too
get_attestationandget_attestation_historyare cleared.revoke_attestationcorrectly clears the full history — it removes all attestation entries (lines 386–395) and removes the sequence/count keys, soget_attestation_historyreturns an empty Vec after revocation. Behavior confirmed correct.Notes
lib.rs's actual current logic.revoke_attestationreturns the wrong error variant for unknown hashes. This should be fixed in a follow-up; the test documents the current (incorrect) behavior per the issue's own instruction not to silently change contract logic.Closes #165, Closes #166, Closes #167, Closes #168