-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
# Custom Error Test Helper | ||
|
||
Library for testing Solidity custom errors with Truffle/Ganache. | ||
Library for testing Solidity custom errors with [Truffle](https://trufflesuite.com/truffle)/[Ganache](https://github.com/trufflesuite/ganache/releases). | ||
|
||
## Usage: | ||
## Installation | ||
|
||
WIP | ||
```bash | ||
npm install --save-dev custom-error-test-helper | ||
``` | ||
|
||
## Usage | ||
|
||
Import `custom-error-test-helper` in your test files to access the assertion. | ||
|
||
```js | ||
const { expectRevertCustomError } = require("custom-error-test-helper"); | ||
|
||
const MyContract = artifacts.require("MyContract"); | ||
|
||
contract("MyContract", function (accounts) { | ||
beforeEach(async function () { | ||
this.contract = await MyContract.new(); | ||
}); | ||
|
||
it("reverts with an error with no parameters", async function () { | ||
// error SomeError0(); | ||
await expectRevertCustomError(MyContract, this.contract.someFunction0(), "SomeError0"); | ||
}); | ||
|
||
it("reverts with an error with parameters", async function () { | ||
// error SomeError1(uint256 one, address vb); | ||
await expectRevertCustomError(MyContract, this.contract.someFunction1(), "SomeError1", [ | ||
1, | ||
"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B", | ||
]); | ||
}); | ||
}); | ||
``` |