Git Product home page Git Product logo

foundry-test's Introduction

Foundry README

Overview

This document will go through the steps needed to test using Foundry. Currently, we use Foundry in the following capacity.

  1. Create a private network with our internal version of Geth.
  2. Deploy a smart contract to the private network.
  3. Test the smart contract on the private network.
  4. Create a transaction on the private network.

Steps

The steps to create a new project are as follows.

1. Creating New Project

  1. cd foundry/projects.
  2. Create a directory that captures your project: mkdir local-private-network; cd local-private-network.
  3. Create a new foundry project: forge init stateful.
  4. Follow the foundry documentation for writing smart contract tests.

2. Deployments

You can choose to have custom deployments for your workflow. However, it is recommended to utilize Docker.

Existing Projects

Below, you can find existing projects and their descriptions.

local-private-network

The purpose of this project is as follows:

  1. Compile the geth from the local source.
  2. Build a docker container with ipld-eth-db and another container for the local-private-network.
  3. Run the compiled version of geth.
  4. Deploy a smart contract to the private blockchain.
  5. Trigger a transaction on the newly deployed smart contract.

Using This Project

If you want to test your local geth code, do the following:

  1. Update the related-directory-mapping.sh file with the path to your local repositories.
  2. cd projects/local-private-network.
  3. ./wrapper.sh - This script will do all the heavy lifting for you. Run the flag with -h to see all the options it provides. Example Run command: ../wrapper.sh -e remote -d local-db -v remove -u abdul -n alabaster.lan.vdb.to -p "../../../related-directory-mapping.sh"
  4. Keep an eye out for the outputs from the docker container.
  5. Enter the docker container and do as you please.

Custom Docker Compose

You will also notice that there are multiple docker compose files.

  1. docker-compose.yml - This pulls a published container.
  2. docker-compose-local-db.yml - This will build the database image from the local repository, allowing you to test any changes.
  3. docker-compose-local-db-prom.yml - This will build the database image from the local repository, allowing you to test any changes, and also start prometheus.

Key Notes:

  • If you want to build geth remotely, talk to Shane to create a user on alabaster, (or any other server you want really).
  • The command to deploy the smart contract is: forge create --keystore $(cat ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE) --rpc-url http://127.0.0.1:8545 --constructor-args 1 --password $(cat ${ETHDIR}/config/password) --legacy /root/stateful/src/Stateful.sol:Stateful
  • The command to create a transaction (which will create a new block) is: cast send --keystore $(cat ~/transaction_info/CURRENT_ETH_KEYSTORE_FILE) --rpc-url http://127.0.0.1:8545 --password $(cat $(cat ~/transaction_info/ETHDIR)) --legacy $(cat ~/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS) "inc()"
  • To manually send a transaction (which will trigger the mining of a new block), simply run the following script: ~/transaction_info/NEW_TRANSACTION.
    • This script is only populated after the start-private-network.sh script has completed successfully.
  • The Dockerfile compiles cast and forge.
  • The foundry/projects/local-private-network/deploy-local-network.sh file does most heavy lifting. It spins up geth and triggers various events.
  • The foundry/projects/local-private-network/start-private-network.sh file triggers deploy-local-network.sh. This file runs all the tests.
  • The geth node will stay running even after the tests are terminated.
  • If you are building the database locally and make change to the schema, you will have to remove the volume: docker-compose down -v local-private-network_vdb_db_eth_server.
  • If you wish to use a local genesis.json file, do not add the alloc or extra_data block. The start up script will do it for you.

foundry-test's People

Contributors

abdulrabbani00 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.