fix(test): correct event-count assertion in genuine-transfer test - #437
Merged
mikewheeleer merged 1 commit intoJul 28, 2026
Conversation
env.events().all() reflects only the most recent contract invocation, not a running total across separate calls (consistent with every other event test in this file). The test compared post-transfer event count against a pre-transfer count captured after a *different* call (set_service_metadata), expecting accumulation that never happens, so it failed on every run regardless of contract behavior. Fixed to assert directly on this call's own event count.
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
test_transfer_service_ownership_genuine_transfer_emits_eventfails onmaintoday (confirmed independent of any feature change — reproduces on a clean checkout), which currently blocks every PR's CI regardless of what it touches.Root cause: the test calls
set_service_metadata(which itself emits ameta_setevent), capturesenv.events().all().len()ascount_before, then callstransfer_service_ownershipand asserts the new count equalscount_before + 1. Butenv.events().all()in the Soroban test harness reflects only the most recent contract invocation, not a running total across separate top-level calls — the same behavior every other event test in this file relies on (e.g.assert_usage_event_countre-checks a count of exactly1after each of several sequentialrecord_usagecalls, never accumulating). So aftertransfer_service_ownership,events_aftercontains only that call's ownowner_chgevent (len() == 1), nevercount_before + 1 == 2. The test was asserting behavior the test harness doesn't provide — not a contract bug.Fix: assert directly on the transfer call's own event count (
== 1) instead of comparing against a stale count from a prior, unrelated invocation. No contract code changed — test-only fix.Validation
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test -p escrow— 353 passed, 0 failed (previously 352 passed / 1 failed onmain)