mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 02:27:43 +00:00
Group isolated contract suites behind explicit entrypoints to reduce repeated Vitest startup, consolidate RPC coverage without changing cases, and remove duplicate script assertions and child processes.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
structuredAgentSessionDomainFingerprint,
|
|
structuredAgentSessionPayloadFingerprint
|
|
} from './structured-agent-session-mutation'
|
|
import { computeAgentSessionPayloadFingerprint } from './agent-session-mutation-envelope'
|
|
|
|
describe('structured agent session client mutations', () => {
|
|
it('canonicalizes payload fields before hashing', () => {
|
|
const first = structuredAgentSessionPayloadFingerprint({
|
|
method: 'agentSession.send',
|
|
sessionId: 'session-1',
|
|
fields: { body: { role: 'user', kind: 'message' }, omitted: undefined }
|
|
})
|
|
const second = structuredAgentSessionPayloadFingerprint({
|
|
method: 'agentSession.send',
|
|
sessionId: 'session-1',
|
|
fields: { body: { kind: 'message', role: 'user' } }
|
|
})
|
|
|
|
expect(first).toBe(second)
|
|
expect(first).toMatch(/^[a-f0-9]{64}$/)
|
|
})
|
|
|
|
it('matches host code-unit ordering for mixed-case and non-ASCII keys', () => {
|
|
const input = {
|
|
method: 'agentSession.send',
|
|
sessionId: 'session-1',
|
|
fields: { a: 1, A: 2, é: 3, 中: 4 }
|
|
}
|
|
|
|
expect(structuredAgentSessionPayloadFingerprint(input)).toBe(
|
|
computeAgentSessionPayloadFingerprint(input)
|
|
)
|
|
})
|
|
|
|
it('preserves the digest when a local fingerprint domain is not an RPC method', () => {
|
|
const fields = { text: 'hello' }
|
|
|
|
expect(
|
|
structuredAgentSessionDomainFingerprint({
|
|
domain: 'mobile.agentSession.send.intent',
|
|
sessionId: 'session-1',
|
|
fields
|
|
})
|
|
).toBe(
|
|
structuredAgentSessionPayloadFingerprint({
|
|
method: 'mobile.agentSession.send.intent',
|
|
sessionId: 'session-1',
|
|
fields
|
|
})
|
|
)
|
|
})
|
|
})
|