Skip to content

Commit 24547f9

Browse files
author
isk.eth
authored
Feature/enhance docs (#1) (#120)
* fix: adding toc to testing modes md * fix: adding toc for the common testing approaches md
1 parent 8977da8 commit 24547f9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

program-analysis/echidna/common-testing-approaches.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ we take care to avoid breaking some important underlying assumptions of transact
77
That is why it is important to have a clear view of the system to test, and how transactions are going to be simulated. There are a few classifications for the testing approach.
88
We will start by two them, internal or external:
99

10+
**Table of contents:**
11+
- [Common testing approaches](#common-testing-approaches)
12+
- [Internal testing](#internal-testing)
13+
- [External testing](#external-testing)
14+
- [Partial testing](#partial-testing)
15+
1016
## Internal testing
1117
In this testing approach, properties are defined inside the contract to test, with complete access to the internal state of the system.
1218

@@ -103,7 +109,7 @@ filterFunctions: [“MockERC20.mint(uint256,address)”]
103109
Finally, there is another benefit for using this approach: it will force the developer or auditor to write properties using public data.
104110
If an important property cannot be defined using public data, it could be an indication that users or other contracts will NOT be able to easily interact with the system to either perform some operation or verify that the system is in a valid state.
105111
106-
### Partial Testing
112+
## Partial testing
107113
108114
Ideally, testing a smart contract system uses the complete deployed system, with the same parameters that the developers intend to use.
109115
Testing with the real code, it is always preferred, even if it is slower than doing something else (but perhaps not in the case that it is extremely slow).

program-analysis/echidna/testing-modes.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Since Echidna offers several ways to write properties, often developers or auditors are wondering which testing mode should use. We will review how each mode works, as well as their advantages or disadvantages.
44

5+
**Table of contents:**
6+
- [Boolean properties](#boolean-properties)
7+
- [Assertions](#assertions)
8+
- [Dapptest](#dapptest)
9+
- [Stateless vs Stateful](#stateless-vs-stateful)
10+
511
## Boolean properties
612

713
By default, the "property" testing mode is used, which reports failures using a special functions called properties:
@@ -110,7 +116,7 @@ function testStake(uint256 toStake) public {
110116

111117
`testStake` checks some invariants on staking, but also ensures that the state of the contract is properly updated (e.g only allowing a user to stake at least `MINSTAKE`).
112118

113-
### Dapptest
119+
## Dapptest
114120

115121
Using the "dapptest" testing mode, Echidna will report violations using certain functions following how dapptool and foundry work:
116122
* This mode uses any function name with one or more arguments, which will trigger a failure if they revert, except in one special case. This is, if the execution reverts with the special reason “FOUNDRY::ASSUME”, then the test will pass (this emulates how [the `assume` foundry cheat code works](https://github.com/gakonst/foundry/commit/7dcce93a38345f261d92297abf11fafd6a9e7a35#diff-47207bb2f6cf3c4ac054647e851a98a57286fb9bb37321200f91637262d3eabfR90-R96)). This pseudo-code summarizes how dapptests work:

0 commit comments

Comments
 (0)