npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

erc20-test-suite

v0.2.1

Published

ERC-20 Token Test Suite (Fork of npm package token-test-suite)

Downloads

2

Readme

/!\ Fork from ERC-20 Token Test Suite (token-test-suite) Original npm package : https://www.npmjs.com/package/token-test-suite Latest previous fork on Github : https://github.com/mancze/token-test-suite Original authors : CryptoverseRocks, mancze, Michal Novák

ERC-20 Token Test Suite

Package to test your ERC-20 token implementation from your truffle projects.

This package offers the reusable tests for your final ERC-20 token implementations. This suite will tests whether your token conforms to the ERC-20 standard.

Installation

npm install --save-dev erc20-test-suite

Getting Started

The test suite assumes it is ran from the truffle's contract function (see docs). That ensures that mocha and chai is visible in the test suite.

Create the file test/MyToken.erc20.js and just add initialization boilerplate. It should look like this:

const suite = require('../node_modules/token-test-suite/lib/suite');
const MyToken = artifacts.require('MyToken');

contract('MyToken', function (accounts) {
	let options = {
		// accounts to test with, accounts[0] being the contract owner
		accounts: accounts,

		// factory method to create new token contract
		create: async function () {
			return await MyToken.new();
		},

		// factory callbacks to mint the tokens
		// use "transfer" instead of "mint" for non-mintable tokens
		mint: async function (token, to, amount) {
			return await token.transfer(to, amount, { from: accounts[0] });
		},

		// optional:
		// also test the increaseApproval/decreaseApproval methods (not part of the ERC-20 standard)
		increaseDecreaseApproval: true,

		// token info to test
		name: 'MyToken',
		symbol: 'MTK',
		decimals: 18,

		// initial state to test
		initialSupply: 100,
		initialBalances: [
			[accounts[0], 100]
		],
		initialAllowances: [
			[accounts[0], accounts[1], 0]
		]
	};

	suite(options);
});

Then run:

truffle test ./test/MyToken.erc20.js

You should get:

Output of the test run

More

The library won't test any additional logic your token might implement. It expects "classical" token behavior. All test assume, that tokens are fully transferrable. If you implement vesting period or freeze times, maybe specifying before/after custom callbacks in options might help. If not, perhaps the standardized tests are not for you and you might just copy/paste and customize them.

License

The library is released under the MIT license.