Add employee status transition tests (issue #249) - #327
Open
d3vobed wants to merge 1 commit into
Open
Conversation
…l#249) Add a dedicated integration suite, contract enforcement, and documentation for the employee status lifecycle. Contract changes - payment_executor: add PaymentError::EmployeeIneligible and gate execute_payment / execute_batch_payroll on payroll_registry::is_eligible. Inactive, incomplete, removed, and unregistered employees are now blocked before proof verification or any token transfer. - payroll_registry: remove_employee now also clears the EmpStatus key so a removed employee reads back as Incomplete and can never be eligible again. Tests (tests/employees/) - status_transitions.rs: all six allowed transitions, idempotent same-status no-ops, unauthorized / unknown company / unknown employee rejections, removal semantics, and lifecycle event payloads. - payroll_eligibility.rs: active employees are paid; inactive, incomplete, removed, and unregistered addresses are blocked with no transfer; reactivation and record correction restore payability; batches reject ineligible entries. Docs - docs/employees.md: status table, allowed/blocked transition matrices, payroll enforcement, and test coverage map. - fixtures/state-machine/employee-status-machine.json: machine-readable mirror. Closes zkpayroll#249
|
@d3vobed this PR currently has merge conflicts. Please resolve the conflicts before it can be merged automatically. |
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
Adds a
tests/employeescrate that pins down the employee status lifecycle and its interaction with payroll execution, per issue #249.status_transitions.rsdrives the documentedEmpStatusmachine (Incomplete→Active→Inactive/Removed, with theRemovedterminal cleanup) and asserts the contract rejects illegal transitions.payroll_eligibility.rsverifies thatpayment_executor::execute_payment/execute_batch_payrollblock employees that are notActive(EmployeeIneligible), and that the registryremove_employeeclears the stored status.payment_executor: addedEmployeeIneligibleerror and anis_eligiblecheck before any transfer.payroll_registry:remove_employeenow clearsEmpStatus.Also adds
docs/employees.mdandfixtures/state-machine/employee-status-machine.json.This supersedes the previously opened PR #322 (which targeted
main; the repo requires PRs againstdev).Note on CI
The upstream workspace currently fails
cargo clippy --workspace --all-targets -D warningsdue to unrelated pre-existing breakage (audit_moduleis missing theinitializemethod required bytests/migrations). That is out of scope for this issue; this PR keepsemployee_status_testsclippy-clean with all 26 tests passing.Closes #249