Rust: Channel Receiver
Surfnet::events() returns a reference to the
crossbeam_channel::Receiver<SimnetEvent> that the runtime publishes to. Drain
it with try_iter() (non-blocking) or read individual events with recv() /
recv_timeout().
Receiver is sharedIf you spawn a background task to consume events, do not also call
try_iter
from the main thread. Events will be split unpredictably between the two
consumers.JS: Drain Method
The JS bindings buffer events internally and expose them throughdrainEvents.
Each call returns whatever has accumulated since the previous call, then clears
the buffer.
Unbounded bufferIf you never call
drainEvents, the buffer grows for the life of the
instance. That’s fine for short tests, but call it periodically for
long-running fixtures so memory doesn’t balloon.SimnetEventValue Shape (JS)
The JS event type is a flat object with akind discriminator and optional
fields. Not every field is set on every variant — destructure based on kind.
Event Kinds
Kind strings on the JS side are camelCase; the matching Rust variant uses PascalCase. Match on these exact strings — they’re case-sensitive and stable across versions.JS kind | Rust variant | Emitted when |
|---|---|---|
ready | SimnetEvent::Ready | The runtime finishes booting; carries initialTransactionCount. |
connected | SimnetEvent::Connected | Connected to the upstream remote RPC; carries message (the URL). |
aborted | SimnetEvent::Aborted | Startup was aborted; carries message (the reason). |
shutdown | SimnetEvent::Shutdown | A graceful shutdown begins. |
systemClockUpdated | SimnetEvent::SystemClockUpdated | The system clock advanced; carries clock. |
clockUpdate | SimnetEvent::ClockUpdate | A clock command ran (pause/resume/update interval); carries clockCommand and optionally slotIntervalMs. |
epochInfoUpdate | SimnetEvent::EpochInfoUpdate | A new epoch info snapshot is available; carries epochInfo. |
blockHashExpired | SimnetEvent::BlockHashExpired | A blockhash that was in use has expired. |
transactionReceived | SimnetEvent::TransactionReceived | A transaction was queued; carries timestamp, transactionSignature. |
transactionProcessed | SimnetEvent::TransactionProcessed | A transaction was executed; carries timestamp, transactionSignature, logs, computeUnitsConsumed, fee, and errorMessage on failure. |
accountUpdate | SimnetEvent::AccountUpdate | An account changed — covers streamed accounts and cheatcode-driven mutations; carries timestamp and accountPubkey. |
infoLog / warnLog / errorLog / debugLog | SimnetEvent::InfoLog / WarnLog / ErrorLog / DebugLog | The runtime emitted a log line; carries timestamp and message. |
pluginLoaded | SimnetEvent::PluginLoaded | A Geyser plugin loaded; carries message (the plugin name). |
taggedProfile | SimnetEvent::TaggedProfile | A profiler result was tagged; carries tag, profileKey, profileSlot, logs, computeUnitsConsumed. |
runbookStarted / runbookCompleted | SimnetEvent::RunbookStarted / RunbookCompleted | A runbook started or finished; carries runbookId and (on completion) optional runbookErrors. |
Assertion Patterns
Assert A Transaction Landed
Assert No Runtime Errors Occurred
Why Events Beat Log Parsing
Prefer the event stream over stdoutThe runtime prints structured events through
tracing, which can be tempting to capture and parse from stdout. Don’t. The structured event stream:- Survives log-level changes — events are emitted regardless of
RUST_LOG. - Comes with typed payloads — no string parsing, no format drift between versions.
- Has stable kinds — log lines are formatted for humans and change freely; event kinds are part of the SDK contract.