Solidity test suite, with helper functions. Use with Truffle and Mocha!
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
Luiserebii ed73a14a49
Minor re-organization, so bumping version up
1 år sedan
src Minor re-organization, so bumping version up 1 år sedan
.gitattributes Adding .gitattributes 1 år sedan
.gitignore Initial commit 1 år sedan
LICENSE Adding LICENSE 1 år sedan
README.md Edits and corrections to README.md, placing errors.js in index.js module 1 år sedan
index.js Minor re-organization, so bumping version up 1 år sedan
package-lock.json Initial commit 1 år sedan
package.json Minor re-organization, so bumping version up 1 år sedan

README.md

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'
  )

})