Skip to content

feat: implement SorobanOracle with local RPC integration harness - #108

Open
jiggy-techy wants to merge 3 commits into
Gryd-lock:mainfrom
jiggy-techy:fix/issue-92-soroban-integration-harness
Open

feat: implement SorobanOracle with local RPC integration harness#108
jiggy-techy wants to merge 3 commits into
Gryd-lock:mainfrom
jiggy-techy:fix/issue-92-soroban-integration-harness

Conversation

@jiggy-techy

Copy link
Copy Markdown

Closes #92

Summary

Implements the SorobanOracle live client and a self-contained local Soroban integration harness that verifies it against a Soroban-RPC-shaped endpoint with no external network access.

SorobanOracle (src/SorobanOracle.ts)

  • Builds and simulates the risk-oracle contract's get_score(destination) invocation via Soroban RPC (simulateTransaction); it is never submitted, so no signing keys are required.
  • Decodes the returned 0-100 score and maps every failure to the shared OracleError hierarchy: malformed destination → InvalidDestinationError, unknown/reverted destination → UnrecognizedDestinationError, unreachable/failing RPC → OracleUnavailableError, slow response → OracleTimeoutError, non-numeric or out-of-range return → ContractIncompatibilityError.
  • getScoreDetailed returns live provenance metadata (source: 'soroban', cacheStatus: 'live').
  • Deliberately not exported from src/index.ts to preserve the bundle-size tree-shaking guarantee (scripts/bundle-size.mjs); typedoc only scans src/index.ts.

Local integration harness (tests/integration/)

  • riskOracleFixture.ts — representative get_score(string) -> u32 contract fixture backed by the same vendored grydlock-testkit scores StubOracle uses.
  • sorobanRpcHarness.ts — in-process HTTP Soroban RPC fixture server bound to 127.0.0.1 emulating simulateTransaction/getHealth, with behavior knobs for contract reverts, malformed return values, delays, and HTTP failures.
  • SorobanOracle.integration.test.ts — 11 tests covering valid scores, invalid/unknown destinations, malformed responses, RPC failures, and timeouts.
  • Runs via npm run test:integration and as a required integration CI job, separate from the fast unit suite (tests/integration/** excluded from vitest.config.ts).

Verification

  • typecheck, lint, build, docs:check pass
  • test:integration: 11/11 pass
  • npm test: 215 passed; 2 pre-existing failures in fixtureText.sync.test.ts (Windows CRLF checkout artifact, verified identical on the base commit)
  • bundle-size: "StubOracle only" 9.57 KB under budget; the "full barrel" 14.99 KB exceeds its 14.00 KB budget — pre-existing upstream, verified identical on the base commit

Implements the SorobanOracle live client (issue Gryd-lock#92): builds and simulates
the risk-oracle contract's get_score invocation via Soroban RPC, decodes the
returned 0-100 score, and maps failures to the shared OracleError hierarchy.

Adds a self-contained local integration harness (tests/integration) that
emulates a Soroban RPC endpoint in-process over HTTP and drives the real
get_score boundary - including invalid/unknown destinations, contract reverts,
malformed responses, RPC failures, and timeouts - with no external network
access. The suite runs via npm run test:integration and as a required CI job
separate from the fast unit tests.

Closes Gryd-lock#92
@knytcomics-ui

Copy link
Copy Markdown
Contributor

hello good day,please some tests are failing,please rectify

@knytcomics-ui

Copy link
Copy Markdown
Contributor

please pass failing tests

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.

Add a local Soroban integration harness and CI contract tests

3 participants