Skip to content

cardano-wasm demo: test suites wired into CI - #1318

Open
palas wants to merge 1 commit into
masterfrom
wasm-demo-tests
Open

cardano-wasm demo: test suites wired into CI#1318
palas wants to merge 1 commit into
masterfrom
wasm-demo-tests

Conversation

@palas

@palas palas commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Context

  • tests/CoreTest.elm: 95 elm-test cases for the pure core (bech32 golden vectors from real pools plus negative vectors isolating each guard, ada<->lovelace round-trips, balance boundaries, certificate JSON, list helpers)
  • tests/wasm/api-regression.mjs: 8 Node tests driving the freshly built lib-wrapper (wallet round-trip, getTxId stability, certificate round-trips asserting the cert, fee and witnesses end up in the signed CBOR, inspectAddress, newConwayTx broken-export probe)
  • haskell-wasm.yml runs elm-test with the demo build (elm-format now also validates tests/) and the regression suite right after it

How to trust this PR

It is all tests that pass. But it would be good to check that what is being tested makes sense, and it is tested the right way.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

- tests/CoreTest.elm: 95 elm-test cases for the pure core (bech32 golden
  vectors from real pools plus negative vectors isolating each guard,
  ada<->lovelace round-trips, balance boundaries, certificate JSON,
  list helpers)
- tests/wasm/api-regression.mjs: 8 Node tests driving the freshly built
  lib-wrapper (wallet round-trip, getTxId stability, certificate round-trips
  asserting the cert, fee and witnesses end up in the signed CBOR,
  inspectAddress, newConwayTx broken-export probe)
- haskell-wasm.yml runs elm-test with the demo build (elm-format now also
  validates tests/) and the regression suite right after it
@palas palas self-assigned this Aug 24, 2026
Copilot AI lite review requested due to automatic review settings August 24, 2026 14:47

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 Elm and Node.js regression tests for the cardano-wasm demo and wires them into WASM CI.

Changes:

  • Adds 95 Elm core tests and Node.js wasm API tests.
  • Updates test dependencies, documentation, and demo configuration.
  • Runs formatting and both test suites in CI.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Reviewed changes and final comments
cardano-wasm/demo/tests/wasm/README.md Documents regression test instructions.
cardano-wasm/demo/tests/wasm/package.json Adds Node.js test dependency metadata.
cardano-wasm/demo/tests/wasm/package-lock.json Locks Node.js dependencies.
cardano-wasm/demo/tests/wasm/api-regression.mjs Adds wasm API regression tests. Moderate: Verify the fee in serialized CBOR rather than only checking transaction ID changes. Moderate: Verify the decoded stake-key witness or use a fixed CBOR vector instead of relying on length increase.
cardano-wasm/demo/tests/CoreTest.elm Adds pure Elm core tests. Moderate: Use a JSON 404 with a different body to test the documented Blockfrost distinction.
cardano-wasm/demo/README.md Documents the demo test suites.
cardano-wasm/demo/elm.json Adds Elm test dependencies.
cardano-wasm/demo/.gitignore Ignores Node.js dependencies.
.github/workflows/haskell-wasm.yml Runs formatting, Elm tests, and Node.js regression tests in CI.
.changes/20260718_cardano_wasm_demo_tests.yml Adds the changelog entry.
Files not reviewed (1)
  • cardano-wasm/demo/tests/wasm/package-lock.json: Generated file
Suppressed comments (4)

.github/workflows/haskell-wasm.yml:246

  • Use npm ci here instead of npm install. The latter can reconcile package.json and package-lock.json and silently test a dependency graph different from the committed lockfile, which undermines the reproducibility of this CI regression suite.
        npm install

cardano-wasm/demo/tests/wasm/api-regression.mjs:248

  • When the missing export is eventually fixed, this branch accepts any resolved value and only logs a note. Thus CI still will not verify that newConwayTx returns the advertised UnsignedTx object or that the returned value is usable. Keep the missing-export probe, but add a smoke assertion on the resolved object's type/methods (or replace this branch with a real constructor test).
    await api.tx.newConwayTx();

cardano-wasm/demo/tests/wasm/api-regression.mjs:110

  • This only checks that the ID has the right shape and remains stable. An implementation that returns a fixed 64-character string, or hashes the wrong bytes consistently, would pass; assert an independently known ID for a fixed transaction vector (as cardano-wasm/npm-wrapper/api.test.js does) before checking witness invariance.
  const unsignedId = await tx.getTxId();
  assert(
    HEX64.test(unsignedId),
    `unsigned txid not 64 lowercase hex: ${unsignedId}`
  );

cardano-wasm/demo/tests/wasm/api-regression.mjs:144

  • Checking only for the stake hash means all three certificate-maker tests can pass if they return the wrong certificate (for example, delegation to a different pool, or registration instead of unregistration). Assert the action-specific encoding and deposit/pool value, ideally using fixed certificate vectors.
    certHex.includes(stakeKeyHash),
    `certificate does not embed the stake key hash: ${certHex}`

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +297 to +300
, test "an arbitrary 404 page is not recognised as Blockfrost's not-found" <|
\_ ->
Blockfrost.isBlockfrostNotFound "<html>404 not found</html>"
|> Expect.equal False
Comment on lines +157 to +161
tx.setFee(fee);
const idAfterFee = await tx.getTxId();
assert(
idAfterFee !== idBeforeFee,
"setting the fee should change the (body-hash) txid"
Comment on lines +179 to +180
cbor.length > cborOneSig.length,
"the stake signature should enlarge the witness set"
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.

2 participants