8000 Test: cross-platform .graph file compatibility (native ↔ browser WASM) · Issue #150 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

Test: cross-platform .graph file compatibility (native ↔ browser WASM) #150

Closed

Description

@adityamukho

Background

BrowserDb::export_graph() documents that its output blob is "byte-for-bit compatible with native .graph files opened by the native binary" (src/browser/mod.rs:171). BrowserDb::import_graph() accepts a native-produced file.

This invariant is currently untested across the boundary. The only existing test (export_import_round_trip in src/browser/mod.rs) round-trips within the browser WASM environment; it does not verify interoperability with the native binary.

What to test

  1. Native → Browser: produce a .graph file with the native binary (or MemoryBackend + PersistentFactStorage in a native test), serialise it to bytes, feed those bytes to BrowserDb::import_graph(), and assert queries return the expected results.

  2. Browser → Native: call BrowserDb::export_graph() on a populated in-browser database, take the returned byte blob, load it via PersistentFactStorage::<MemoryBackend>::load() (or write it to a temp file and open with Minigraf::open()), and assert the facts are readable.

Suggested approach

  • A native integration test (in tests/) can exercise the native → browser direction by building the .graph bytes using the storage layer directly, then deserialising them using the same layer, confirming the format is self-consistent. This is already implicitly tested via migration tests but not labelled as a cross-platform compat test.
  • The browser → native direction requires a wasm-bindgen-test that exports a blob and a companion native test that reads the same fixed binary fixture. A checked-in binary fixture (a small known .graph file) could serve both directions.
  • Consider adding a fixture-based test: a small .graph file committed to tests/fixtures/ produced by the native binary, loaded by the browser WASM test suite via import_graph, and asserted to contain known facts.

Acceptance criteria

  • At least one test verifies native-produced bytes are readable by BrowserDb::import_graph()
  • At least one test verifies BrowserDb::export_graph() bytes are readable by the native storage layer
  • Tests run in CI (native tests in rust.yml; browser tests in wasm-browser.yml)
  • A format regression note is added to CHANGELOG.md / TEST_COVERAGE.md when the tests are added

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestrustPull requests that update rust code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0