Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BogdanHabic/c70a09af18347d0168fb17dd4e57253b to your computer and use it in GitHub Desktop.
Save BogdanHabic/c70a09af18347d0168fb17dd4e57253b to your computer and use it in GitHub Desktop.
var Calculator = artifacts.require("./Calculator.sol");
contract('Calculator', function (accounts) {
it("shouldn't allow division by zero", async function () {
let error;
const fail = await Calculator.new();
try {
await fail.div(5, 0);
} catch (e) {
error = e;
}
assert.isDefined(error, "No exception thrown during divison");
assert.isTrue(error.message.search("revert") >= 0, "Expected transaction revert");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment