Refactor assert revert helper to encapsulate promises (#628)

This commit is contained in:
Facundo Spagnuolo
2017-12-28 00:39:55 -03:00
committed by Federico Bond
parent 4ce0e211c5
commit 323d1fa941
10 changed files with 44 additions and 159 deletions

View File

@ -1,5 +1,5 @@
const assertRevert = require('./helpers/assertRevert');
import assertRevert from './helpers/assertRevert';
var Ownable = artifacts.require('../contracts/ownership/Ownable.sol');
@ -27,21 +27,11 @@ contract('Ownable', function (accounts) {
const other = accounts[2];
const owner = await ownable.owner.call();
assert.isTrue(owner !== other);
try {
await ownable.transferOwnership(other, { from: other });
assert.fail('should have thrown before');
} catch (error) {
assertRevert(error);
}
await assertRevert(ownable.transferOwnership(other, { from: other }));
});
it('should guard ownership against stuck state', async function () {
let originalOwner = await ownable.owner();
try {
await ownable.transferOwnership(null, { from: originalOwner });
assert.fail();
} catch (error) {
assertRevert(error);
}
await assertRevert(ownable.transferOwnership(null, { from: originalOwner }));
});
});