Add settlement state transition tests (issue #254) - #326
Open
d3vobed wants to merge 1 commit into
Open
Conversation
…oll#254) Add a tests/settlement crate that exercises the canonical PayrollRunState machine (is_allowed_payroll_state_transition_internal) across the full 10x10 transition matrix, plus terminal/retryable semantics and the admin-only transition_payroll_run_state authorization guard. - docs/state-machine.md documents the settlement phase -> state mapping (pending->Submitted, executing->Confirming, settled->Completed, failed->Failed, cancelled->Cancelled). - fixtures/state-machine/settlement-state-machine.json captures the same matrix for external tooling. Minimal build fixes to contracts/payroll so the contract compiles (the upstream main was broken at HEAD): add the missing symbol_short import, add the DataKey::AllowedAsset variant referenced by set/is_asset_allowed, remove a stale duplicate cancel_payroll_run, and drop an unused helper. Note: the upstream workspace currently fails cargo clippy --workspace -D warnings due to unrelated breakage (audit_module missing initialize, used by tests/migrations). This PR is scoped to the settlement tests; that pre-existing breakage is out of scope. Closes zkpayroll#254
|
@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 dedicated
tests/settlementcrate that pins down the settlement state machine defined byPayrollRunState/is_allowed_payroll_state_transition_internalincontracts/payroll/src/lib.rs.is_allowed_payroll_state_transition_internalrules, and every disallowed one is rejected predictably (no silent drift from the documented matrix).is_payroll_state_terminalandis_payroll_state_retryableare verified — onlyFailedis retryable;Completed/Cancelledare terminal and immutable.transition_payroll_run_stateis admin-only; a non-admin call panics withUnauthorized.pending(Submitted) and settling reachessettled(Completed).Also adds
docs/settlement-state-machine.mdandfixtures/state-machine/settlement-state-machine.jsondocumenting the settlement phase → concrete state mapping (pending→Submitted,executing→Confirming,settled→Completed,failed→Failed,cancelled→Cancelled).This supersedes the previously opened PR #324 (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 keeps thesettlement_state_testscrate clippy-clean and all 14 of its tests passing.Closes #254