Coder Social home page Coder Social logo

crytotech / apeswap-test-helpers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apeswapfinance/apeswap-test-helpers

0.0 0.0 0.0 2.96 MB

Import this module to be able to run quick tests on important ApeSwap contracts.

License: MIT License

Shell 21.18% JavaScript 73.24% Solidity 5.58%

apeswap-test-helpers's Introduction

ApeSwap Test Helpers

A suite of Solidity smart contract test helpers. Use to easily test contracts against popular ApeSwap features.

NOTICE:

This project uses @openzeppelin/test-environment under the hood to deploy contracts to the development. Using this helper module assumes you are using @openzeppelin/test-environment for testing as well.

Overview

Installation

yarn add -D @apeswapfinance/test-helpers

OR

npm install --save-dev @apeswapfinance/test-helpers

Configruation

As this module is hosted as a GitHub package, create a .npmrc file in the root of your project with these details:

@apeswapfinance:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}

In your environment, set NPM_TOKEN to your github access token.

export NPM_TOKEN=<github-access-token>

Hardhat (formerly Buidler)

Install web3 and the hardhat-web3 plugin.

npm install --save-dev @nomiclabs/hardhat-web3 web3

Remember to include the plugin in your configuration as explained in the installation instructions.

Usage

Import @apeswapfinance/test-helpers in your test files to access helper deploy functions.

Mock Farm

const {
  dex,  // Deploy/manage a test dex
  farm, // Deploy/manage a test farm
} = require('@ape.swap/test-helpers');
const { accounts, contract } = require('@openzeppelin/test-environment');
const { assert } = require('chai');

describe('MasterApe', function () {
    const [owner, feeTo, alice, bob, carol] = accounts;

    beforeEach(async () => {
        const {
            bananaToken,
            bananaSplitBar,
            masterApe,
        } = await farm.deployMockFarm(accounts, {
            initialMint, // defaults to 25,000
            bananaPerBlock, // defaults to 10
        }); // accounts passed will be used in the deployment
        this.masterApe = masterApe;
    });

    it('should have proper pool length', async () => {
        assert.equal((await this.masterApe.poolLength()).toString(), '1');
    });
});

Mock Dex

const {
  dex,  // Deploy/manage a test dex
  farm, // Deploy/manage a test farm
} = require('@ape.swap/test-helpers');
const { accounts, contract } = require('@openzeppelin/test-environment');
const { assert } = require('chai');

describe('ApeFactory', function () {
    this.timeout(10000);
    const [owner, feeTo, alice, bob, carol] = accounts;

    beforeEach(async () => {
        const {
            dexFactory,
            dexRouter,
            mockWBNB,
            mockTokens,
            dexPairs
        } = await dex.deployMockDex(accounts, 5); // accounts passed will be used in the deployment
        this.dexFactory = dexFactory;
    });

    it('should have proper pair length', async () => {
        assert.equal((await this.dexFactory.allPairsLength()).toString(), '5');
    });
});

License

MIT

apeswap-test-helpers's People

Contributors

3esmit avatar abcoathup avatar alcuadrado avatar alejoamiras avatar aniket-engg avatar auhau avatar bobface avatar bruce-plutusds avatar cgewecke avatar changhwan0813 avatar chrisb87 avatar defifofum avatar dependabot[bot] avatar djuanit0x avatar dotrungkien avatar forshtat avatar frangio avatar fvictorio avatar gorgos avatar jgcarv avatar kennym avatar kingdido999 avatar naiba avatar nventuro avatar pawurb avatar pmizel avatar remon-nashid avatar scottt avatar spalladino avatar tikithedude 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.