BksRhalid / Pact_Frontend

Home Page:https://app.pact.fr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIT License LinkedIn


Logo

PACT, FREELANCING PLATEFORM

PACT is a blockchain-based client-relationship platform. The mission is to remove the friction in the client-relationship. The interest of using blockchain for a platform is to bring trust.
Explore the docs Β»

Video Demo

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Acknowledgments

About The Project

The objective of the exercise is to provide the unit tests of a smart contract including everts and revert.

In this context, we have created three test files: :

  • Ownable.test.js : to test if Ownable from openzepplin is correctly implemented

    Units tests on Ownable access functions
      πŸ”Ž Test Ownable Revert if the owner is not the caller
        βœ” should NOT setProtocolFee if caller is not the owner (244ms)
        βœ” should NOT setJuryFee if caller is not the owner (61ms)
        βœ” should NOT setJuryLength if caller is not the owner (70ms)
        βœ” should CHANGE ProtocolFee if caller is the owner (352ms)
        βœ” should CHANGE JuryFee if caller is the owner (182ms)
        βœ” should CHANGE juryLength if caller is the owner (204ms)
    
    Units tests on freelance access functions
      πŸ”Ž Deployment hardhat deploy testing
        βœ” should deploy the smart contract (64ms)
      πŸ”Ž Test dispute contract function
        βœ” should generate a number (169ms)
    
    Units tests on freelance access functions
      πŸ”Ž Deployment hardhat deploy testing
        βœ” should deploy the smart contract
      πŸ”Ž Test freelance contract set-up
        βœ” should ADD a new worker (99ms)
        βœ” should REMOVE the worker (228ms)
        βœ” should ADD a new client (164ms)
        βœ” should REMOVE the client (287ms)
        βœ” should ADD a new jury member (156ms)
      πŸ”Ž  Test freelance contract function creation unit test
        βœ” should CREATE a new contract called by Client (200ms)
        βœ” should NOT CREATE a new contract called by Worker (128ms)
      πŸ”Ž Test freelance contract function cancel contract
        βœ” should EMIT ContractStateChange (222ms)
        βœ” should NOT CANCEL a new contract (120ms)
      πŸ”Ž Test freelance contract function sign contract
        βœ” should update the worker address (177ms)
        βœ” should EMIT ContractStateChange (131ms)
      πŸ”Ž Test dispute contract function
        βœ” should create a new dispute (248ms)
        βœ” should NOT create a second dispute (325ms)
        βœ” should NOT revert select a jury (454ms)
        βœ” should get 3 juryMembers (190ms)
      πŸ”Ž Test function of Voting process
        βœ” should return the correct juryCounter (67ms)
        βœ” should return false if juryMembers has no voted
        βœ” should return true if juryMembers has voted (288ms)
        βœ” should change vote count for client (111ms)
        βœ” should change vote count for worker (192ms)
      πŸ”Ž Test function count Vote and change the State
        βœ” should change state ClientLostInDispute  (329ms)
        βœ” should change state WorkerLostInDispute  (478ms)
      πŸ”Ž Unit Test of payments related functions and events when works is confirm by Clients
        βœ” should Revert as it not in correct state
        βœ” should worker requestClientValidation and change contract state to WaitingClientReview  (125ms)
        βœ” should NOT allow client to  request client validation (52ms)
        βœ” should client able to confirm worker job and change state to WorkFinishedSuccessufully (190ms)
        βœ” should Not allow worker to confirm the job (58ms)
        βœ” should NOT allow client to pull payment
        βœ” should allow worker to pull payments and not fail (262ms)
        βœ” should allow client to pull payments after worker cancel (52ms)
      πŸ”Ž Unit Test of payments related functions and events after dispute opened
        βœ” should Revert as Dispute isn't closed
        βœ” should NOT allow client to pull payment (185ms)
    
    

Below the coverage report of the test :

------------------------|----------|----------|----------|----------|----------------|
File                    |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
------------------------|----------|----------|----------|----------|----------------|
 contracts/             |    69.57 |    59.52 |    84.85 |    67.58 |                |
  freelanceContract.sol |    69.57 |    59.52 |    84.85 |    67.58 |... 674,675,676 |
 contracts/utils/       |      100 |      100 |       50 |      100 |                |
  payments.sol          |      100 |      100 |        0 |      100 |                |
  randomNumber.sol      |      100 |      100 |      100 |      100 |                |
  random_ChainLink.sol  |      100 |      100 |      100 |      100 |                |
------------------------|----------|----------|----------|----------|----------------|
All files               |       70 |    59.52 |    82.86 |    67.87 |                |
------------------------|----------|----------|----------|----------|----------------|

(back to top)

Getting Started

Below the instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

Here the list things you need to use the software and how to install them.

  • For this project we are going to use yarn
  1. installation
npm install --global yarn
  1. check installation
 yarn --version
  • solidity

Installation

_Below instruction installing and setting up the project.

  1. Clone the repo

    git clone https://github.com/BksRhalid/Pact_Frontend.git
    git clone https://github.com/BksRhalid/Pact_Backend.git
    
  2. Install packages

    yarn install
  3. Enter your Wallet Private Key and API in env

    const PK = "YOUR WALLET PRIVATE KEY";
    const INFURA = "ENTER YOUR API";
    const ETHERSCAN = "ENTER YOUR API";
  4. Check dependencies used like Openzepplin contracts / hardhat-deploy

    yarn add --dev @openzeppelin/contracts
    yarn add --dev hardhat-deploy

In case of error: _TypeError: ethers.getContract is not a function

see reference : https://ethereum.stackexchange.com/questions/130125/solvedpatrickcollins-solidity-course-2022-lesson-7-112038-typeerror-e

yarn add --dev hardhat @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers

(back to top)

Usage

Try running some of the following tasks:

REPORT_GAS=true npx hardhat test

(back to top)

License

Distributed under the MIT License.

(back to top)


About

https://app.pact.fr


Languages

Language:JavaScript 97.0%Language:CSS 3.0%