koral
Menu
Documentation pages

KORAL / TESTING & ERRORS

Testing and errors

Use the test that matches the program. The CLI's test command is deliberately Counter-only.

Compiler tests

From the utility source checkout:

./gradlew test :cli:installDist

Compiler tests check model serialization, validation, checked operations, control flow, and related compiler behavior. They do not replace native execution checks.

Counter verification

npm ci --prefix cli/build/install/koral/testing
cli/build/install/koral/bin/koral test build/counter/counter.so

Build the typed Counter first. The verifier exercises the native artifact in local LiteSVM with deterministic test signers. No mainnet transaction or wallet connection is involved.

Payment verification

cli/build/install/koral/bin/koral build examples/payments.kt --out build/payments
node cli/build/install/koral/testing/payments.mjs build/payments/counter.so build/payments/tests.json

Use the bundled payments verifier for this exact example, not koral test. The payment checks inspect actual local balances, reads after CPI, permissions, duplicate references, and rollback on failure.

Broader integration checks

npm ci --prefix testing
node testing/verify.mjs cli/build/install/koral/bin/koral "$KORAL_SBF_SDK"

This source-checkout harness builds multiple programs and checks source changes, expected rejections, failed-rebuild artifacts, and local behavior. Benchmark reproduction is separate; recorded CU is not a general throughput or security claim.

Common failures

Message or resultWhat to inspect
Set KORAL_SBF_SDK or pass --sdkLocal SDK environment or explicit build option
Invalid SDKc/sbf.ld and dependencies/platform-tools/llvm/bin/clang
Missing compiler plugin JARUse the installed CLI distribution, not an ad hoc class directory
Unsupported callUse supported trusted operations; ordinary wrapping arithmetic is rejected
Every instruction path must returnReturn the declared state type on every branch
Missing test runnerPreserve the installed testing directory and install its Node dependencies
Tool timed outThe compiler/native tool step exceeded its bounded timeout

Selected runtime error codes

CodeMeaning in the current Koral runtime
102Invalid instruction or serialized input data
2006Initialization PDA does not match the canonical address
2040Initialization authority and state alias
3002State discriminator mismatch
3003State data too short
3005Required accounts missing
3006Required writable permission missing
3007State account owner mismatch
3008Invalid System Program address or executable flag
3010Required signer missing
5100Checked arithmetic overflow or underflow
6000Stored state authority mismatch

System Program errors may also propagate from CPI; this table is not a complete Solana error catalog or a stable public error specification. A custom ensure code may reuse a numeric value, so inspect the actual source too. Passing local checks is not an audit.

Implementation basis: testing/, CompilerTest.kt, cli/Main.kt, and runtime/src/counter.c.