Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
63c8751e
Commit
63c8751e
authored
Dec 04, 2017
by
Matt Condon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: linter errors
parent
677d0574
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
41 deletions
+40
-41
RBAC.test.js
test/RBAC.test.js
+40
-41
No files found.
test/RBAC.test.js
View file @
63c8751e
const
RBACMock
=
artifacts
.
require
(
'./mocks/RBACMock.sol'
)
import
expectThrow
from
'./helpers/expectThrow'
;
import
expectEvent
from
'./helpers/expectEvent'
;
import
expectThrow
from
'./helpers/expectThrow'
import
expectEvent
from
'./helpers/expectEvent'
const
RBACMock
=
artifacts
.
require
(
'./mocks/RBACMock.sol'
);
require
(
'chai'
)
.
use
(
require
(
'chai-as-promised'
))
.
should
()
.
should
()
;
const
ROLE_ADVISOR
=
'advisor'
;
contract
(
'RBAC'
,
function
(
accounts
)
{
let
mock
contract
(
'RBAC'
,
function
(
accounts
)
{
let
mock
;
const
[
admin
,
anyone
,
futureAdvisor
,
...
advisors
]
=
accounts
]
=
accounts
;
before
(
async
()
=>
{
mock
=
await
RBACMock
.
new
(
advisors
,
{
from
:
admin
})
})
mock
=
await
RBACMock
.
new
(
advisors
,
{
from
:
admin
})
;
})
;
context
(
'in normal conditions'
,
()
=>
{
it
(
'allows admin to call #onlyAdminsCanDoThis'
,
async
()
=>
{
await
mock
.
onlyAdminsCanDoThis
({
from
:
admin
})
.
should
.
be
.
fulfilled
})
.
should
.
be
.
fulfilled
;
})
;
it
(
'allows admin to call #onlyAdvisorsCanDoThis'
,
async
()
=>
{
await
mock
.
onlyAdvisorsCanDoThis
({
from
:
admin
})
.
should
.
be
.
fulfilled
})
.
should
.
be
.
fulfilled
;
})
;
it
(
'allows advisors to call #onlyAdvisorsCanDoThis'
,
async
()
=>
{
await
mock
.
onlyAdvisorsCanDoThis
({
from
:
advisors
[
0
]
})
.
should
.
be
.
fulfilled
})
.
should
.
be
.
fulfilled
;
})
;
it
(
'allows admin to call #eitherAdminOrAdvisorCanDoThis'
,
async
()
=>
{
await
mock
.
eitherAdminOrAdvisorCanDoThis
({
from
:
admin
})
.
should
.
be
.
fulfilled
})
.
should
.
be
.
fulfilled
;
})
;
it
(
'allows advisors to call #eitherAdminOrAdvisorCanDoThis'
,
async
()
=>
{
await
mock
.
eitherAdminOrAdvisorCanDoThis
({
from
:
advisors
[
0
]
})
.
should
.
be
.
fulfilled
})
.
should
.
be
.
fulfilled
;
})
;
it
(
'does not allow admins to call #nobodyCanDoThis'
,
async
()
=>
{
expectThrow
(
mock
.
nobodyCanDoThis
({
from
:
admin
})
)
})
)
;
})
;
it
(
'does not allow advisors to call #nobodyCanDoThis'
,
async
()
=>
{
expectThrow
(
mock
.
nobodyCanDoThis
({
from
:
advisors
[
0
]
})
)
})
)
;
})
;
it
(
'does not allow anyone to call #nobodyCanDoThis'
,
async
()
=>
{
expectThrow
(
mock
.
nobodyCanDoThis
({
from
:
anyone
})
)
})
)
;
})
;
it
(
'allows an admin to remove an advisor
\'
s role'
,
async
()
=>
{
await
mock
.
removeAdvisor
(
advisors
[
0
],
{
from
:
admin
})
.
should
.
be
.
fulfilled
})
.
should
.
be
.
fulfilled
;
})
;
it
(
'allows admins to #adminRemoveRole'
,
async
()
=>
{
await
mock
.
adminRemoveRole
(
advisors
[
3
],
ROLE_ADVISOR
,
{
from
:
admin
})
.
should
.
be
.
fulfilled
})
.
should
.
be
.
fulfilled
;
})
;
it
(
'announces a RoleAdded event on addRole'
,
async
()
=>
{
expectEvent
.
inTransaction
(
mock
.
adminAddRole
(
futureAdvisor
,
ROLE_ADVISOR
,
{
from
:
admin
}),
'RoleAdded'
)
})
)
;
})
;
it
(
'announces a RoleRemoved event on removeRole'
,
async
()
=>
{
expectEvent
.
inTransaction
(
mock
.
adminRemoveRole
(
futureAdvisor
,
ROLE_ADVISOR
,
{
from
:
admin
}),
'RoleRemoved'
)
})
})
)
;
})
;
})
;
context
(
'in adversarial conditions'
,
()
=>
{
it
(
'does not allow an advisor to remove another advisor'
,
async
()
=>
{
expectThrow
(
mock
.
removeAdvisor
(
advisors
[
1
],
{
from
:
advisors
[
0
]
})
)
})
)
;
})
;
it
(
'does not allow "anyone" to remove an advisor'
,
async
()
=>
{
expectThrow
(
mock
.
removeAdvisor
(
advisors
[
0
],
{
from
:
anyone
})
)
})
})
})
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment