Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apeswap.finance/test-helpers

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apeswap.finance/test-helpers

JavaScript testing helpers for ApeSwap contract integration.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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('@apeswapfinance/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); // 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('@apeswapfinance/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,
            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

Keywords

FAQs

Package last updated on 01 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc