feat(governance): v0.0.30 — submit_proposal + cast_vote + finalize_proposal impl complete + mock runtime integration tests E2E (10 scenarios)
Phase 5.1 GOVERNANCE pallet REAL IMPL canonical. Full dispatchables canonical 7+6+5 step CHN-4 flow + storage assertions + tally + voting period enforcement + mock runtime + 10 integration tests E2E pattern v0.0.26 mirror. ## Real dispatchables canonical - submit_proposal (7 steps): ensure_signed + stake>=MIN + derive_id BLAKE2-256 + collision + build + insert + emit - cast_vote (6 steps): ensure_signed + get_proposal + status_voting + block<=end + !already_voted + update_tally + emit - finalize_proposal (5 steps): ensure_signed + get_proposal + status_voting + block>end + tally + status + emit ## Mock runtime + 10 integration tests E2E canonical - scenario_1: Submit happy path → stored + event - scenario_2: Stake insufficient → StakeInsufficient (CHN-4 5.3) - scenario_3: Vote Aye tally → yes_weight += 500 - scenario_4: Vote Nay tally → nay_weight += 750 - scenario_5: Double vote → AlreadyVoted - scenario_6: Finalize voting open → VotingPeriodOpen - scenario_7: Finalize Approved yes majority → status=Approved + event - scenario_8: Finalize Rejected nay majority → status=Rejected - scenario_9: Vote closed period → VotingPeriodClosed - scenario_10: Full lifecycle (submit → 3 votes → finalize Approved) ## Files - EDIT: crates/origin-chain-governance/src/lib.rs (real impl + MIN_PROPOSAL_STAKE + account_bytes helper) - NEW: crates/origin-chain-governance/src/mock.rs (85 LOC mock runtime) - NEW: crates/origin-chain-governance/src/tests_integration.rs (290 LOC, 10 tests) - EDIT: CHANGELOG.md (v0.0.30 entry) ## Verification - cargo test -p origin-chain-governance — 17 tests verde, 0 failures (10 integration + 5 standalone + 2 auto-generated) 🛠️ Phase 5.1 real impl canonical. Runtime API v0.0.31 next → Phase 5 FOUNDATION COMPLETE. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2a700ee6ca
commit
7c1425ff66
4 files changed
+559
-19
No files matched your search
@@ -6,6 +6,62 @@ by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.0.30] — 2026-05-25 — Phase 5.1 impl — Real submit_proposal + cast_vote + finalize_proposal + mock runtime integration tests E2E (10 scenarios)
|
||||
|
||||
**🛠️ Phase 5.1 GOVERNANCE pallet REAL IMPL canonical** — Full canonical
|
||||
dispatchables real impl + storage assertions + tally logic + voting period
|
||||
enforcement + mock runtime + 10 integration tests E2E pattern v0.0.26 mirror.
|
||||
|
||||
### Deliverables v0.0.30
|
||||
|
||||
**Real dispatchables canonical 7+6+5 step CHN-4 flow**:
|
||||
|
||||
`submit_proposal` (7 steps): ensure_signed + validate stake >= MIN_PROPOSAL_STAKE (1,000 OGC) + derive_proposal_id BLAKE2-256 + collision check + build Proposal + insert + emit ProposalSubmitted
|
||||
|
||||
`cast_vote` (6 steps): ensure_signed + get_proposal + status==Voting + block.number<=end_block + !already_voted + update tally + insert Votes + emit VoteCast
|
||||
|
||||
`finalize_proposal` (5 steps): ensure_signed + get_proposal + status==Voting + block.number>end_block + tally final_status (yes_weight > nay_weight → Approved, else Rejected) + insert + emit ProposalFinalized
|
||||
|
||||
**Mock runtime canonical (NEW file)**:
|
||||
- `crates/origin-chain-governance/src/mock.rs` — 85 LOC pattern v0.0.26 mirror
|
||||
- `construct_runtime!`: `System` + `Governance`
|
||||
- Helpers: `alice/bob/charlie_origin + _account` + `run_to_block` for voting period testing
|
||||
|
||||
**Integration tests canonical E2E (NEW file)**:
|
||||
- `crates/origin-chain-governance/src/tests_integration.rs` — 290 LOC, **10 tests verde canonical**
|
||||
|
||||
**10 integration tests CHN-4 flow canonical**:
|
||||
|
||||
| # | Scenario | Expected |
|
||||
|---|----------|----------|
|
||||
| 1 | Submit proposal happy path | ✅ Stored + event emitted |
|
||||
| 2 | Stake insufficient | ❌ StakeInsufficient (CHN-4 5.3) |
|
||||
| 3 | Vote Aye tally updated | ✅ yes_weight += 500 |
|
||||
| 4 | Vote Nay tally updated | ✅ nay_weight += 750 |
|
||||
| 5 | Double vote same account | ❌ AlreadyVoted |
|
||||
| 6 | Finalize voting open | ❌ VotingPeriodOpen |
|
||||
| 7 | Finalize Approved (yes majority) | ✅ status=Approved + event |
|
||||
| 8 | Finalize Rejected (nay majority) | ✅ status=Rejected |
|
||||
| 9 | Vote closed period | ❌ VotingPeriodClosed |
|
||||
| 10 | Full lifecycle walkthrough | ✅ submit → 3 votes → finalize Approved |
|
||||
|
||||
**Helper canonical**:
|
||||
- `MIN_PROPOSAL_STAKE = 1_000 × 10^18` constant per CHN-4 5.3
|
||||
- `account_bytes<T>` private helper convert T::AccountId → [u8; 32]
|
||||
|
||||
### Verification end-to-end canonical
|
||||
|
||||
- ✅ `cargo test -p origin-chain-governance` — **17 tests verde, 0 failures**:
|
||||
- 10 integration tests E2E
|
||||
- 5 standalone tests (compiles + derive_proposal_id deterministic + variants + re-export)
|
||||
- 2 auto-generated (mock genesis + runtime integrity)
|
||||
|
||||
### Roadmap canonical post-v0.0.30
|
||||
|
||||
| Version | Trigger |
|
||||
|---------|---------|
|
||||
| **v0.0.31** | **Runtime API canonical GovernanceApi impl en runtime → Phase 5.1 FOUNDATION COMPLETE** |
|
||||
|
||||
## [0.0.29] — 2026-05-25 — Phase 5.1 wired — Governance pallet runtime composition Index 10
|
||||
|
||||
**🔌 Phase 5.1 GOVERNANCE pallet WIRED runtime composition canonical** —
|
||||
|
||||
Reference in new issue
Block a user