> For the complete documentation index, see [llms.txt](https://docs.liquidcollective.io/eth/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liquidcollective.io/eth/technical-reference/tests.md).

# Tests

About the testing procedure

## Functional tests

The following functional tests are run manually with each release.

| Using       | Given                                                                                                              | When                                                  | Then                                                                                                                                                                                                                 | As a            | Feature                                                              |
| ----------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | -------------------------------------------------------------------- |
| Defender MS |                                                                                                                    | I add a Node Operator                                 | Transaction is mined AND Node Operator is added                                                                                                                                                                      | System Admin    | Add Node Operator                                                    |
| CLI         | A Node Operator has been added                                                                                     | I get the Node Operator                               | Valid count is returned                                                                                                                                                                                              | Any User        | Get Node Operator Count                                              |
| CLI         | A Node Operator has been added                                                                                     | I get Node Operator at index 0                        | Node Operator with correct information is returned                                                                                                                                                                   | Any User        | Get Node Operator                                                    |
| Defender MS | A Node Operator has been added                                                                                     | I set Node Operator at index 0 limit to 3             | Transaction is mined AND Node Operator limit is updated                                                                                                                                                              | System Admin    | Set Node Operator Limit                                              |
| CLI         |                                                                                                                    | I get withdrawal credentials                          | Prints withdrawal credentials                                                                                                                                                                                        | Any User        | Get withdrawal credentials                                           |
| CLI         | I have been added AND my limit has been set to 3                                                                   | I add 2 validators                                    | Transaction is mined AND validators are added AND operators information's are updated (in particular total count of validators is incremented by 2)                                                                  | Node Operator   | Add Validators                                                       |
| CLI         | I have been added AND my limit has been set to 3 AND I have already added 2 validators                             | I add 2 validators                                    | Transaction is mined AND validators are added AND operators information's are updated (in particular total count of validators is incremented by 2)                                                                  | Node Operator   | Add Validators over limit                                            |
| CLI         | I have been added AND my limit has been set to 3 AND I have already added 2 validators (that have not been funded) | I remove validator with idx 0                         | Transaction is mined AND validators are added AND operators information's are updated (in particular total count of validators is decremented by 1) AND validator is deleted (validator 1 should become validator 2) | Node Operator   | Remove validator before funding                                      |
| CLI         | I have been added AND another node operator as well                                                                | I add 2 validators for an operator index I do not own | Transaction is mined AND reverted                                                                                                                                                                                    | Node Operator   | Add Validator with wrong Node Operator address                       |
| CLI         | Validators have been added                                                                                         | I get validator X                                     | Validator info is returned                                                                                                                                                                                           | Any User        | Get Validator                                                        |
| Defender MS |                                                                                                                    | I set allower                                         | Transaction is mined AND allower is set                                                                                                                                                                              | System Admin    | Set allower                                                          |
| CLI         | Allower has been set                                                                                               | I get allower                                         | Allower address is returned                                                                                                                                                                                          | Any User        | Get allower                                                          |
| Defender MS |                                                                                                                    | I allow an account to status to true                  | Transaction is mined AND account is allowed                                                                                                                                                                          | System Admin    | Allow staker account                                                 |
| CLI         | Account has been allowed to status true                                                                            | I check is allowed                                    | True is returned                                                                                                                                                                                                     | Any User        | Check IsAllowed                                                      |
| UI          | I have been allowed                                                                                                | I deposit ETH                                         | Transaction is mined AND staker LsETH balance is increased AND totalSupply is increased                                                                                                                              | Staker          | Deposit                                                              |
| Defender MS | An operator as at least 1 validator available AND 33 ETH have been deposited                                       | I deposit to consensus layer with maxcount to 2       | Transaction is mined AND 1 validator get funded AND deposit contract is called AND operator information is updated AND River contract balance has decreased by 32 but totalSupply has not changed                    | System Admin    | Deposit to consensus layer                                           |
| Defender MS | One operator with limit 2 AND operator has already 1 funded validator AND 64 ETH have been deposited               | I deposit to consensus layer with maxcount to 2       | Transaction is mined AND 1 validator get funded AND deposit contract is called AND operator information is updated AND River contract balance has decreased by 32 but totalSupply has not changed                    | System Admin    | Deposit to consensus layer hitting the limit of available validators |
| CLI         | 4 validators have been added AND 2 of them have been funded                                                        | I load validators                                     | 4 validators are loaded to csv                                                                                                                                                                                       | Any User        | Load validators                                                      |
| Defender MS |                                                                                                                    | I add an Oracle member                                | Transaction is mined AND member is added                                                                                                                                                                             | System Admin    | Add Oracle Member                                                    |
| CLI         | An oracle member has been added                                                                                    | I list Oracle number count                            | Valid list of members is returned                                                                                                                                                                                    | Any User        | List Oracle Members                                                  |
| CLI         | I am an oracle member AND quorum is set to 1                                                                       | I report beacon data                                  | Transaction is mined AND data is reported to River contract                                                                                                                                                          | Oracle operator | Oracle report (quorum 1)                                             |
| CLI         | A first epoch has been reported                                                                                    | I get current epoch                                   | Should return current epoch                                                                                                                                                                                          | Any User        | Oracle epoch current                                                 |
| CLI         | A first epoch has been reported                                                                                    | I get current last-completed epoch                    | Should return last completed epoch                                                                                                                                                                                   | Any User        | Oracle epoch last-completed                                          |
| CLI         | A first epoch has been reported                                                                                    | I get expected epoch                                  | Should return next epoch to be reported                                                                                                                                                                              | Any User        | Oracle epoch expected                                                |
| Defender MS |                                                                                                                    | I set oracle quorum to 2                              | Transaction is mined AND quorum is updated                                                                                                                                                                           | System Admin    | Set Oracle quorum                                                    |
| Defender MS |                                                                                                                    |                                                       |                                                                                                                                                                                                                      | System Admin    | Set Oracle specs                                                     |
| CLI         | I am an oracle members AND quorum is set to 2                                                                      | I report beacon data for epoch X                      | Transaction is mined AND status of oracle is update AND data is not reported to River contract                                                                                                                       | Oracle operator | Oracle #1 report (quorum 2)                                          |
| CLI         | I am an oracle members AND quorum is set to 2                                                                      | I report distinct beacon data for same epoch X        | Transaction is mined AND status of oracle is update AND data is not reported to River contract                                                                                                                       | Oracle operator | Oracle #2 report distinct from #1 (quorum 2)                         |
| CLI         | I am an oracle members AND quorum is set to 2                                                                      | I report a second time for same epoch X               | Transaction is mined and reverted                                                                                                                                                                                    | Oracle operator | Oracle #2 report a second time                                       |
| CLI         | I am an oracle member AND quorum is set to 2 AND I am the 1st to report                                            | I report same beacon data as #1 for epoch X           | Transaction is mined AND data #1 is reported to River contract                                                                                                                                                       | Oracle operator | Oracle #3 report same as #1 (quorum 2)                               |

## Unit & integration tests

These tests are automated using Foundry.

### Install Rust

You can follow this guide to properly setup Rust : <https://www.rust-lang.org/tools/install>

### Clone repository

```
git clone https://github.com/liquid-collective/liquid-collective-protocol
```

### Install dependencies

```
yarn && yarn link_contracts
```

### Run full test suite

```
yarn test
```

The test suite is handled by Foundry (<https://github.com/foundry-rs/foundry>) and allows Fuzz testing out of the box. You can control the amount of fuzz tests to run per test by setting the `FOUNDRY_FUZZ_RUNS` env variable.

You can find all the tests in the `contracts/test` directory.
