Skip to content

Add unit tests for WasmEngine and SandboxPolicy (engine.rs) #16

@niklabh

Description

@niklabh

Description

oxide-browser/src/engine.rs defines WasmEngine and SandboxPolicy — the core compilation and sandboxing layer. It currently has no tests.

This module is critical for security (fuel limits, memory bounds), so test coverage would catch regressions early.

Suggested test cases

  • SandboxPolicy defaults — verify SandboxPolicy::default() returns expected fuel (500M) and memory page limits (256)
  • Engine creationWasmEngine::new() succeeds with a valid policy
  • Module compilation — compile a minimal valid .wasm module (can use wat::parse_str to create one inline)
  • Fuel limit enforcement — a module with an infinite loop should trap after fuel is exhausted
  • Memory limit enforcement — a module that tries to grow memory beyond the limit should fail
  • Invalid WASM — compiling garbage bytes should return an error, not panic

Files involved

  • oxide-browser/src/engine.rs — add a #[cfg(test)] mod tests { ... } block

Helpful references

Difficulty

Intermediate — requires basic understanding of wasmtime and WebAssembly concepts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions