Skip to main content

Helper objects for generating ERC20s while testing a Brownie project.

Project description

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brownie-token-tester-0.0.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distributions

brownie_token_tester-0.0.1-py3.8.egg (9.4 kB view details)

Uploaded Source

brownie_token_tester-0.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file brownie-token-tester-0.0.1.tar.gz.

File metadata

  • Download URL: brownie-token-tester-0.0.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.5

File hashes

Hashes for brownie-token-tester-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d2d615223bc16c5781158642a3dbf6898251de091cbc179983972348609e67b9
MD5 96723aedf14bb2df1d2dad1fb3db66b9
BLAKE2b-256 715a919b6cae28f4cf9cb22337deaac970aa096e26ebcb0dac5b0e6366c869c1

See more details on using hashes here.

File details

Details for the file brownie_token_tester-0.0.1-py3.8.egg.

File metadata

  • Download URL: brownie_token_tester-0.0.1-py3.8.egg
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.5

File hashes

Hashes for brownie_token_tester-0.0.1-py3.8.egg
Algorithm Hash digest
SHA256 d39c60e83462f2f9c339ff8e7c653b2fc371eb73a133e048da8a94019bc260b9
MD5 b2924fbe9a5ecbc8ef5393fa4999a3e0
BLAKE2b-256 31de371848a88810c783bdca339698cba054ca9457c18d4285c8feb4f950e1f9

See more details on using hashes here.

File details

Details for the file brownie_token_tester-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: brownie_token_tester-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.5

File hashes

Hashes for brownie_token_tester-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d3f978971a03b43f5059c4ffdd931186ddd69d1e837d4e4ee39ad3624c11244
MD5 7b121d2cc55b9ef35952a2a944ee548b
BLAKE2b-256 ece90c3e58ec448804ef4cd375616fa512824846ced7a61f93be549c00003a5c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page