smartcontractkit / smartcontractkit/cre-sdk-typescript

TestTeeRuntime is unreachable: not exported from @chainlink/cre-sdk/test, and newTestTEERuntime does not exist

Open
#315 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
6
Forks
9
Avg merge
5h 23m
Merged PRs (30d)
6

Description

Summary

TestTeeRuntime ships, is documented, and cannot be imported. It is missing from the only public test
entrypoint, and the factory its own doc comment names does not exist.

Detail

packages/cre-sdk/src/sdk/testutils/test-runtime.ts defines:

/**
 * TestTeeRuntime is a TeeRuntime implementation for unit tests. Extends TeeRuntimeImpl; construct via newTestTEERuntime.
 * Adds getLogs() and setTimeProvider(). ...
 */
export class TestTeeRuntime<T> extends TeeRuntimeImpl<T> { ... }
  • newTestTEERuntime does not exist. grep -rn newTestTEERuntime across the repo and the
    published tarball matches only that comment.
  • TestTeeRuntime is not exported from packages/cre-sdk/src/sdk/test/index.ts, which is the
    only test path in the package's exports map ("./test"). src/sdk/testutils/index.ts exports it,
    but ./testutils is not an export path, so it is unreachable from an installed package.
  • Its constructor takes RuntimeHelpers, TestWriter and TestRuntimeState, none of which are
    publicly exported either, so a user cannot construct it directly even reaching past the export map.

Draft PR #247 ("Rtinianov tee runtime") is where the class came from; it is still open, while the
class itself shipped. That is what makes this look like an oversight rather than a deliberate
exclusion — happy to be told otherwise.

Why it matters

Every workflow using cre.handlerInTee has to hand-roll a TeeRuntime double. The
hello-confidential-workflows-ts template does this itself, and says so:

The public test surface does not yet ship a TEE runtime factory (newTestRuntime returns a DON
Runtime), so we stand up the small slice of TeeRuntime the handler actually uses.

Getting that double right requires reading compiled internals rather than docs. Two that cost us time:

  • .result() returns the protobuf message, not its JSON form, so a fake headerByNumber must
    return BigInt.absVal as a Uint8Array. Passing the base64 string the JSON type documents throws
    SyntaxError: Failed to parse String to BigInt from inside bytesToBigint.
  • evmClient.writeReport calls report.x_generatedCodeOnly_unwrap(), so a Report double has to
    carry that generated-code-only method.

The practical cost is that determinism — the property confidential workflows are sold on — is the
hardest thing in the SDK to unit test
, which is backwards.

Fix

PR opened: adds newTestTEERuntime mirroring newTestRuntime, exports it and TestTeeRuntime from
the public test surface, and extracts the shared registry/writer/state setup so the two factories
cannot drift apart. Four tests added; bun test, biome ci and typecheck are clean.

Versions

@chainlink/cre-sdk 1.20.0 and 1.18.0; verified against main at ec3158f.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/cre-sdk/src/sdk/testutils/test-runtime.ts and packages/cre-sdk/src/sdk/test/index.ts, then compare the existing newTestRuntime path. Check the four tests described in the issue and verify the public factory and TestTeeRuntime exports work from @chainlink/cre-sdk/test. Run bun test, biome ci, and typecheck to confirm completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.