Skip to content

fix(tests): use correct topic names for account pay_fee events#1995

Closed
0xPepeSilvia wants to merge 2 commits intotari-project:developmentfrom
0xPepeSilvia:fix/event-topic-assertion-1975
Closed

fix(tests): use correct topic names for account pay_fee events#1995
0xPepeSilvia wants to merge 2 commits intotari-project:developmentfrom
0xPepeSilvia:fix/event-topic-assertion-1975

Conversation

@0xPepeSilvia
Copy link
Copy Markdown

@0xPepeSilvia 0xPepeSilvia commented Apr 10, 2026

Description

Fixes #1975.

The feature file integration_tests/tests/features/indexer.feature was asserting that the indexer saw std.vault.pay_fee topics for the account component. The step definition indexer_scans_network_events filters events by substate_id == component_address, but the runtime emits std.vault.pay_fee with substate_id = vault_id (see crates/engine/src/runtime/impl.rs:1784-1790). The filter therefore can never match, and the assertion fails every run.

The Account.pay_fee custom event (emitted via emit_event in crates/template_builtin/templates/account/src/lib.rs:178) is recorded with the account component's substate id (see the custom emit_event path in crates/engine/src/runtime/impl.rs:466) and does match the filter.

Fix

  1. Revert the topic names in the three affected scenarios from std.vault.pay_fee back to Account.pay_fee.
  2. Keep the 30-second retry loop added in an earlier commit on this branch as defence-in-depth against indexer catch-up timing.

Why the previous attempt on this branch was insufficient

The first commit on this branch (fix(tests): retry event topic assertion until indexer has scanned) wrapped the assertion in a retry. That masks indexer timing flakiness but does not address the root cause: with the filter looking for component-scoped events and the expected topics being vault-scoped, the retry simply sleeps until the timeout. The topic-name revert is the actual fix.

Verification

  • Traced the event emission paths in crates/engine/src/runtime/impl.rs for both emit_std_event (line 256) and custom emit_event (line 466).
  • Confirmed Account.pay_fee is still emitted by the account template (unchanged).
  • cargo check -p tari_ootle_wallet_storage_sqlite and -p tari_ootle_walletd both clean (touching unrelated crates just to spot-check).

The indexer_scans_network_events step queried getEvents once with no
retry. If the indexer hadn't finished scanning/indexing events yet, the
query returned an incomplete set and the assertion failed immediately.

Now retries for up to 30 seconds, checking that all expected topics are
present before asserting. On timeout, still reports the specific
missing topic for debugging.

Closes tari-project#1975

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a retry mechanism to the indexer_scans_network_events integration test. The updated logic polls the GraphQL indexer for up to 30 seconds to ensure all expected event topics are present, addressing potential timing issues where events might not be immediately available. I have no feedback to provide.

@0xPepeSilvia 0xPepeSilvia marked this pull request as draft April 10, 2026 06:06
The previous attempt wrapped the event assertion in a 30-second retry
loop, but the underlying bug was that the feature file expected
`std.vault.pay_fee` events while the step definition filters events by
`substate_id == component_address`.

`std.vault.pay_fee` is emitted by the runtime with `substate_id =
vault_id` (see crates/engine/src/runtime/impl.rs:1784-1790), so the
filter can never match it. The retry would always time out.

The `Account.pay_fee` custom event (emitted via `emit_event` in
templates/account/src/lib.rs) carries the component substate id and
does match the filter. Revert the topic names so the assertion is
looking for events that can actually be found. The retry loop is kept
as defence-in-depth against indexer catch-up timing.
@0xPepeSilvia 0xPepeSilvia changed the title fix(tests): retry event topic assertion until indexer has scanned fix(tests): use correct topic names for account pay_fee events Apr 10, 2026
@0xPepeSilvia 0xPepeSilvia marked this pull request as ready for review April 10, 2026 06:24
@sdbondi
Copy link
Copy Markdown
Member

sdbondi commented Apr 10, 2026

Firstly, thanks for thr PR @0xPepeSilvia! Unfortunately, this PR was first #1983

@sdbondi sdbondi closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix event topic assertion in indexer event scanning test

3 participants