Compiling and Testing Contracts

The three Solidity contracts that form the RealEstateToken project are set out in full here:

  1. Whitelist - manages the Whitelist of approved investors.

  2. RealEstateFactory - deploys RealEstateToken contracts.

  3. RealEstateToken - Tokenization of a real estate development project.

Compiling and testing these contracts is simple. Foundry with it's Solidity centric test scripts, and builting helpers and assertions, make it straightforward to write unit tests for our contracts. The example project has a basic suite of tests for each contract.

Building

To build the Solidity contracts are built simply with:

forge build

Testing

Foundry unit tests are found in the test directory. There are a number of ways in which you can structure your tests. For simplicity, we've written one test script per contract. Test scripts are written in Solidity and the filename must have the form FileName.t.sol. You can read more about testing with Foundry here: https://getfoundry.sh/forge/tests/overview

You can run your unit tests in Foundry with a simple:

forge test

This will run all test scripts int the test directory.

The sample project includes the following tests scripts:

Whitelist.t.sol

RealEstateFactory.t.sol

RealEstateToken.t.sol

Last updated