1.3.0 • Published 5 years ago

sol-assert v1.3.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

sol-assert

Helper assertion library for Solidity JS testing.

Install

npm install --save-dev sol-assert

Usage

const sassert = require('sol-assert')

.revert

// Testing for revert
await sassert.revert(myContract.methods.myFunc().send())

// Testing for specific error message
await sassert.revert(
    myContract.methods.myFunc().send(),
    'Text that should be from the thrown error in the contract')

.invalidOpcode

// Testing for invalid opcode
await sassert.invalidOpcode(myContract.methods.myFunc().send())

// Testing for specific error message
await sassert.invalidOpcode(
    myContract.methods.myFunc().send(),
    'Text that should be from the thrown error in the contract')

.event

function test1() {
    // Calling ERC20 transfer
    const receipt = await token.methods['transfer(address,uint256)'](ACCT1, 1).send({ from: OWNER })
    // Expect the `Transfer` event to be emitted
    sassert.event(receipt, 'Transfer')
}

function test2() {
    // Calling ERC223 transfer
    const receipt = await token.methods['transfer(address,uint256,bytes)'](ACCT1, 1).send({ from: OWNER })
    // Expect 2 Transfer events to be emitted because in my ERC223 contract I emit both Transfer events:
    // event Transfer(address indexed from, address indexed to, uint256 amount);
    // event Transfer(address indexed from, address indexed to, uint256 amount, bytes data);
    sassert.event(receipt, 'Transfer', 2)
}
1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago