---
# System prepended metadata

title: Casimir Hacken
tags: [guide]

---

## About

This guide covers the steps needed for Hacken to run contract tests and development scripts. The [repository root README.md](https://github.com/consensusnetworks/casimir/tree/master#readme) provides further details on development prerequisites and operations. The [@casimir/ethereum README.md](https://github.com/consensusnetworks/casimir/tree/master/contracts/ethereum#readme) contains the latest documentation for the contracts and protocol.

## Commit Hashes

Commit hashes are provided for each stage of the audit. The tests and development scripts failed in the first commit (freeze contract code) due to missing guides and configuration for external developers, but they should succeed in the following ones. The latest commit in the this list will match the latest commit in `audit/hacken`.

1. [Freeze contract code](https://github.com/consensusnetworks/casimir/commit/4a4ab39b7d1faec2ffb6b3a26e633b084343f3f4): `4a4ab39`
2. [Remediate contract findings](https://github.com/consensusnetworks/casimir/tree/0fe38a15f6accc775bae8a11855549cd9ce8008b): `0fe38a1`
3. [Reorder contract code](https://github.com/consensusnetworks/casimir/tree/4f246eb6ee269c3a0bffebdd41c05543b424f4a3): `4f246eb`
4. [Report test coverage](https://github.com/consensusnetworks/casimir/tree/4e5a4ab938e9a1d8abb1b631427d74df072f4cd5):`4e5a4ab`

## Setup

Complete the following steps **from the repository root** to install any required repository dependencies and ensure the environment is configured properly.

1. Check out the latest commit from `audit/hacken`.

```zsh
git checkout audit/hacken
```

2. Clean stale dependencies and reinstall.

```zsh
npm run clean
```

3. **If the postinstall check fails**, follow the instructions referenced in the error thrown (shown in the terminal output) and reinstall. Repeat until the postinstall check passes.

```zsh
npm i
```

4. Create a .env file and set USE_SECRETS to false.

```zsh
echo "USE_SECRETS=false" > .env
```

## Commands

The following commands can be run **from the repository root**.

1. Run contract tests.

```zsh
npm run test:ethereum
```

> 🚩 To test with coverage, set `USE_COVERAGE` to `true` in the [.env](.env) file.


2. Run a development environment.

```zsh
npm run dev:ethereum
```

3. Run contract builds.

```zsh
npm run build --workspace @casimir/ethereum
```

  > 🚩 Contract builds are automatically run after install and before contract tests or development scripts.

4. Clean contract builds.

```zsh
npm run clean --workspace @casimir/ethereum
```

## Coverage

The coverage is captured using `solidity-coverage`. The current test results are pictured below.

![](https://hackmd.io/_uploads/SJcWl2_1T.png)

## Change Notes

- The added file `@casimir/ethereum/src/v1/vendor/FunctionsClient.sol` updated (not officially released) contract previously imported from `@chainlink/contracts/src/v0.8/dev/functions/FunctionsClient.sol` and should not change audit scope.
- The included `@casimir/ethereum/src/v1/CasimirViews` and `@casimir/ethereum/src/v1/interfaces/ICasimirViews` should not be included in the audit scope.
- The constructor parameter changes in CasimirManager.sol and the new Config struct in ICasimirManager.sol were both required to run test coverage.