Skip to content

fix(test): correct cross-call event-count assumption in ownership-transfer test - #315

Open
thlpkee20-wq wants to merge 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:fix/transfer-ownership-event-count-test
Open

fix(test): correct cross-call event-count assumption in ownership-transfer test#315
thlpkee20-wq wants to merge 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:fix/transfer-ownership-event-count-test

Conversation

@thlpkee20-wq

Copy link
Copy Markdown
Contributor

Summary

test_transfer_service_ownership_genuine_transfer_emits_event fails on
current main (confirmed against a clean checkout, unrelated to any of
my other in-flight PRs on this repo). It compares
env.events().all().len() before and after transfer_service_ownership,
assuming the event log accumulates across separate top-level client
calls (set_service_metadata then transfer_service_ownership). In
this soroban-sdk version, env.events().all() is scoped to the
current invocation, so the delta assertion always fails even though the
contract correctly emits owner_chg on every genuine transfer (the
event is there — the test's own subsequent assertions on
events_after.last() already prove that).

Fix

Matched the established, working pattern used elsewhere in this file
(e.g. test_settle_emits_settled_event_with_payload): assert the event
log is non-empty and check the most recent publish's topic/payload,
instead of a before/after delta.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test — 336/336 passing (was 335 passed, 1 failed before
    this fix)

This is a test-only fix, not tied to a specific GrantFox issue — it
unblocks a clean cargo test run for every other PR touching this repo.

…nsfer test

test_transfer_service_ownership_genuine_transfer_emits_event compared
env.events().all().len() before and after transfer_service_ownership,
assuming the event log accumulates across separate top-level client
calls. In this soroban-sdk version, env.events().all() is scoped to the
current invocation, so the delta assertion always failed even though
the contract correctly emits owner_chg on every genuine transfer. Fixed
to match the established, working pattern used elsewhere in this file
(e.g. test_settle_emits_settled_event_with_payload): assert the event
log is non-empty and check the most recent publish's topic/payload.
@mikewheeleer

Copy link
Copy Markdown
Contributor

thanks @thlpkee20-wq! please add a Closes #<issue> line to the PR description so it links to the issue it resolves — then we can review and merge. 🙏

@mikewheeleer

Copy link
Copy Markdown
Contributor

thanks @thlpkee20-wq! please add a Closes #<issue> line to the PR description so it links to the issue it resolves — then we can review and merge. 🙏

1 similar comment
@mikewheeleer

Copy link
Copy Markdown
Contributor

thanks @thlpkee20-wq! please add a Closes #<issue> line to the PR description so it links to the issue it resolves — then we can review and merge. 🙏

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