Refactor assert revert helper to encapsulate promises (#628)
This commit is contained in:
committed by
Federico Bond
parent
4ce0e211c5
commit
323d1fa941
@ -1,4 +1,4 @@
|
||||
const assertRevert = require('./helpers/assertRevert');
|
||||
import assertRevert from './helpers/assertRevert';
|
||||
const assertJump = require('./helpers/assertJump');
|
||||
var SafeMathMock = artifacts.require('mocks/SafeMathMock.sol');
|
||||
|
||||
@ -49,22 +49,12 @@ contract('SafeMath', function (accounts) {
|
||||
it('should throw an error on addition overflow', async function () {
|
||||
let a = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
|
||||
let b = 1;
|
||||
try {
|
||||
await safeMath.add(a, b);
|
||||
assert.fail('should have thrown before');
|
||||
} catch (error) {
|
||||
assertRevert(error);
|
||||
}
|
||||
await assertRevert(safeMath.add(a, b));
|
||||
});
|
||||
|
||||
it('should throw an error on multiplication overflow', async function () {
|
||||
let a = 115792089237316195423570985008687907853269984665640564039457584007913129639933;
|
||||
let b = 2;
|
||||
try {
|
||||
await safeMath.multiply(a, b);
|
||||
assert.fail('should have thrown before');
|
||||
} catch (error) {
|
||||
assertRevert(error);
|
||||
}
|
||||
await assertRevert(safeMath.multiply(a, b));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user