Skip to content

Fix: [reporting] events.rs defines event types but no test verifies events are emitted correctly - #509

Merged
dultimateade merged 1 commit into
dultimateade:mainfrom
doradenise-jpg:simple/416
Nov 25, 2026
Merged

dultimateade merged 1 commit into
dultimateade:mainfrom
doradenise-jpg:simple/416

Conversation

@doradenise-jpg

Copy link
Copy Markdown

Closes #416

Issues

#416 [reporting] events.rs defines event types but no test verifies events are emitted correctly

Summary

contracts/reporting/src/events.rs defines event types for report lifecycle transitions. None of the test files assert that events are actually emitted on the correct entrypoints with the correct topic and data values.

Expected Behaviour

Add an event_emission.rs test file that uses env.events().all() to assert correct event emission for each lifecycle transition.

References

  • contracts/reporting/src/events.rs

Summary

The events.rs file currently only defines reporting_paused and reporting_unpaused events. The test should focus on these two events and verify idempotency (no event on repeated pause/unpause). For other lifecycle entrypoints, assert that no events are emitted (or update the test if events are added later). Use env.events().all() to capture events; note that in Soroban testutils, events are cleared between calls? Actually env.events().all() returns all events emitted so far in the test, so compare lengths before and after. Ensure to import soroban_sdk::testutils::Events as _ to use env.events().all(). Also import reporting::ReportingError for error assertions.

Changes

  • Create a new integration test file contracts/reporting/tests/event_emission.rs that verifies event emission for the reporting lifecycle. Use the helpers in tests/common.rs (register_and_init, report_data, report_hash, dispute_reason) to set up the contract. For pause/unpause: call client.pause_reporting(&admin) and assert env.events().all() contains exactly one event whose topics are (Symbol::new(&env, "reporting_paused"), admin) and data is (); call pause_reporting again and assert no new event is emitted (idempotent no-op); call unpause_reporting and assert a reporting_unpaused event with the admin topic and () data; call unpause_reporting again and assert no new event. For lifecycle entrypoints (submit_report, verify_report, dispute_report, resolve_dispute, update_report_status, delete_report): invoke each successfully and assert that no unexpected events are emitted by them (since events.rs only defines pause/unpause events, the test should document that these entrypoints currently emit no events, or assert the expected event if one is added). Also add negative cases: pause reporting, then call submit_report/verify_report/dispute_report/resolve_dispute/update_report_status/delete_report and assert they return Err(ReportingError::ReportingPaused) and that env.events().all() does not contain any new event from the failed call. Use env.events().all() before and after each call to compare event counts and contents. (contracts/reporting/tests/event_emission.rs)

Co-authored-by: Simple Agent <agent@simple.dev>
@drips-wave

drips-wave Bot commented Nov 25, 2026

Copy link
Copy Markdown

@doradenise-jpg Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@dultimateade
dultimateade merged commit 7dfece6 into dultimateade:main Nov 25, 2026
0 of 2 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.

[reporting] events.rs defines event types but no test verifies events are emitted correctly

2 participants