Code Monkey home page Code Monkey logo

tuanggo-_-brownie-token-tester's Introduction

brownie-token-tester

Helper objects for generating ERC20s while testing a Brownie project.

Dependencies

Installation

via pipx

If you have installed Brownie using pipx, you need to add brownie-token-tester into the same virtual environment:

pipx inject eth-brownie brownie-token-tester

via pip

You can install the latest release via pip:

pip install brownie-token-tester

via setuptools

You can clone the repository and use setuptools for the most up-to-date version:

git clone https://github.com/iamdefinitelyahuman/brownie-token-tester.git
cd brownie-token-tester
python3 setup.py install

Quick Usage

Import the library from within a Brownie test, script or console:

from brownie_tokens import ERC20, MintableForkToken

You can then make use of the following functionality:

ERC20

Deploys a generic ERC20 contract for testing purposes.

def ERC20(
    name: str = "Test Token",
    symbol: str = "TST",
    decimals: int = 18,
    success: Union[bool, None] = True,
    fail: Union[bool, str, None] = "revert",
) -> Contract:
  • The success kwarg is used to set the token's return value upon a successful call to approve, transfer or transferFrom. Valid values are True, False, and None.
  • The fail kwarg sets the token's behaviour upon failed calls to the above methods. Use "revert" if the transaction should revert, or True, False, and None to return a value without reverting.

The resulting deployment adheres to the ERC20 Token Standard and additionally implements one non-standard method:

def _mint_for_testing(target: address, amount: uint256): nonpayable

This method increases the balance of target by amount. It may be called by any account.

MintableForkToken

MintableForkToken is used to standardize the process of minting tokens when working in a forked mainnet environment. The MintableForkToken class inherits from and may be used interchangeably with the Contract class. It exposes one additional method, _mint_for_testing, with the same API as given above.

For tokens where custom logic is implemented, this is an actual minting event. For most tokens, the "minting" process involves a query to the Ethplorer API to get a list of top token holders, and then transferring their balances to target. If you want to exclude some holders from this process use skip_holders(*addresses). If you have too many requests at a time set $ETHPLORER_API_KEY(see ethplorer.io) as environment variable.

Tokens for which custom logic is currently implemented:

  • Aave tokens
  • DAI
  • EURS
  • LinkUSD
  • pBTC
  • Synthetix synths
  • renBTC
  • renZEC
  • rETH
  • RSV
  • USDC
  • USDN
  • USDT
  • tBTC
  • wBTC
  • wZEC

Development

This project is still in early development and should be considered an alpha. Comments, questions, criticisms and pull requests are welcomed.

License

This project is licensed under the MIT license.

tuanggo-_-brownie-token-tester's People

Contributors

agureevroman avatar iamdefinitelyahuman avatar romanagureev avatar samwerner avatar skellet0r avatar

Stargazers

 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.