Created
November 24, 2018 18:19
-
-
Save BogdanHabic/c70a09af18347d0168fb17dd4e57253b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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