Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 006f6eb

Browse files
authored
Mention functions and test compatibility
Tests must return to avoid executing code that exists after them. This issue arises when a function is declared in the contract, leading to all tests failing as they execute function code, resulting in stack underflows. This can be resolved by including a return statement at the end of every test.
1 parent 81e25a8 commit 006f6eb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/get-started/huff-by-example/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,12 @@ Available decorators include:
521521
* `calldata` - Set the calldata for the transaction environment. Accepts a single string of calldata bytes.
522522
* `value` - Set the callvalue for the transaction environment. Accepts a single literal.
523523

524+
#### Testing with functions
525+
526+
Huff functions are appended at the end of the contract bytecode, which may conflict with the execution of the tests, as function code may be executed after them.
527+
528+
Always include a return statement at the end of each of your tests to ensure compatibility with functions.
529+
524530
#### Example
525531
```plaintext
526532
#include "huffmate/utils/Errors.huff"
@@ -536,5 +542,7 @@ Available decorators include:
536542
0x00 calldataload // [0x01]
537543
callvalue // [0x01, 0x01]
538544
eq ASSERT()
545+
546+
0x00 0x00 return
539547
}
540548
```

0 commit comments

Comments
 (0)