Skip to content

v0.1.0

Choose a tag to compare

@nadaniels nadaniels released this 06 Nov 20:35
· 141 commits to main since this release
d37e95b

Initial release

Ethergeist - a mock Ethereum node behind a viem transport, for tests and demos. Each JSON-RPC request is answered with what the test registered; nothing executes.

Added

  • createMockRpc({ chain, blockNumber, timestamp, fees, debug }), with mock.transport() and mock.publicClient() for viem, and mock.request() for a raw JSON-RPC request.
  • Mocked contracts: mock.contract({ abi, address, defaults }), with typed read, simulate, estimateGas, and write namespaces that mirror viem's getContract. A function mock .returns() a value or a resolver, .reverts() with the ABI's errors, .fails() as a node would, and takes .once() or .times(n). Multicall3 batches are answered call by call.
  • Matching on pinned args, with match.any(), match.where(), and match.partial(): the most specific mock answers. When two are equally specific, limited ones (.once(), .times(n)) answer first, in the order they were registered; otherwise the one registered last answers.
  • Typed mocks for viem's public actions in mock.actions (balances, code, storage, blocks, transactions, receipts, logs, gas prices and fee history, nonces, estimates, and sends), and mock.method() for any other JSON-RPC method.
  • A chain that sends build on: mock.addTransaction(), mock.mine(), mock.setFees(), and contract.emit and contract.events (with contractEvents() and testLog()) for logs that getLogs(), watchers, and receipts find.
  • mock.buildTransaction(), mock.buildReceipt(), and mock.buildLog() for values in viem's types, and testAddress() and testHash() for stable test values.
  • Node failures: mock.failRequests() for HTTP errors, JSON-RPC errors, timeouts, and network failures, and named node errors (insufficient funds, nonce too low, and others) that viem sorts into its own error classes.
  • What the app asked: mock.history, mock.calls, contract.calls, mock.unhandled, mock.formatHistory(), and the debug option.
  • Checks: mock.assertNoUnhandled() and mock.assertAllUsed(), and the MockError family (MockCheckError, MockSetupError, MockNotFoundError, MockResolverError, MockInternalError) with stable error codes.
  • Shared setup: mock.checkpoint() and restore(), mock.reset(), and mock.clearCalls().
  • ESM only, for Node 22.12 or later and browsers, with viem ^2.50.3 and ox ^0.14.22 as peers, and types for TypeScript 5.8 or later.