Skip to content

test: Add WASMI engine tests#7441

Open
mvadari wants to merge 1 commit into
ripple/wasmi-host-functionsfrom
ripple/se/wasmi-tests
Open

test: Add WASMI engine tests#7441
mvadari wants to merge 1 commit into
ripple/wasmi-host-functionsfrom
ripple/se/wasmi-tests

Conversation

@mvadari

@mvadari mvadari commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

High Level Overview of Change

Context of Change

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

@mvadari mvadari marked this pull request as ready for review June 9, 2026 21:11
Copilot AI review requested due to automatic review settings June 9, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a broad set of WebAssembly fixture modules (WAT/C/Rust sources + embedded wasm hex) to exercise WASMI engine behavior across traps, WASI imports, disabled proposals/features, and resource-limit edge cases within the existing src/test/app WASM test harness.

Changes:

  • Add many new .wat fixtures covering traps, WASI calls, proposal-gated opcodes/features, memory/table edge cases, and stress scenarios (recursion, start section loop, large param lists).
  • Add Rust-based float fixtures (float_tests, float_0) and additional C fixtures (e.g., fib.c, infiniteLoop.c, thousand-parameter functions).
  • Extend wasm_fixtures/fixtures.{h,cpp} with new embedded wasm hex constants and update cspell configuration for WAT fixtures.

Reviewed changes

Copilot reviewed 53 out of 59 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/test/app/wasm_fixtures/wat/wide_arithmetic.wat Adds WAT source for wide arithmetic opcode coverage (proposal-gated).
src/test/app/wasm_fixtures/wat/wasi_print.wat Adds WAT fixture exercising WASI fd_write.
src/test/app/wasm_fixtures/wat/wasi_get_time.wat Adds WAT fixture exercising WASI clock_time_get.
src/test/app/wasm_fixtures/wat/trap_unreachable.wat Adds WAT fixture that traps via unreachable.
src/test/app/wasm_fixtures/wat/trap_null_call.wat Adds WAT fixture for call_indirect null element trap.
src/test/app/wasm_fixtures/wat/trap_int_overflow.wat Adds WAT fixture for i32 signed division overflow trap.
src/test/app/wasm_fixtures/wat/trap_func_signature_mismatch.wat Adds WAT fixture for indirect call type mismatch trap.
src/test/app/wasm_fixtures/wat/trap_divide_by_0.wat Adds WAT fixture for divide-by-zero trap.
src/test/app/wasm_fixtures/wat/table_uint_max.wat Adds WAT fixture declaring an enormous table size boundary case.
src/test/app/wasm_fixtures/wat/table_65_elements.wat Adds WAT fixture for table element-count limit test (65).
src/test/app/wasm_fixtures/wat/table_64_elements.wat Adds WAT fixture for table element-count limit test (64).
src/test/app/wasm_fixtures/wat/table_2_tables.wat Adds WAT fixture for multiple tables (proposal-gated).
src/test/app/wasm_fixtures/wat/table_0_elements.wat Adds WAT fixture for zero-sized table.
src/test/app/wasm_fixtures/wat/start_loop.wat Adds WAT fixture with a start function that loops.
src/test/app/wasm_fixtures/wat/proposal_tail_call.wat Adds WAT fixture for tail-call proposal opcode.
src/test/app/wasm_fixtures/wat/proposal_stringref.wat Adds placeholder for stringref proposal fixture (currently not valid WAT).
src/test/app/wasm_fixtures/wat/proposal_sign_ext.wat Adds WAT fixture for sign-extension operators (proposal-gated).
src/test/app/wasm_fixtures/wat/proposal_ref_types.wat Adds WAT fixture for reference-types proposal (externref, ref.null).
src/test/app/wasm_fixtures/wat/proposal_mutable_global.wat Adds WAT fixture for mutable globals export/mutation (proposal-gated).
src/test/app/wasm_fixtures/wat/proposal_multi_value.wat Adds WAT fixture for multi-value returns/params (proposal-gated).
src/test/app/wasm_fixtures/wat/proposal_gc_struct_new.wat Adds WAT fixture for GC struct opcode (proposal-gated).
src/test/app/wasm_fixtures/wat/proposal_float_to_int.wat Adds WAT fixture for saturating float-to-int conversion opcode (proposal-gated).
src/test/app/wasm_fixtures/wat/proposal_extended_const.wat Adds WAT fixture for extended-const expressions (proposal-gated).
src/test/app/wasm_fixtures/wat/proposal_bulk_memory.wat Adds WAT fixture for bulk-memory ops (proposal-gated).
src/test/app/wasm_fixtures/wat/opc_reserved.wat Adds WAT fixture with many NOPs; comments imply broader opcode coverage than implemented.
src/test/app/wasm_fixtures/wat/multi_memory.wat Adds WAT fixture for multi-memory (proposal-gated).
src/test/app/wasm_fixtures/wat/memory64.wat Adds WAT fixture for memory64 (proposal-gated).
src/test/app/wasm_fixtures/wat/memory_pointer_over_limit.wat Adds WAT fixture for out-of-bounds pointer access.
src/test/app/wasm_fixtures/wat/memory_pointer_at_limit.wat Adds WAT fixture for last valid byte pointer access.
src/test/app/wasm_fixtures/wat/memory_offset_over_limit.wat Adds WAT fixture for static offset out-of-bounds access.
src/test/app/wasm_fixtures/wat/memory_negative_address.wat Adds WAT fixture using negative address access.
src/test/app/wasm_fixtures/wat/memory_last_byte_of_8MB.wat Adds WAT fixture for accessing last byte at 8MB limit (comment arithmetic typo).
src/test/app/wasm_fixtures/wat/memory_init_1_page_more_than_8MB.wat Adds WAT fixture for init beyond 8MB (comment arithmetic typo).
src/test/app/wasm_fixtures/wat/memory_grow_1_to_0.wat Adds WAT fixture for memory.grow with -1 delta.
src/test/app/wasm_fixtures/wat/memory_grow_1_page_more_than_8MB.wat Adds WAT fixture attempting to grow beyond the limit by 1 page.
src/test/app/wasm_fixtures/wat/memory_grow_0_to_1.wat Adds WAT fixture growing from 0 pages to 1 page.
src/test/app/wasm_fixtures/wat/memory_grow_0_page_more_than_8MB.wat Adds WAT fixture memory.grow by 0 pages at limit.
src/test/app/wasm_fixtures/wat/memory_end_of_word_over_limit.wat Adds WAT fixture for word-sized load straddling end-of-memory.
src/test/app/wasm_fixtures/wat/deep_recursion.wat Adds WAT fixture for deep recursion behavior.
src/test/app/wasm_fixtures/wat/custom_page_sizes.wat Adds WAT fixture for custom page sizes (proposal-gated).
src/test/app/wasm_fixtures/thousand1_params.c Adds C fixture for function with 1001 params.
src/test/app/wasm_fixtures/thousand_params.c Adds C fixture for function with 1000 params.
src/test/app/wasm_fixtures/infiniteLoop.c Adds C fixture for an infinite loop.
src/test/app/wasm_fixtures/float_tests/src/lib.rs Adds Rust wasm fixture testing many float host functions.
src/test/app/wasm_fixtures/float_tests/Cargo.toml Adds Cargo manifest for float-tests fixture crate (uses git branch dependency).
src/test/app/wasm_fixtures/float_tests/Cargo.lock Adds lockfile for float-tests fixture crate.
src/test/app/wasm_fixtures/float_0/src/lib.rs Adds Rust wasm fixture intended to validate FLOAT_ZERO behavior (currently always returns success).
src/test/app/wasm_fixtures/float_0/Cargo.toml Adds Cargo manifest for float_0 fixture crate.
src/test/app/wasm_fixtures/float_0/Cargo.lock Adds lockfile for float_0 fixture crate.
src/test/app/wasm_fixtures/fixtures.h Declares many new wasm-hex fixture constants for tests.
src/test/app/wasm_fixtures/fixtures.cpp Defines many new embedded wasm-hex fixtures used by WASM tests.
src/test/app/wasm_fixtures/fib.c Adds C fixture for recursive Fibonacci function.
src/test/app/wasm_fixtures/disableFloat.wat Adds WAT fixture that exercises float opcodes for “float disabled” behavior.
cspell.config.yaml Updates cspell ignore paths to exclude WAT fixtures (but not Rust/Cargo fixtures).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +24
if FLOAT_SIZE as i32 != unsafe { float_from_int(10, f10.as_mut_ptr(), FLOAT_SIZE, FLOAT_ROUNDING_MODES_TO_NEAREST) } {
let _ = trace(" float 10-10: failed");
return 1;
}
Comment on lines +37 to +40
} {
let _ = trace(" float 10-10: failed");
return 1;
}
Comment on lines +42 to +49
// Compare result with FLOAT_ZERO constant
if 0 == unsafe { float_compare(f_result.as_ptr(), FLOAT_SIZE, FLOAT_ZERO.as_ptr(), FLOAT_SIZE) } {
let _ = trace(" FLOAT_ZERO compare: good");
} else {
let _ = trace(" FLOAT_ZERO compare: bad");
}

1
@@ -0,0 +1 @@
;;hard to generate
Comment on lines +22 to +26
;; Main function with all instructions in hex order
(func $all_instructions (export "all_instructions") (result i32)
(local $l0 i32)
(local $l1 i64)

(export "memory" (memory 0))

(func $access_last_byte (result i32)
;; Math: 128 pages * 64,536 bytes/page = 8,388,608 bytes

;; access last byte of 8MB limit
(func $access_last_byte (result i32)
;; Math: 128 pages * 64,536 bytes/page = 8,388,608 bytes
Comment thread cspell.config.yaml
Comment on lines 9 to 12
- .clang-tidy
- src/test/app/wasm_fixtures/**/*.wat
- src/test/app/wasm_fixtures/*.c
language: en
Comment on lines +17 to +19
[dependencies]
xrpl-std = { git = "https://github.com/ripple/xrpl-wasm-stdlib.git", package = "xrpl-wasm-stdlib", branch = "u32-buffer" }

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

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.

3 participants