Interactive CLI for testing Ottochain state machines and scripts. This terminal provides a comprehensive testing framework with transaction generation, signing, sending, and validation.
The Ottochain Terminal provides a command-line interface for:
- State Machine Management: Create, process events, and archive state machine fibers
- Script Management: Create and invoke scripts
- Full Testing Cycle: Fetch initial state, send transactions, and validate final state
- CI/CD Ready: Subcommand-based architecture suitable for automated testing
cd e2e-test
npm installnpm run terminal:listnpm run terminal -- state-machine create \
--definition resources/state-machines/simple-order.json \
--initialData resources/state-machines/initial-data-order.jsonnpm run terminal -- state-machine process-event \
--address <CID-from-previous-step> \
--event resources/state-machines/events/confirm-order.json \
--expectedState confirmednpm run terminal -- oracle create \
--oracle resources/oracles/calculator-oracle.jsonnpm run terminal -- oracle invoke \
--address <CID-from-create-step> \
--method add \
--args resources/oracles/invoke-args-add.json \
--expectedResult '15'Create a new state machine fiber.
Required Options:
--definition <path>: Path to state machine definition JSON file--initialData <path>: Path to initial data JSON file
Optional:
--parentFiberId <uuid>: Parent fiber ID for hierarchical state machines
Example:
node terminal.js state-machine create \
--definition resources/state-machines/approval-workflow.json \
--initialData resources/state-machines/initial-data-approval.jsonProcess an event on an existing state machine fiber.
Required Options:
--event <path>: Path to event JSON file
Optional:
--expectedState <state>: Expected resulting state for validation
Example:
node terminal.js sm event \
--address 7065df56-2eba-49bd-8d55-69c3ead89e05 \
--event resources/state-machines/events/ship-order.json \
--expectedState shippedArchive a state machine fiber.
Example:
node terminal.js sm archive \
--address 7065df56-2eba-49bd-8d55-69c3ead89e05Create a new script.
Required Options:
--oracle <path>: Path to oracle definition JSON file
Example:
node terminal.js oracle create \
--oracle resources/oracles/counter-oracle.jsonInvoke a method on an existing script.
Required Options:
--method <name>: Method name to invoke
Optional:
--args <path>: Path to arguments JSON file--expectedResult <json>: Expected result for validation
Example:
node terminal.js or invoke \
--address abc123... \
--method increment \
--expectedResult '{"count":1}'List available example resources.
Optional:
--type <type>: Filter by type:state-machines,oracles, orevents
Examples:
node terminal.js list
node terminal.js list --type oraclesThese options apply to all commands:
--address <uuid>: Use a specific UUID for the resource (default: random UUID)--wallets <list>: Comma-separated signers:alice,bob,charlie,diane,james(default:alice)
--target <env>: Target environment:local,remote, orci(default:local)
--mode <mode>: Operation mode (default:send+validate)send: Only send transaction (fire-and-forget)validate: Only validate existing state (no transaction sent)send+validate: Full cycle - send and validate
--waitTime <N>: Seconds to wait after sending before validation (default:5)--retryDelay <N>: Seconds between validation retries (default:3)--maxRetries <N>: Maximum validation retry attempts (default:5)
CID=$(uuidgen)
node terminal.js sm create \
--address $CID \
--definition resources/state-machines/simple-order.json \
--initialData resources/state-machines/initial-data-order.jsonnode terminal.js sm event \
--address $CID \
--event resources/state-machines/events/confirm-order.json \
--expectedState confirmednode terminal.js sm event \
--address $CID \
--event resources/state-machines/events/ship-order.json \
--expectedState shippednode terminal.js oracle create \
--oracle resources/oracles/calculator-oracle.json \
--wallets alice,bob,charlienode terminal.js sm create \
--definition resources/state-machines/simple-order.json \
--initialData resources/state-machines/initial-data-order.json \
--mode send \
--target cinode terminal.js oracle invoke \
--address abc123... \
--method add \
--args resources/oracles/invoke-args-add.json \
--mode validate{
"states": {
"state_id": {
"id": { "value": "state_id" },
"isFinal": false,
"metadata": null
}
},
"initialState": { "value": "state_id" },
"transitions": [
{
"from": { "value": "state_a" },
"to": { "value": "state_b" },
"eventType": { "value": "event_name" },
"guard": { "==": [1, 1] },
"effect": { "merge": [{ "var": "data" }, { "var": "payload" }] },
"dependencies": []
}
],
"metadata": {
"name": "MachineName",
"description": "Description"
}
}{
"eventType": { "value": "event_name" },
"payload": {
"field1": "value1",
"field2": "value2"
},
"idempotencyKey": null
}{
"scriptProgram": {
"if": [
{ "==": [{ "var": "method" }, "methodName"] },
{ "return": "expression" },
{ "error": "Unknown method" }
]
},
"initialState": {
"field": "value"
},
"accessControl": {
"Public": {}
}
}The terminal is designed for CI/CD pipelines:
- name: Test State Machine Creation
run: |
cd e2e-test
npm run terminal -- sm create \
--definition resources/state-machines/simple-order.json \
--initialData resources/state-machines/initial-data-order.json \
--target ci \
--mode send+validate \
--maxRetries 100: Success1: Failure (transaction or validation error)
Transaction fails to send:
- Check that the metagraph is running (use
--target local/remote/ciappropriately) - Verify wallet configuration in environment
Validation times out:
- Increase
--maxRetriesand--retryDelay - Check metagraph health
Resource file not found:
- Use absolute paths or paths relative to
e2e-test/directory - Run
npm run terminal:listto see available resources
For verbose output, examine the console logs which show:
- Client request JSON (signed transaction)
- Node responses
- Validation attempts and state comparisons
- State Machines: Add to
resources/state-machines/ - Events: Add to
resources/state-machines/events/ - Oracles: Add to
resources/oracles/
To add new operations:
- Create generator/validator in
lib/state-machine/orlib/oracle/ - Add command to
terminal.js - Update this README
terminal.js (main CLI)
├── lib/state-machine/
│ ├── createFiber.js (generator + validator)
│ ├── processEvent.js (generator + validator)
│ └── archiveFiber.js (generator + validator)
├── lib/oracle/
│ ├── createOracle.js (generator + validator)
│ └── invokeOracle.js (generator + validator)
├── lib/ (shared utilities)
│ ├── generateProof.js
│ ├── generateWallet.js
│ ├── sendDataTransaction.js
│ └── metagraphEnv.js
└── resources/
├── state-machines/
├── oracles/
└── state-machines/events/
ISC