From c299f3f3638bcab1b16b3de079243bad7ab2f49c Mon Sep 17 00:00:00 2001 From: Cheng Wang Date: Fri, 21 Jun 2024 23:31:28 +0200 Subject: [PATCH] Doc expectAssertionError --- docs/sdk/testing-and-debugging.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/sdk/testing-and-debugging.md b/docs/sdk/testing-and-debugging.md index 7cc9d472..741ccb40 100644 --- a/docs/sdk/testing-and-debugging.md +++ b/docs/sdk/testing-and-debugging.md @@ -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) +```