Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Reusable EVM test fixtures

@tevm/test-utils packages compiled test contracts and shared fork transports used throughout the Tevm test suite. Reach for it when a test needs deterministic bytecode and ABI fixtures without maintaining another Solidity compilation step.

Working example

This example was run with @tevm/test-utils@1.0.0-rc.151 and viem@2.49.3.

import assert from 'node:assert/strict'
import {
	AdvancedContract,
	BlockReader,
	ErrorContract,
	SimpleContract,
	TestERC20,
	TestERC721,
	transports,
} from '@tevm/test-utils'
 
const fixtures = [AdvancedContract, BlockReader, ErrorContract, SimpleContract, TestERC20, TestERC721]
for (const fixture of fixtures) {
	assert.ok(Array.isArray(fixture.abi))
	assert.match(fixture.bytecode, /^0x[0-9a-f]+$/i)
}
assert.equal(typeof transports.optimism, 'object')
 
console.log(`contracts=${fixtures.length}`)
console.log(`simpleFunctions=${SimpleContract.abi.filter((item) => item.type === 'function').length}`)
console.log(`transports=${Object.keys(transports).sort().join(',')}`)
contracts=6
simpleFunctions=2
transports=mainnet,optimism

Exports

The package entry point in test/test-utils/src/index.ts exposes:

ExportKindPurpose
AdvancedContractCompiled contractAdvanced call and state behavior
BlockReaderCompiled contractBlock environment reads
ErrorContractCompiled contractRevert and error paths
SimpleContractCompiled contractBasic reads and writes
TestERC20Compiled contractERC-20 behavior
TestERC721Compiled contractERC-721 behavior
MUDTestSystemCompiled contractMUD integration tests
transportsObjectShared mainnet and optimism transports
getAlchemyUrlFunctionResolve the configured Alchemy endpoint

Neighbours

Local testing · Memory client · Contract reference