Skip to content

refactor(e2e): unify submit helpers behind a typed SubmitError - #2013

Open
wbaxterh wants to merge 1 commit into
midnightntwrk:mainfrom
wbaxterh:wes-1840-typed-submit-error
Open

refactor(e2e): unify submit helpers behind a typed SubmitError#2013
wbaxterh wants to merge 1 commit into
midnightntwrk:mainfrom
wbaxterh:wes-1840-typed-submit-error

Conversation

@wbaxterh

Copy link
Copy Markdown

Overview

Closes #1840.

Follow-up from the #1796 review. tests/e2e/src/api/midnight.rs had submit_midnight_tx (returned the raw TransactionProgress) and submit_expecting_rejection (drove it to a rejection and returned a stringly Box<dyn Error>). This adds a typed SubmitError and collapses them into a single submit_midnight_tx that submits, waits for finalized success, and returns the finalized ExtrinsicEvents or a typed error, so callers match on the result instead of picking between two methods:

  • SubmitError::Subxt — a subxt-layer failure, including the node rejecting the tx at submission time (e.g. "already imported" / "temporarily banned").
  • SubmitError::NotFinalized — the tx was watched but failed pre_dispatch/execution.

Notes on scope:

  • submit_expecting_rejection had no callers, so it is removed; a rejection is now the typed Err from submit_midnight_tx.
  • submit_expecting_success keeps its best-block-inclusion semantics (no added latency on the deploy path) via a shared submit_and_watch helper, and now also returns SubmitError.
  • The one c2m_bridge caller uses the returned finalized events directly.
  • Adds thiserror (already a workspace dependency) to the e2e crate.

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • All commits are signed off (git commit -s) for the DCO
  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason:
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 Testing Evidence

Verified with cargo test -p midnight-node-e2e --test e2e_tests -- --list (builds the e2e lib + test binary and lists tests): compiles clean, test set unchanged. No behavior change to the tests themselves; this is an internal helper refactor.

  • Additional tests are provided (if possible) — N/A, refactor of existing helpers.

🔱 Fork Strategy

  • N/A

Links

Closes #1840

tests/e2e/src/api/midnight.rs had submit_midnight_tx (raw progress handle) and
submit_expecting_rejection (drove it to a rejection, returning a stringly error).
Add a typed SubmitError (Subxt for submission-time failures, NotFinalized for a
watched tx that failed pre_dispatch/execution) and collapse them into one
submit_midnight_tx that submits, waits for finalized success, and returns the
finalized ExtrinsicEvents or a typed SubmitError. Callers expecting success use
?/expect; callers expecting a rejection match on the Err.

submit_expecting_rejection had no callers and is removed. submit_expecting_success
keeps its best-block-inclusion semantics via a shared submit_and_watch helper and
now also returns SubmitError. The c2m_bridge caller uses the returned events directly.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: wbaxterh <wesleybaxterhuber@gmail.com>
@wbaxterh
wbaxterh requested a review from a team as a code owner August 10, 2026 13:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 353c186fc4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.await?
.wait_for_finalized_success()
.await
.map_err(|e| SubmitError::NotFinalized(e.to_string()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Separate watcher failures from transaction rejection

When the transaction subscription disconnects, event retrieval fails, or another subxt/RPC error occurs while wait_for_finalized_success() is running, this mapping reports SubmitError::NotFinalized just like a pre-dispatch or execution rejection. A rejection-focused e2e test matching that variant can therefore pass during an infrastructure failure instead of proving the node rejected the transaction; preserve subxt watcher errors separately and reserve NotFinalized for confirmed transaction failures.

Useful? React with 👍 / 👎.

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.

e2e: unify submit_midnight_tx / submit_expecting_rejection with a typed SubmitError

1 participant