This page covers the smart contract implementation details. See Glossary.
Prerequisites
- Foundry installed and configured
- A Vehicle contract implementing
IVehicle - Familiarity with the STEAM standard
Create the base test contract
Create a test file attest/vehicles/<your_vehicle>/<YourVehicle>Vehicle.t.sol. Inherit from STEAMSingleAssetTester to get the full STEAM test suite.
Configure the test environment
Override internal hooks to provide optional components. By default, these returnaddress(0).
Add vehicle-specific tests
WhileSTEAMSingleAssetTester covers the state machine, add tests for your protocol-specific logic.
Test composition pattern
Test your Vehicle across different configurations by creating variant files that override the hooks.Key helper methods
Use these fromSTEAMSingleAssetTester in your custom tests:
| Helper | Description |
|---|---|
_get_and_prepare_query(user, receiver, mode, amount, salt) | Deals tokens, approves the Vehicle, returns a Query struct |
_get_run_config(query) | Returns a RunConfig for executing the query through the state machine |
_compute_amount(uint256) | Bounds a raw value to a reasonable test range (1 to 1000 units) |
_unit(count) | Converts a count to the asset’s decimals (e.g., _unit(1) = 1e18 for WETH) |
Inherited test categories
When you inherit fromSTEAMSingleAssetTester, you automatically get tests for:
- State machine — all valid and invalid state transitions
- Input validation — zero amounts, invalid assets, unauthorized receivers
- Access control — only the query owner or authorized roles can trigger transitions
- Fee handling — deposit and redeem fees correctly applied
- Module execution — interaction with protocol modules via
ModulesManager