test: add task expiration detection coverage - #176
Merged
Abd-Standard merged 1 commit intoAug 30, 2026
Conversation
Add a reusable expiration-checking function with comprehensive tests to detect tasks that have passed their deadline. Changes: - Add expiration.rs module with is_task_expired() helper function - Refactor submission.rs to use the expiration helper consistently - Add 7 unit tests for expiration edge cases (past, future, boundary) - Add 4 integration tests verifying expiration in submission flow The helper uses the existing Task.deadline field and compares it with the current ledger timestamp. A task is expired when current_time > deadline. Boundary behavior: Tasks at exactly the deadline timestamp are NOT considered expired (deadline is inclusive). This follows the existing convention where env.ledger().timestamp() > task.deadline triggers TaskExpired error. All 38 tests pass, including existing regression tests.
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.
Closes #155
Add a reusable expiration-checking function with comprehensive tests to detect tasks that have passed their deadline.
Changes:
The helper uses the existing Task.deadline field and compares it with the current ledger timestamp. A task is expired when current_time > deadline.
Boundary behavior: Tasks at exactly the deadline timestamp are NOT considered expired (deadline is inclusive). This follows the existing convention where env.ledger().timestamp() > task.deadline triggers TaskExpired error.
All 38 tests pass, including existing regression test
Checklist
General
mainfeat: add reputation system)Closes #<issue-number>)Testing
cargo testfor contracts,npm run buildfor frontend)cargo clippy -- -D warnings)Documentation
///doc comments (Rust) or JSDoc (TypeScript)CONTRIBUTING.md,README.md, or other docs updated if neededCONTRACT_API.mdupdated if contract interface changedCode Quality
cargo fmt/ ESLint)anytypes introduced in TypeScriptSmart Contract (if applicable)
require_auth()called on all state-changing operationsFrontend (if applicable)