Skip to content

fix(test): correct event-count assertion in genuine-transfer test - #437

Merged
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
Jagadeeshftw:fix/genuine-transfer-event-count-assertion
Jul 28, 2026
Merged

fix(test): correct event-count assertion in genuine-transfer test#437
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
Jagadeeshftw:fix/genuine-transfer-event-count-assertion

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

test_transfer_service_ownership_genuine_transfer_emits_event fails on main today (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 a meta_set event), captures env.events().all().len() as count_before, then calls transfer_service_ownership and asserts the new count equals count_before + 1. But env.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_count re-checks a count of exactly 1 after each of several sequential record_usage calls, never accumulating). So after transfer_service_ownership, events_after contains only that call's own owner_chg event (len() == 1), never count_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 -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test -p escrow353 passed, 0 failed (previously 352 passed / 1 failed on main)

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.
@mikewheeleer
mikewheeleer merged commit b946ca4 into Agentpay-Org:main Jul 28, 2026
1 check 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.

2 participants