fix: linter errors

This commit is contained in:
Matt Condon
2017-12-04 17:08:28 +02:00
parent 677d05743c
commit 63c8751e06

View File

@ -1,99 +1,98 @@
const RBACMock = artifacts.require('./mocks/RBACMock.sol') import expectThrow from './helpers/expectThrow';
import expectEvent from './helpers/expectEvent';
import expectThrow from './helpers/expectThrow' const RBACMock = artifacts.require('./mocks/RBACMock.sol');
import expectEvent from './helpers/expectEvent'
require('chai') require('chai')
.use(require('chai-as-promised')) .use(require('chai-as-promised'))
.should() .should();
const ROLE_ADVISOR = 'advisor'; const ROLE_ADVISOR = 'advisor';
contract('RBAC', function(accounts) { contract('RBAC', function (accounts) {
let mock let mock;
const [ const [
admin, admin,
anyone, anyone,
futureAdvisor, futureAdvisor,
...advisors ...advisors
] = accounts ] = accounts;
before(async () => { before(async () => {
mock = await RBACMock.new(advisors, { from: admin }) mock = await RBACMock.new(advisors, { from: admin });
}) });
context('in normal conditions', () => { context('in normal conditions', () => {
it('allows admin to call #onlyAdminsCanDoThis', async () => { it('allows admin to call #onlyAdminsCanDoThis', async () => {
await mock.onlyAdminsCanDoThis({ from: admin }) await mock.onlyAdminsCanDoThis({ from: admin })
.should.be.fulfilled .should.be.fulfilled;
}) });
it('allows admin to call #onlyAdvisorsCanDoThis', async () => { it('allows admin to call #onlyAdvisorsCanDoThis', async () => {
await mock.onlyAdvisorsCanDoThis({ from: admin }) await mock.onlyAdvisorsCanDoThis({ from: admin })
.should.be.fulfilled .should.be.fulfilled;
}) });
it('allows advisors to call #onlyAdvisorsCanDoThis', async () => { it('allows advisors to call #onlyAdvisorsCanDoThis', async () => {
await mock.onlyAdvisorsCanDoThis({ from: advisors[0] }) await mock.onlyAdvisorsCanDoThis({ from: advisors[0] })
.should.be.fulfilled .should.be.fulfilled;
}) });
it('allows admin to call #eitherAdminOrAdvisorCanDoThis', async () => { it('allows admin to call #eitherAdminOrAdvisorCanDoThis', async () => {
await mock.eitherAdminOrAdvisorCanDoThis({ from: admin }) await mock.eitherAdminOrAdvisorCanDoThis({ from: admin })
.should.be.fulfilled .should.be.fulfilled;
}) });
it('allows advisors to call #eitherAdminOrAdvisorCanDoThis', async () => { it('allows advisors to call #eitherAdminOrAdvisorCanDoThis', async () => {
await mock.eitherAdminOrAdvisorCanDoThis({ from: advisors[0] }) await mock.eitherAdminOrAdvisorCanDoThis({ from: advisors[0] })
.should.be.fulfilled .should.be.fulfilled;
}) });
it('does not allow admins to call #nobodyCanDoThis', async () => { it('does not allow admins to call #nobodyCanDoThis', async () => {
expectThrow( expectThrow(
mock.nobodyCanDoThis({ from: admin }) mock.nobodyCanDoThis({ from: admin })
) );
}) });
it('does not allow advisors to call #nobodyCanDoThis', async () => { it('does not allow advisors to call #nobodyCanDoThis', async () => {
expectThrow( expectThrow(
mock.nobodyCanDoThis({ from: advisors[0] }) mock.nobodyCanDoThis({ from: advisors[0] })
) );
}) });
it('does not allow anyone to call #nobodyCanDoThis', async () => { it('does not allow anyone to call #nobodyCanDoThis', async () => {
expectThrow( expectThrow(
mock.nobodyCanDoThis({ from: anyone }) mock.nobodyCanDoThis({ from: anyone })
) );
}) });
it('allows an admin to remove an advisor\'s role', async () => { it('allows an admin to remove an advisor\'s role', async () => {
await mock.removeAdvisor(advisors[0], { from: admin }) await mock.removeAdvisor(advisors[0], { from: admin })
.should.be.fulfilled .should.be.fulfilled;
}) });
it('allows admins to #adminRemoveRole', async () => { it('allows admins to #adminRemoveRole', async () => {
await mock.adminRemoveRole(advisors[3], ROLE_ADVISOR, { from: admin }) await mock.adminRemoveRole(advisors[3], ROLE_ADVISOR, { from: admin })
.should.be.fulfilled .should.be.fulfilled;
}) });
it('announces a RoleAdded event on addRole', async () => { it('announces a RoleAdded event on addRole', async () => {
expectEvent.inTransaction( expectEvent.inTransaction(
mock.adminAddRole(futureAdvisor, ROLE_ADVISOR, { from: admin }), mock.adminAddRole(futureAdvisor, ROLE_ADVISOR, { from: admin }),
'RoleAdded' 'RoleAdded'
) );
}) });
it('announces a RoleRemoved event on removeRole', async () => { it('announces a RoleRemoved event on removeRole', async () => {
expectEvent.inTransaction( expectEvent.inTransaction(
mock.adminRemoveRole(futureAdvisor, ROLE_ADVISOR, { from: admin }), mock.adminRemoveRole(futureAdvisor, ROLE_ADVISOR, { from: admin }),
'RoleRemoved' 'RoleRemoved'
) );
}) });
}) });
context('in adversarial conditions', () => { context('in adversarial conditions', () => {
it('does not allow an advisor to remove another advisor', async () => { it('does not allow an advisor to remove another advisor', async () => {
expectThrow( expectThrow(
mock.removeAdvisor(advisors[1], { from: advisors[0] }) mock.removeAdvisor(advisors[1], { from: advisors[0] })
) );
}) });
it('does not allow "anyone" to remove an advisor', async () => { it('does not allow "anyone" to remove an advisor', async () => {
expectThrow( expectThrow(
mock.removeAdvisor(advisors[0], { from: anyone }) mock.removeAdvisor(advisors[0], { from: anyone })
) );
}) });
}) });
});
})