OpenZeppelin Test Helpers
Assertion library for Ethereum smart contract testing. Make sure your contracts behave as expected.
- Check that transactions revert for the correct reason
- Verify that events were emitted with the right values
- Track balance changes elegantly
- Handle very large numbers
- Simulate the passing of time
Test Helpers integrates seamlessly with OpenZeppelin Test Environment, but it also supports Truffle tests and regular web3 workflows.
npm install --save-dev @openzeppelin/test-helpers
@openzeppelin/test-helpers in your test files to access the different assertions and utilities.
Note: The following snippet uses OpenZeppelin Test Environment: a Truffle-based setup would work the same way.
const accounts contract = ;constBN // Big Number supportconstants // Common constants, like the zero address and largest integersexpectEvent // Assertions for emitted eventsexpectRevert // Assertions for transactions that should fail} = ;const ERC20 = contract;;
- Head to Configuration for advanced settings.
- For detailed usage information, take a look at the API Reference.