Skip to content

fix: broken tests - #1641

Merged
sdbondi merged 1 commit into
tari-project:developmentfrom
sdbondi:fix-tests
Nov 11, 2025
Merged

fix: broken tests#1641
sdbondi merged 1 commit into
tari-project:developmentfrom
sdbondi:fix-tests

Conversation

@sdbondi

@sdbondi sdbondi commented Nov 11, 2025

Copy link
Copy Markdown
Member

Description

Forgot to push fixes in #1640

Summary by CodeRabbit

  • New Features
    • Added validation to enforce maximum template binary size limits with clear error messaging when size limits are exceeded during template publishing.

@sdbondi
sdbondi merged commit 498dc6f into tari-project:development Nov 11, 2025
11 of 13 checks passed
@coderabbitai

coderabbitai Bot commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

These changes implement size validation for WASM template binaries during publishing. A new error variant is introduced to handle oversized binaries, a pre-flight size check is integrated into the template publishing flow, and tests are updated to verify the new behavior with support for unsafe test data construction.

Changes

Cohort / File(s) Summary
Error & Validation
crates/engine/src/transaction/error.rs, crates/engine/src/transaction/processor.rs
Added WasmBinaryTooBig { size, max } error variant to TransactionError; integrated pre-flight size validation in publish_template that early-returns with the new error if template binary exceeds ENGINE_LIMITS.max_template_binary_size_bytes
Testing Infrastructure
crates/template_lib_types/src/max_bytes.rs, crates/engine/tests/publish_template.rs
Added unsafe new_unchecked constructor to MaxBytes<N> for test data; updated publish_template_too_big_binary test to use dynamic limit checks and TemplateBlob::new_unchecked() with safety comments; refactored error assertion to use assert_reject_reason helper

Sequence Diagram

sequenceDiagram
    participant Client
    participant PublishTemplate
    participant SizeCheck
    participant WasmModule
    participant TxError

    Client->>PublishTemplate: publish_template(binary)
    PublishTemplate->>SizeCheck: Check binary.len() vs ENGINE_LIMITS
    alt Binary exceeds max size
        SizeCheck->>TxError: WasmBinaryTooBig { size, max }
        TxError->>Client: Return Error
    else Binary within limits
        SizeCheck->>WasmModule: Load & validate template
        WasmModule->>PublishTemplate: Success
        PublishTemplate->>Client: Return Ok(tx_id)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Specific areas requiring attention:
    • The new_unchecked unsafe constructor in MaxBytes<N> — verify safety comments justify the invariant bypass and confirm it's intended for testing only
    • Pre-flight validation logic in publish_template — ensure the size check is performed before any template loading to prevent wasted computation on invalid inputs
    • Test modifications using unsafe constructor — confirm the test harness properly isolates unsafe usage and validates the error path correctly

Possibly related PRs

Suggested labels

P-acks_required, P-reviews_required

Poem

🐰 A binary arrives at the gate, quite fat,
The guard checks the size with a pat,
"Too big!" it declares, with a friendly rebuff,
"Trim down, my friend—that's quite enough!"
Size limits keep systems just right, and that's that! 🏰

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 066d6f1 and a9d1be7.

📒 Files selected for processing (4)
  • crates/engine/src/transaction/error.rs (1 hunks)
  • crates/engine/src/transaction/processor.rs (2 hunks)
  • crates/engine/tests/publish_template.rs (2 hunks)
  • crates/template_lib_types/src/max_bytes.rs (1 hunks)

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.

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.

2 participants