Skip to content

Commit

Permalink
Merge pull request #395 from alephium/doc/expectAssertionError
Browse files Browse the repository at this point in the history
Doc expectAssertionError
  • Loading branch information
polarker authored Jun 21, 2024
2 parents 9e33120 + c299f3f commit fe91c46
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/sdk/testing-and-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,17 @@ node log.
Under the hood, `Debug` is a special [system
events](/sdk/events#system-events) which is only available in
[devnet](/full-node/getting-started#devnet).

## Checking Assertion Error

To check for assertion errors during contract execution, use the helper function `expectAssertionError(p, address, errorCode)`. This function verifies that a specific assertion error occurs.

* `p`: The execution promise
* `address`: The address of the contract where the error occurred
* `errorCode`: The error code at the position of failure

Example usage:

```
await expectAssertionError(TokenFaucet.tests.withdraw(testParams), testContractAddress, 0)
```

0 comments on commit fe91c46

Please sign in to comment.