- Fix
snapshot.restore
when used multiple times.
- Add missing export of
snapshot
module.
- Changed
send.ether
so it no longer forcesgasPrice: 0
.
NOTE: This may break some tests but gas price 0 is no longer valid since the London hard fork.
- Added
tracker.deltaWithFees
.
- Added new
snapshot
module to capture and revert blockchain state.
- Fixed
expectRevert
for latest versions of Hardhat.
- Updated
@truffle/contract
dependency.
- Updated
@openzeppelin/contract-loader
dependency.
- Fixed
expectRevert
for Hardhat. (#131)
- Made
expectEvent
return the event that was found. (#129) - Fix
expectEvent.inTransaction
when there are conflicting events. (#133)
The fix to expectEvent.inTransaction
may break some tests that were not using the API as intended, or which were causing a false positive assertion. If the emitter
argument was a contract instance, the event that the assertion found in the transaction was not guaranteed to have originated in that particular contract instance at that address, it could also have generated in a different instance of the same contract. This is no longer the case, and may be the cause of a test breaking after the update.
- Deprecated
expectEvent.not
in favor ofexpectEvent.notEmitted
. (#121) - Added
expectEvent.notEmitted()
for asserting absence of events in Truffle or Web3 receipts. (#121)
These changes are only necessary to get rid of the new deprecation warning.
-
If you have a receipt:
await expectEvent.not.inTransaction(receipt.tx, contract, event)
becomesexpectEvent.notEmitted(receipt, event)
. -
If you don't have a receipt, you can continue using
inTransaction
, but throughnotEmitted
:expectEvent.not.inTransaction
becomesexpectEvent.notEmitted.inTransaction
.
- Added function
advanceBlockTo
. (#94) - Added
expectEvent.not
support to test negative cases. (#104) - Added
constants.ZERO_BYTES32
. (#110)
- Fixed some RPC calls not having an
id
field. (#92) - Added
singletons
configuration and renamed theenvironment
option tosingletons.abstraction
. (#96)
- Fixed a bug in the
chai-bn
setup. (#85)
- Removed the requirement to install
chai
when using the library. (#84)
- Removed check for truffle environments on configure due to issues with truffle migrations.
- Renamed the package to
@openzeppelin/test-helpers
. (#78) - Removed hard-dependency on
truffle-contract
(#75):- An
environment
option was added toconfigure
, and can be set to eitherweb3
ortruffle
(default isweb3
, but there is automatic detection of atruffle
environment) singletons
returnweb3 Contract
instances whenenvironment
is set toweb3
expectEvent.inLogs
was deprecated in favor ofexpectEvent
, which receives the full receipt object (not just the logs), and supports both web3 and truffle contract receipts
- An
- Improved how revert reason checks (
expectRevert
) are handled on unsupported environments. (#80) - Breaking:
configure
'sweb3
argument was removed and replaced byprovider
, which can be either a web3 provider or a connection string. The default ishttp://localhost:8545
, unless a globalweb3
instance is found, in which caseweb3.currentProvider
is used. - Add optional
unit
argument tobalance
functions. (#79)
The package has been renamed to @openzeppelin/test-helpers
, so please uninstall openzeppelin-test-helpers
and reinstall it with the new name.
npm remove openzeppelin-test-helpers
npm install --save-dev @openzeppelin/test-helpers
If you are using openzeppelin-test-helpers
in a Truffle environment with automatic configuration, there is nothing you need to do. If you were manually configuring a web3
instance, you will need to configure the provider
instead. The specifics will depend on your setup, but the following should get you started.
-require('openzeppelin-test-helpers/configure')({ web3: myWeb3 });
+require('@openzeppelin/test-helpers/configure')({ provider: myWeb3.currentProvider });
Additionally, Truffle migrations require explicit environment configuration, since automatic detection does not work.
require('@openzeppelin/test-helpers/configure')({ provider: web3.currentProvider, environment: 'truffle' });
- Upgraded web3-utils and truffle-contract dependencies to use the stable web3 release. (#65)
- Added support for web3 ^1.2.0 (included by truffle v5.0.29). (#63)
- Fixed
shouldFail.reverting.withMessage
on non-Ganache chains. (#25) - Fixed
send.transaction
not working on contracts with a fallback function. (#26) - Made
shouldFail.reverting.withMessage
fail if no error string was provided. (#28) - Renamed
makeInterfaceId
tomakeInterfaceId.ERC165
, and addedmakeInterfaceId.ERC1820
. (#21) - Added possibility to configure a custom web3 instance. (#38)
- Replaced
shouldFail
withexpectRevert
, with an improved API. (#39) - Fixed detection of Ganache pre-releases (such as those used by Ganache GUI v2.0.1). (#46)
- Change all occurences of
makeInterfaceId
tomakeInterfaceId.ERC165
. - The
shouldFail
module has been renamed toexpectRevert
, andreverting.withMessage
is now the main module export.
0.3 | 0.4 |
---|---|
shouldFail.reverting.withMessage |
expectRevert |
shouldFail.reverting |
expectRevert.unspecified |
shouldFail.throwing |
expectRevert.invalidOpcode |
shouldFail.outOfGas |
expectRevert.outOfGas |
- Updated ERC1820Registry address. (#26)
- Added support for environments using
web3-provider-engine
. (#24)
chai
is no longer exported, andshould
is no longer automatically installed. (#18)
If you use Chai assertions in your project you should make sure to explicitly install it: npm install chai
. If you need to access the chai
instance you should now get it through require('chai')
. If you use should
-style assertions you should set it up manually now, by adding require('chai/register-should')
in your tests, or e.g. in your Truffle config. Check out OpenZeppelin's upgrade commit in case it might be helpful: cf7375d
.