Skip to content

Latest commit

 

History

History
106 lines (67 loc) · 4.56 KB

TEST_SETUP.md

File metadata and controls

106 lines (67 loc) · 4.56 KB

TEST_SETUP

Requirements

Notes: If your IDE does not support the Prettier plugin, please follow the code formatter guidelines to maintain the consistent code format.

Building and Running the Project

1. Install dependencies

   npm install

2. Configure environment variables

At root, create a .env file using the example.env as the template and fill out the variables.

Variable Description
OPERATOR_ID_A This is the Account ID which can be found in your account portal.
OPERATOR_KEY_A This is the DER Encoded Private Key which can be found in your account portal.
PRIVATE_KEYS This is the HEX Encoded Private Key list which can be found in your account portal. It supports up to six private keys.

Notes: At least two accounts are required for the HEX_PRIVATE_KEY fields. See Create Hedera Portal Profile on how to create accounts on Hedera networks. Six accounts will be needed if you want to run the solidity voting example. The local.env file uses ECDSA accounts listed when starting the local node.

Important: While Hedera supports both ECDSA and ED25519 accounts, please use ECDSA since Ethereum only supports ECDSA.

3. Configure Hardhat

Adjust the defaultNetwork field in the hardhat.config.js file based on the network your accounts (specified in the .env file) are associated with.

Available Networks:

  • local for reference and how to setup a local besu node please follow the link
  • testnet
  • previewnet
  • besu_local for reference and how to setup a local besu node please follow the link

4. Installing the foundry-rs toolkit for the forge testing framework

Motivation: This step is necessary for the project as it utilizes the hardhat-foundry plugin, enabling Hardhat to use dependencies from the ./lib folder, which are installed using forge. Consequently, the plugin attempts to execute forge install to make these dependencies accessible to Hardhat. Therefore, it is crucial to install the forge testing framework, which is a part of the foundry-rs toolkit.

Notes: If you already have foundry-rs and forge correctly installed locally, you can skip this step.

4.a. First, download the foundry-rs installer by running the following command:
curl -L https://foundry.paradigm.xyz | bash
4.b. Next, to install Foundry and forge, simply execute:
foundryup

5. Compile smart contracts

    npx hardhat compile

6. Test smart contracts

6.1 Set up Hedera Local Node
  • Use the default env variables provided in local.env for your .env file.

  • Ensure that the defaultNetwork in hardhat.config.js is set to NETWORKS.local.name.

  • From the root of your project directory, execute the following command to start up a Hedera local node:

   npx hedera start -d

Important: Before running the hedera local node, verify that there are no other instances of Hedera docker containers or json-rpc-relay running in the background, as they might interfere with the functionality of the hedera local node.

6.2 Execute test suites

Run below command to execute the tests

   npx hardhat test

Note: For more information on testing, follow the instructions in the test guide.

Code Formatter

Before committing your new changes, please run command below to format all files:

   npx prettier . --write

Notes: This is applicable only in cases where you haven't configured prettier within your IDE.