Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.3 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { ScriptedRpcTransport } from './scripted-rpc-transport'

// Require one physical send per logical name in call order; dropped sends must fail before mislabelling later payloads.
describe('a wrapper between the operation and the scripted transport', () => {
  it('is caught when it swallows a send, rather than mislabelling the next payload', () => {
    const transport = new ScriptedRpcTransport(
      () => 0,
      undefined,
      (client) => ({
        ...client,
        sendRequest: (...args) =>
          args[0] === 'alpha.one'
            ? Promise.reject(new Error('the wrapper kept this one'))
            : client.sendRequest(...args)
      })
    )
    void transport.client.sendRequest('alpha.one').catch(() => undefined)
    expect(() => transport.client.sendRequest('beta.two')).toThrow(/beta\.two.*alpha\.one#1/)
  })

  it('is caught when it invents a send the operation never made', () => {
    let inner: ((method: string) => Promise<unknown>) | null = null
    new ScriptedRpcTransport(
      () => 0,
      undefined,
      (client) => {
        inner = (method) => client.sendRequest(method)
        return client
      }
    )
    expect(inner).not.toBeNull()
    expect(() => inner?.('alpha.one')).toThrow(/cannot take the name \(no logical request\)/)
  })
})