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

@aragon/contract-helpers-test

v0.1.0

Published

[![Status](https://img.shields.io/badge/stability-stable.svg?style=flat-square)](https://nodejs.org/api/documentation.html#documentation_stability_index) [![npm version](https://img.shields.io/npm/v/@aragon/contract-helpers-test.svg?style=flat-square&colo

Downloads

145

Readme

Aragon test helpers

Status npm version

Test helpers for both generic Solidity and Aragon-related smart contracts.

🛠 This package is designed to be used in a web3.js@1 and Truffle v5 environment. If you are using ethers.js, you are likely much better served by waffle which comes batteries-included with most of the assertion matchers you'll need.

Quick start

Install with yarn add --dev @aragon/contract-helpers-test.

In your tests, you'll then import these utilities like so:

const { bn, getEvents, MAX_UINT256, ZERO_ADDRESS } = require('@aragon/contract-helpers-test')
const { assertEvent, assertRevert } = require('@aragon/contract-helpers-test/asserts')
const { newDao, newDaoFactory } = require('@aragon/contract-helpers-test/aragon-os')

A number of contract mocks are also accessible through @aragon/contract-helpers-test/contracts/ and may be useful for testing Aragon apps or other generic smart contracts. More documentation on these contract mocks is available in the contracts/ subdirectory.

API

The test helpers are grouped into several main exports:

Furthermore, the package also comes with:

Global state

The utilities exposed from the test helpers will automatically detect and bind to an injected Truffle environment (artifacts and web3).

However, it is possible to override this default binding or inject your own if none exist at the start of a file.

ctx

Individual utilities containing a trailing ctx parameter allow you to override the environment specifically for that single call.

type Artifacts = {
  require: (name: string) => TruffleContract,
}

type Context = {
  artifacts: Artifacts,
  web3: Web3,
}

injectArtifacts()

Inject an artifacts object into the global default environment.

Note that all future calls will now reference this new artifacts object by default.

injectWeb3()

Inject a web3 object into the global default environment.

Note that all future calls will now reference this new web3 object by default.

Generic utilities

Constants

The following constants are available, and mostly self-explanatory:

  • Ethereum related
    • EMPTY_BYTES
    • ZERO_ADDRESS
    • ZERO_BYTES32
  • Number related
    • MAX_UINT64
    • MAX_UINT192
    • MAX_UINT256
  • Time related
    • NOW: Date.now(), in seconds
    • TOMORROW: one day ahead of Date.now(), in seconds
    • NEXT_WEEK: one week ahead of Date.now(), in seconds
    • ONE_DAY: duration for one day, in seconds
    • ONE_WEEK: duration for one week, in seconds

Custom assertions

aragonOS utilities

Constants

The following constants are available:

  • ACL
    • ANY_ENTITY: address denoting any address has permission
    • BURN_MANAGER: address denoting a permission has been frozen via discarding (burning) its manager
  • EVM Scripts
    • EMPTY_CALLS_SCRIPT: empty CallsScript (with spec id 1)

aragonOS assertions

Smart contract mocks

Please visit the documentation available in contracts/.

Shell scripts

ganache-cli.sh

A utility script to start a local ganache-cli or solidity-coverage RPC node and initiate npx truffle test.

This script is generally considered deprecated but may be useful if your test framework still requires you to start a local test node manually.

If you haven't already done so, you may be interested in migrating to buidler, which handles this connection for you.