8

As per the title, which testing method is most correct for modifiers? Something like testing via inheritance and creating a function specifically designed to test modifiers or testing via a framework like truffle (or even something else)? Just trying to get a better idea of Solidity best practices. Thanks!

1

The test framework you choose shouldn't matter. We use truffle and solidity-coverage to ensure test coverage. One example of a repo with 100% code coverage is https://github.com/JoinColony/colonySale

As an example for how modifiers are tested, see this saleOpen modifier https://github.com/JoinColony/colonySale/blob/master/contracts/ColonyTokenSale.sol#L63 used on the buy function.

We test this one specifically via negative test cases, e.g. https://github.com/JoinColony/colonySale/blob/master/test/colony-token-sale.js#L215

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.