Skip to content

Fix #848 - formatting and assertion improvements#857

Merged
FabijanC merged 3 commits intomainfrom
fix-pr-848
Sep 22, 2025
Merged

Fix #848 - formatting and assertion improvements#857
FabijanC merged 3 commits intomainfrom
fix-pr-848

Conversation

@FabijanC
Copy link
Copy Markdown
Contributor

@FabijanC FabijanC commented Sep 22, 2025

Usage related changes

None

Development related changes

Checklist:

  • Checked out the contribution guidelines
  • Applied formatting - ./scripts/format.sh
  • No linter errors - ./scripts/clippy_check.sh
  • No unused dependencies - ./scripts/check_unused_deps.sh
  • No spelling errors - ./scripts/check_spelling.sh
  • Performed code self-review
  • Rebased to the latest commit of the target branch (or merged it into my branch)
    • Once you make the PR reviewable, please avoid force-pushing
  • Updated the docs if needed - ./website/README.md
  • Linked the issues resolvable by this PR - linking info
  • Updated the tests if needed; all passing - execution info

Summary by CodeRabbit

  • Tests

    • Standardized assertion error messages across integration tests.
    • Simplified test helpers to return assertion results directly, improving error propagation and readability.
    • Replaced manual comparisons with property-based assertion macros in multiple tests.
    • Minor structural tweaks in test flows and formatting of extracted values.
  • Documentation

    • Refined doc comments and punctuation for clarity.
  • Refactor

    • Consolidated assertion patterns and streamlined control flow in test utilities and cases.
  • Style

    • Minor formatting and naming cleanups in test code.
  • Chores

    • Import adjustments to align with updated assertion usage.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 22, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Across multiple integration test files, assertion patterns were standardized to return the assertion macro’s Result directly instead of using the ? operator followed by Ok(()). Several helpers now conclude with the assertion expression as the final return value. Assertions were migrated to project-specific macros (assert_eq_prop, assert_ne_prop, assert_gte_prop, assert_lte_prop, assert_prop) and error message formatting within assertion macros was unified. Minor doc comment and punctuation tweaks were made. One helper in test_account_selection (assert_supports_isrc6) now returns Result and callers updated to await.unwrap(). No public API surface outside tests was modified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Mostly homogeneous mechanical edits replacing ?/Ok(()) with direct assertion returns
  • Consistent migration to prop-based assertion macros across tests
  • Minor import and formatting adjustments
  • One helper signature change with straightforward call-site updates

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.26% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Fix #848 - formatting and assertion improvements" succinctly summarizes the primary change set (formatting fixes and expanded use of propagable assertion macros) and references the related issue. This matches the raw_summary which shows doc-comment/formatting edits and conversion to propagable assertion macros across many integration tests. The phrasing is concise and clear enough for a teammate scanning history to understand the primary intent.
Description Check ✅ Passed The PR description follows the repository template: it provides "Usage related changes" (explicitly "None"), a "Development related changes" section describing formatting and propagable-macro updates, and a completed checklist with items marked. The listed development changes align with the raw_summary and the stated PR objectives. Overall the description is sufficiently complete and actionable for reviewers.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@FabijanC FabijanC changed the title Fix #848 Fix #848 - formatting and assertion improvements Sep 22, 2025
@FabijanC
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 22, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/integration/test_blocks_generation.rs (1)

75-77: Implement assert_tx_succeeded_pre_confirmed and propagate its Result at call sites.

tests/integration/common/utils.rs currently contains a no‑op that prints "TODO" and returns (). Change it to return Result<(), anyhow::Error> and implement the checks: fetch the transaction receipt, assert ExecutionResult::Succeeded, assert finality_status() == TransactionFinalityStatus::PreConfirmed, and return Ok(()) or anyhow::bail on failure.

Update all test call sites to propagate the Result (use ? or make the helper the tail expression), e.g. in tests/integration/test_blocks_generation.rs at lines 75–77, 108–110, 165–172, 337–341, 461–463 (and any other callers).

🧹 Nitpick comments (1)
tests/integration/test_messaging.rs (1)

978-983: Avoid borrowing from a temporary JSON value.

Borrowing a field from the temporary returned by send_custom_rpc is harder to read and easy to regress. Bind the response first, then index.

Apply:

-    let generated_l2_txs_raw =
-        &devnet.send_custom_rpc("devnet_postmanFlush", json!({})).await.unwrap()
-            ["generated_l2_transactions"];
-    let generated_l2_txs = generated_l2_txs_raw.as_array().unwrap();
+    let flush_resp = devnet.send_custom_rpc("devnet_postmanFlush", json!({})).await.unwrap();
+    let generated_l2_txs = flush_resp["generated_l2_transactions"].as_array().unwrap();
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eeb397f and 0c04173.

📒 Files selected for processing (12)
  • tests/integration/common/assertions.rs (10 hunks)
  • tests/integration/common/utils.rs (5 hunks)
  • tests/integration/test_abort_blocks.rs (1 hunks)
  • tests/integration/test_account_impersonation.rs (2 hunks)
  • tests/integration/test_account_selection.rs (4 hunks)
  • tests/integration/test_advancing_time.rs (1 hunks)
  • tests/integration/test_blocks_generation.rs (7 hunks)
  • tests/integration/test_dump_and_load.rs (1 hunks)
  • tests/integration/test_messaging.rs (3 hunks)
  • tests/integration/test_minting.rs (1 hunks)
  • tests/integration/test_subscription_to_tx_status.rs (1 hunks)
  • tests/integration/test_trace.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: Abeeujah
PR: 0xSpaceShard/starknet-devnet#848
File: tests/integration/test_blocks_generation.rs:65-78
Timestamp: 2025-09-18T13:11:58.957Z
Learning: The function assert_tx_succeeded_pre_confirmed in tests/integration/common/utils.rs was not converted to return Result<(), anyhow::Error> and still returns unit type (), unlike assert_tx_succeeded_accepted which was converted to return Result.
Learnt from: Abeeujah
PR: 0xSpaceShard/starknet-devnet#848
File: tests/integration/test_blocks_generation.rs:141-162
Timestamp: 2025-09-18T13:15:00.238Z
Learning: The function assert_tx_succeeded_pre_confirmed in tests/integration/common/utils.rs is currently unimplemented - it only contains a TODO message printed via eprintln! and has all the actual assertion logic commented out. The function still returns unit type () rather than Result<(), anyhow::Error> and essentially acts as a no-op stub.
Learnt from: Abeeujah
PR: 0xSpaceShard/starknet-devnet#848
File: tests/integration/test_blocks_generation.rs:141-162
Timestamp: 2025-09-18T13:15:00.238Z
Learning: In tests/integration/common/utils.rs, the function assert_tx_succeeded_pre_confirmed currently contains only a TODO comment and doesn't perform any actual assertions, making it effectively unimplemented despite having its signature updated to return Result<(), anyhow::Error>.
Learnt from: Abeeujah
PR: 0xSpaceShard/starknet-devnet#848
File: tests/integration/test_blocks_generation.rs:141-162
Timestamp: 2025-09-18T13:15:00.238Z
Learning: In tests/integration/common/utils.rs, the function assert_tx_succeeded_pre_confirmed currently contains only a TODO comment and doesn't perform any actual assertions, making it effectively unimplemented despite having its signature updated to return Result<(), anyhow::Error>.
📚 Learning: 2025-09-18T13:11:58.957Z
Learnt from: Abeeujah
PR: 0xSpaceShard/starknet-devnet#848
File: tests/integration/test_blocks_generation.rs:65-78
Timestamp: 2025-09-18T13:11:58.957Z
Learning: The function assert_tx_succeeded_pre_confirmed in tests/integration/common/utils.rs was not converted to return Result<(), anyhow::Error> and still returns unit type (), unlike assert_tx_succeeded_accepted which was converted to return Result.

Applied to files:

  • tests/integration/test_subscription_to_tx_status.rs
  • tests/integration/test_account_impersonation.rs
  • tests/integration/common/assertions.rs
  • tests/integration/test_dump_and_load.rs
  • tests/integration/test_advancing_time.rs
  • tests/integration/test_messaging.rs
  • tests/integration/common/utils.rs
  • tests/integration/test_minting.rs
  • tests/integration/test_blocks_generation.rs
  • tests/integration/test_account_selection.rs
  • tests/integration/test_trace.rs
  • tests/integration/test_abort_blocks.rs
📚 Learning: 2025-09-18T13:15:00.238Z
Learnt from: Abeeujah
PR: 0xSpaceShard/starknet-devnet#848
File: tests/integration/test_blocks_generation.rs:141-162
Timestamp: 2025-09-18T13:15:00.238Z
Learning: In tests/integration/common/utils.rs, the function assert_tx_succeeded_pre_confirmed currently contains only a TODO comment and doesn't perform any actual assertions, making it effectively unimplemented despite having its signature updated to return Result<(), anyhow::Error>.

Applied to files:

  • tests/integration/test_subscription_to_tx_status.rs
  • tests/integration/test_account_impersonation.rs
  • tests/integration/test_dump_and_load.rs
  • tests/integration/test_advancing_time.rs
  • tests/integration/test_messaging.rs
  • tests/integration/common/utils.rs
  • tests/integration/test_minting.rs
  • tests/integration/test_blocks_generation.rs
  • tests/integration/test_account_selection.rs
  • tests/integration/test_trace.rs
  • tests/integration/test_abort_blocks.rs
📚 Learning: 2025-09-18T13:15:00.238Z
Learnt from: Abeeujah
PR: 0xSpaceShard/starknet-devnet#848
File: tests/integration/test_blocks_generation.rs:141-162
Timestamp: 2025-09-18T13:15:00.238Z
Learning: The function assert_tx_succeeded_pre_confirmed in tests/integration/common/utils.rs is currently unimplemented - it only contains a TODO message printed via eprintln! and has all the actual assertion logic commented out. The function still returns unit type () rather than Result<(), anyhow::Error> and essentially acts as a no-op stub.

Applied to files:

  • tests/integration/test_subscription_to_tx_status.rs
  • tests/integration/test_account_impersonation.rs
  • tests/integration/test_dump_and_load.rs
  • tests/integration/test_advancing_time.rs
  • tests/integration/test_messaging.rs
  • tests/integration/common/utils.rs
  • tests/integration/test_minting.rs
  • tests/integration/test_blocks_generation.rs
  • tests/integration/test_account_selection.rs
  • tests/integration/test_trace.rs
  • tests/integration/test_abort_blocks.rs
📚 Learning: 2025-06-16T07:35:24.725Z
Learnt from: FabijanC
PR: 0xSpaceShard/starknet-devnet#799
File: crates/starknet-devnet-core/src/starknet/mod.rs:240-246
Timestamp: 2025-06-16T07:35:24.725Z
Learning: In the Starknet devnet codebase, `get_class_hash_at` has different behaviors at different layers: at the internal state level (blockifier), it returns `Ok(ClassHash(Felt::ZERO))` for undeployed addresses, while at the RPC layer, this gets converted to `Err(Error::ContractNotFound)`. When checking if a contract is deployed at the internal state level, use `is_ok_and(|h| h.0 == Felt::ZERO)` to detect undeployed addresses.

Applied to files:

  • tests/integration/test_blocks_generation.rs
  • tests/integration/test_account_selection.rs
🔇 Additional comments (26)
tests/integration/common/assertions.rs (3)

1-1: LGTM!

The backtick formatting for the value false in the doc comment improves documentation clarity.


27-27: LGTM!

The punctuation improvements in the doc comments enhance readability and consistency.

Also applies to: 99-99, 135-135


38-39: LGTM!

The error message formatting standardization using explicit interpolation ({left_val:?} and {right_val:?}) is more readable and consistent across all assertion macros.

Also applies to: 53-54, 74-75, 89-90, 110-111, 125-126, 146-147, 161-162

tests/integration/test_trace.rs (1)

59-62: LGTM!

The simplification from explicit error propagation with ? followed by Ok(()) to returning the assertion macro result directly is consistent with the broader test suite refactor pattern. This improves consistency and reduces boilerplate code.

tests/integration/test_abort_blocks.rs (1)

37-37: LGTM!

The refactoring aligns with the broader test suite pattern of returning assertion macro results directly instead of using explicit error propagation with ? and Ok(()). This creates more consistent error handling across test helpers.

tests/integration/test_dump_and_load.rs (1)

51-51: LGTM!

The change from explicit error propagation to returning the assertion macro result directly is consistent with the broader test suite refactoring pattern. This simplifies the code and standardizes error handling across test functions.

tests/integration/test_subscription_to_tx_status.rs (1)

51-51: LGTM!

The refactoring to return the assertion macro result directly instead of using explicit error propagation is consistent with the broader test suite changes. This creates more uniform error handling patterns across the codebase.

tests/integration/test_minting.rs (1)

50-50: LGTM!

The change to return the assertion result directly aligns with the consistent refactoring pattern across the test suite. This eliminates unnecessary boilerplate and creates uniform error handling.

tests/integration/test_advancing_time.rs (1)

37-37: LGTM!

Both functions now return the assertion macro result directly instead of using explicit error propagation with ? followed by Ok(()). This creates consistent error handling patterns and reduces boilerplate code while maintaining the same functional behavior.

Also applies to: 43-43

tests/integration/common/utils.rs (5)

38-38: LGTM!

The import adjustments appropriately add the needed assertion macros for the refactored test utilities.


243-243: LGTM!

The function now returns the assertion result directly instead of explicitly returning Ok(()), which is consistent with the broader test suite refactoring pattern.


450-453: LGTM!

The variable rename from e to el improves readability, and the error message format using explicit interpolation ({el:?}) is more consistent with the updated assertion patterns.


490-490: LGTM!

The refactoring to return the assertion macro result directly is consistent with the broader changes across test utilities and eliminates unnecessary boilerplate.


601-601: LGTM!

Converting from block comment to inline comment improves code consistency and readability.

tests/integration/test_account_impersonation.rs (2)

15-15: Good switch to project assertion macros.

Importing assert_eq_prop and assert_gte_prop aligns this file with the propagating-Result pattern.


260-261: Propagating assertions look correct.

  • Checking ExecutionResult via assert_eq_prop with ? is consistent.
  • Final-expression assert_gte_prop cleanly returns Result from the helper.

Also applies to: 266-267

tests/integration/test_messaging.rs (2)

183-189: Tail-return assertion in trace validator.

Using assert_eq_prop as the final expression keeps the helper concise and consistent.


208-221: Return the assertion result directly.

assert_eq_prop!(resp_body, expected_resp) as the tail expression is spot on.

tests/integration/test_blocks_generation.rs (5)

34-38: Assertion message formatting tweak LGTM.

The assert_prop! messages are clearer; leaving the “but found:” suffix to the macro’s formatter is consistent with the suite.

Also applies to: 44-48


182-184: Nice tail-expression return.

assert_eq_prop!(balance, expected) as the final expression simplifies the helper.


195-198: Consistent use of propagating assertion.

Latest and pre-confirmed nonce checks now return the macro result directly.


210-215: Consistent storage assertion.

Good use of tail-returning assertion for latest storage.


227-232: Consistent class-hash assertion.

Returning the assertion result directly keeps helpers uniform.

tests/integration/test_account_selection.rs (3)

65-66: Use of assert_eq_prop as tail return is consistent.

Good replacement of trailing Ok(()) with the macro result.


237-253: Helper now returns Result and uses propagating assertion.

assert_supports_isrc6 returning Result<(), anyhow::Error> and asserting via assert_eq_prop improves consistency and failure messages.


260-261: Call sites updated appropriately.

.await.unwrap() aligns with the test style elsewhere.

Also applies to: 269-270

@FabijanC FabijanC merged commit 7b43bf2 into main Sep 22, 2025
2 checks passed
@FabijanC FabijanC deleted the fix-pr-848 branch September 22, 2025 13:54
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2025
10 tasks
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.

1 participant