Portals.Conformance.SDKSuite (portals v0.1.0)

Copy Markdown View Source

The protocol conformance suite every worker SDK must pass.

Portals.Conformance.Runner checks a codec directly. A foreign SDK cannot be handed to it as a module, so this suite drives it over a language-neutral bridge instead: every SDK ships a conformance_worker fixture whose echo_term round-trips a term through the SDK's own codec and whose decode_reason classifies raw bytes. The golden vectors (protocol/vectors/golden.exs) and malformed fixtures (protocol/malformed/fixtures.exs) are replayed against it from the same source of truth the Elixir codec is checked against, so every SDK classifies every fixture identically.

defmodule PortalsRuby.ConformanceTest do
  use Portals.Conformance.SDKSuite,
    language: "ruby",
    worker: Portals.Ruby.worker_opts(script: "priv/ruby/test/fixtures/run_worker.rb"),
    stdio_worker:
      Portals.Ruby.worker_opts(script: "priv/ruby/test/fixtures/run_worker_stdio.rb"),
    bad_version_worker:
      Portals.Ruby.worker_opts(
        script: "priv/ruby/test/fixtures/run_worker.rb",
        env: [{"PORTALS_PROTOCOL_VERSION", "999"}]
      )
end

Options

  • :language (required) — used in test names.
  • :worker (required) — Portals.start_worker/1 options for a worker that serves the conformance_worker and bench_worker fixtures over the default Unix-socket transport.
  • :stdio_worker (required) — the same, for a worker using the framed stdio fallback transport. The suite adds transport: :stdio.
  • :bad_version_worker (required) — a worker that advertises protocol version 999 in its HELLO.
  • :moduletag — extra module tags for every test in the suite, e.g. [runtime: :deno].

The suite also asserts that the SDK reports the same version as the portals application, since every SDK is released in lockstep with it.

Summary

Functions

The decode_reason every SDK must report for each malformed fixture.

Functions

expected_reasons()

@spec expected_reasons() :: %{required(String.t()) => String.t()}

The decode_reason every SDK must report for each malformed fixture.