Skip to content

feat(governance): add event emission coverage and validation tests (#…#601

Merged
Vera3289 merged 2 commits into
Vera3289:mainfrom
Philzwrist07:issue-482-event-coverage
Jun 27, 2026
Merged

feat(governance): add event emission coverage and validation tests (#…#601
Vera3289 merged 2 commits into
Vera3289:mainfrom
Philzwrist07:issue-482-event-coverage

Conversation

@Philzwrist07

@Philzwrist07 Philzwrist07 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #482 Fixes a bug where execute() and cancel() emitted the generic proposal_finalised event, making
them indistinguishable from a finalisation on the event stream. Adds dedicated events for every
state transition and validates all event payloads in tests.

Changes

events.rs

  • Added proposal_executed (topic: "executed") — emits the admin address
  • Added proposal_cancelled (topic: "cancelled") — emits the admin address

lib.rs

  • execute() now emits proposal_executed instead of proposal_finalised
  • cancel() now emits proposal_cancelled instead of proposal_finalised

test.rs

  • test_event_proposal_created — validates "created" topic and proposer payload
  • test_event_vote_cast — validates "vote" topic, voter, direction, and weight
  • test_event_proposal_finalised — validates "final" topic and Passed status
  • test_event_proposal_executed — validates "executed" topic and admin payload
  • test_event_proposal_cancelled — validates "cancelled" topic and admin payload

docs/events.md (new)

  • Full event schema for all 6 event types (topics + data types + JSON examples)
  • Off-chain indexer integration guide using Stellar RPC getEvents
  • History reconstruction approach — no storage reads required
  • Schema stability policy (event schema is a public API)

Acceptance Criteria

┌───────────┬────────┐
│ Criterion │ Status │
├───────────────────────────────────────────────────────────────────────┼────────┤
│ Proposal creation, voting, finalisation, and cancellation emit events │ ✅ │
├───────────────────────────────────────────────────────────────────────┼────────┤
│ Event contents are validated in tests │ ✅ │
├───────────────────────────────────────────────────────────────────────┼───────────────────┤
│ Off-chain indexing needs are documented │ ✅ docs/events.md │
├───────────────────────────────────────────────────────────────────────┼───────────────────┤
│ No silent state changes without events │ ✅ │
└───────────────────────────────────────────────────────────────────────┴────────────────

Philzwrist07 and others added 2 commits June 26, 2026 21:23
…era3289#482)

- Add dedicated proposal_executed and proposal_cancelled event functions
  in events.rs, replacing the incorrect reuse of proposal_finalised for
  execute() and cancel() actions
- Wire new events in lib.rs execute() and cancel()
- Add 5 event-validation tests covering all state-changing actions:
  test_event_proposal_created, test_event_vote_cast,
  test_event_proposal_finalised, test_event_proposal_executed,
  test_event_proposal_cancelled
- Add docs/events.md with full event schema, off-chain indexer integration
  guide, and schema stability policy

Closes Vera3289#482
@Vera3289 Vera3289 merged commit 61367a1 into Vera3289:main Jun 27, 2026
3 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart Contracts: Add event emission and validation coverage

2 participants