chore(workspace): Rust workspace R0 — builder image, core crate (JS-compatible JSON, report contracts, facade), wasm facade, core-wasm package with proofs
This commit is contained in:
1 parent
5fec0654d3
commit
2a38fa37b5
39 files changed
+1913
-1
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { callCore, loadCore } from '../src/index'
|
||||
import { coreBuilt } from './helpers/core'
|
||||
|
||||
const CORE_MANIFEST = new URL(
|
||||
'../../../crates/core/Cargo.toml',
|
||||
import.meta.url,
|
||||
)
|
||||
const WORKSPACE_MANIFEST = new URL('../../../Cargo.toml', import.meta.url)
|
||||
|
||||
describe.skipIf(!coreBuilt)('core facade (wasm)', () => {
|
||||
it('reports the workspace version of the core', async () => {
|
||||
const core = await loadCore()
|
||||
const workspace = readFileSync(fileURLToPath(WORKSPACE_MANIFEST), 'utf8')
|
||||
const version = /\[workspace\.package\][^[]*?version = "([^"]+)"/s.exec(
|
||||
workspace,
|
||||
)?.[1]
|
||||
expect(version).toBeDefined()
|
||||
expect(readFileSync(fileURLToPath(CORE_MANIFEST), 'utf8')).toContain(
|
||||
'version.workspace = true',
|
||||
)
|
||||
expect(core.core_version()).toBe(version)
|
||||
})
|
||||
|
||||
it('answers with a closed outcome envelope', async () => {
|
||||
const core = await loadCore()
|
||||
expect(callCore(core, 'core_version', '')).toEqual({
|
||||
ok: true,
|
||||
value: core.core_version(),
|
||||
})
|
||||
expect(callCore(core, 'nope', '{}')).toMatchObject({
|
||||
ok: false,
|
||||
kind: 'unknown_op',
|
||||
})
|
||||
expect(callCore(core, 'pretty_json', '{ not json')).toMatchObject({
|
||||
ok: false,
|
||||
kind: 'invalid_json',
|
||||
})
|
||||
})
|
||||
|
||||
it('exposes exactly the documented functions', async () => {
|
||||
const core = await loadCore()
|
||||
for (const name of [
|
||||
'core_version',
|
||||
'call',
|
||||
'panic_for_test',
|
||||
'recurse_for_test',
|
||||
]) {
|
||||
expect(typeof (core as unknown as Record<string, unknown>)[name]).toBe(
|
||||
'function',
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user