0.0.7-alpha • Published 5 years ago

solidity-test v0.0.7-alpha

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

solidity-test

npm version

A simple node module to aid smart contract development in testing contracts. Initially created due to the desire to modularize testing for reverts, now looking to expand into something more definite.

Quick Example

const solidityTest = require('solidityTest');
const solAssert = solidityTest.solAssert;

const notOwner = '0x00000000000000000000000000000000000';

//Within Mocha:

it('reverts transaction', async () => {
  
  await solAssert.revert(
    async () => {  
      someContract.functionOnlyOwnerCanCall().send({from: notOwner});
    }
  )
  
})

And, if perhaps testing for ownership, and wanting to be strict about the kind of error received:

const solidityTest = require('solidityTest');
const solAssert = solidityTest.solAssert;
const errors = solidityTest.errors;

const notOwner = '0x00000000000000000000000000000000000';

//Within Mocha:

it('reverts transaction', async () => {

  //Passing an error string to revert will only pass when the error string is matched
  await solAssert.revert(
    async () => {
      someContract.functionOnlyOwnerCanCall().send({from: notOwner});
    }, errors.openzeppelin.ownable // which is: 'Ownable: caller is not the owner'
  )

})
0.0.7-alpha

5 years ago

0.0.6-alpha

5 years ago

0.0.5-alpha

5 years ago

0.0.4-alpha

5 years ago

0.0.3-alpha

5 years ago

0.0.2-alpha

5 years ago

0.0.1-alpha

5 years ago