Repository navigation
v0.1.0
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 }), withmock.transport()andmock.publicClient()for viem, andmock.request()for a raw JSON-RPC request.- Mocked contracts:
mock.contract({ abi, address, defaults }), with typedread,simulate,estimateGas, andwritenamespaces that mirror viem'sgetContract. 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(), andmatch.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), andmock.method()for any other JSON-RPC method. - A chain that sends build on:
mock.addTransaction(),mock.mine(),mock.setFees(), andcontract.emitandcontract.events(withcontractEvents()andtestLog()) for logs thatgetLogs(), watchers, and receipts find. mock.buildTransaction(),mock.buildReceipt(), andmock.buildLog()for values in viem's types, andtestAddress()andtestHash()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 thedebugoption. - Checks:
mock.assertNoUnhandled()andmock.assertAllUsed(), and theMockErrorfamily (MockCheckError,MockSetupError,MockNotFoundError,MockResolverError,MockInternalError) with stable error codes. - Shared setup:
mock.checkpoint()andrestore(),mock.reset(), andmock.clearCalls(). - ESM only, for Node 22.12 or later and browsers, with viem
^2.50.3and ox^0.14.22as peers, and types for TypeScript 5.8 or later.