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
64c324e3
Commit
64c324e3
authored
Aug 21, 2018
by
jacob
Committed by
Nicolás Venturo
Aug 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove arrow functions from js tests (#1225)
parent
7618b91d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
34 deletions
+34
-34
SignatureBouncer.test.js
test/access/SignatureBouncer.test.js
+11
-11
ECRecovery.test.js
test/library/ECRecovery.test.js
+1
-1
SafeMath.test.js
test/math/SafeMath.test.js
+1
-1
HasNoContracts.test.js
test/ownership/HasNoContracts.test.js
+1
-1
HasNoTokens.test.js
test/ownership/HasNoTokens.test.js
+1
-1
Superuser.test.js
test/ownership/Superuser.test.js
+2
-2
RBAC.test.js
test/ownership/rbac/RBAC.test.js
+17
-17
No files found.
test/access/SignatureBouncer.test.js
View file @
64c324e3
...
...
@@ -13,13 +13,13 @@ const UINT_VALUE = 23;
const
BYTES_VALUE
=
web3
.
toHex
(
'test'
);
const
INVALID_SIGNATURE
=
'0xabcd'
;
contract
(
'Bouncer'
,
([
_
,
owner
,
anyone
,
bouncerAddress
,
authorizedUser
])
=>
{
contract
(
'Bouncer'
,
function
([
_
,
owner
,
anyone
,
bouncerAddress
,
authorizedUser
])
{
beforeEach
(
async
function
()
{
this
.
bouncer
=
await
Bouncer
.
new
({
from
:
owner
});
this
.
roleBouncer
=
await
this
.
bouncer
.
ROLE_BOUNCER
();
});
context
(
'management'
,
()
=>
{
context
(
'management'
,
function
()
{
it
(
'has a default owner of self'
,
async
function
()
{
(
await
this
.
bouncer
.
owner
()).
should
.
eq
(
owner
);
});
...
...
@@ -57,14 +57,14 @@ contract('Bouncer', ([_, owner, anyone, bouncerAddress, authorizedUser]) => {
});
});
context
(
'with bouncer address'
,
()
=>
{
context
(
'with bouncer address'
,
function
()
{
beforeEach
(
async
function
()
{
await
this
.
bouncer
.
addBouncer
(
bouncerAddress
,
{
from
:
owner
});
this
.
signFor
=
getBouncerSigner
(
this
.
bouncer
,
bouncerAddress
);
});
describe
(
'modifiers'
,
()
=>
{
context
(
'plain signature'
,
()
=>
{
describe
(
'modifiers'
,
function
()
{
context
(
'plain signature'
,
function
()
{
it
(
'allows valid signature for sender'
,
async
function
()
{
await
this
.
bouncer
.
onlyWithValidSignature
(
this
.
signFor
(
authorizedUser
),
{
from
:
authorizedUser
});
});
...
...
@@ -89,7 +89,7 @@ contract('Bouncer', ([_, owner, anyone, bouncerAddress, authorizedUser]) => {
});
});
context
(
'method signature'
,
()
=>
{
context
(
'method signature'
,
function
()
{
it
(
'allows valid signature with correct method for sender'
,
async
function
()
{
await
this
.
bouncer
.
onlyWithValidSignatureAndMethod
(
this
.
signFor
(
authorizedUser
,
'onlyWithValidSignatureAndMethod'
),
{
from
:
authorizedUser
}
...
...
@@ -124,7 +124,7 @@ contract('Bouncer', ([_, owner, anyone, bouncerAddress, authorizedUser]) => {
});
});
context
(
'method and data signature'
,
()
=>
{
context
(
'method and data signature'
,
function
()
{
it
(
'allows valid signature with correct method and data for sender'
,
async
function
()
{
await
this
.
bouncer
.
onlyWithValidSignatureAndData
(
UINT_VALUE
,
this
.
signFor
(
authorizedUser
,
'onlyWithValidSignatureAndData'
,
[
UINT_VALUE
]),
{
from
:
authorizedUser
}
...
...
@@ -165,8 +165,8 @@ contract('Bouncer', ([_, owner, anyone, bouncerAddress, authorizedUser]) => {
});
});
context
(
'signature validation'
,
()
=>
{
context
(
'plain signature'
,
()
=>
{
context
(
'signature validation'
,
function
()
{
context
(
'plain signature'
,
function
()
{
it
(
'validates valid signature for valid user'
,
async
function
()
{
(
await
this
.
bouncer
.
checkValidSignature
(
authorizedUser
,
this
.
signFor
(
authorizedUser
))).
should
.
eq
(
true
);
});
...
...
@@ -185,7 +185,7 @@ contract('Bouncer', ([_, owner, anyone, bouncerAddress, authorizedUser]) => {
});
});
context
(
'method signature'
,
()
=>
{
context
(
'method signature'
,
function
()
{
it
(
'validates valid signature with correct method for valid user'
,
async
function
()
{
(
await
this
.
bouncer
.
checkValidSignatureAndMethod
(
authorizedUser
,
this
.
signFor
(
authorizedUser
,
'checkValidSignatureAndMethod'
))
...
...
@@ -208,7 +208,7 @@ contract('Bouncer', ([_, owner, anyone, bouncerAddress, authorizedUser]) => {
});
});
context
(
'method and data signature'
,
()
=>
{
context
(
'method and data signature'
,
function
()
{
it
(
'validates valid signature with correct method and data for valid user'
,
async
function
()
{
(
await
this
.
bouncer
.
checkValidSignatureAndData
(
authorizedUser
,
BYTES_VALUE
,
UINT_VALUE
,
this
.
signFor
(
authorizedUser
,
'checkValidSignatureAndData'
,
[
authorizedUser
,
BYTES_VALUE
,
UINT_VALUE
]))
...
...
test/library/ECRecovery.test.js
View file @
64c324e3
...
...
@@ -63,7 +63,7 @@ contract('ECRecovery', function ([_, anyone]) {
}
});
context
(
'toEthSignedMessage'
,
()
=>
{
context
(
'toEthSignedMessage'
,
function
()
{
it
(
'should prefix hashes correctly'
,
async
function
()
{
const
hashedMessage
=
web3
.
sha3
(
TEST_MESSAGE
);
(
await
ecrecovery
.
toEthSignedMessageHash
(
hashedMessage
)).
should
.
eq
(
hashMessage
(
TEST_MESSAGE
));
...
...
test/math/SafeMath.test.js
View file @
64c324e3
...
...
@@ -7,7 +7,7 @@ require('chai')
.
use
(
require
(
'chai-bignumber'
)(
BigNumber
))
.
should
();
contract
(
'SafeMath'
,
()
=>
{
contract
(
'SafeMath'
,
function
()
{
const
MAX_UINT
=
new
BigNumber
(
2
).
pow
(
256
).
minus
(
1
);
beforeEach
(
async
function
()
{
...
...
test/ownership/HasNoContracts.test.js
View file @
64c324e3
...
...
@@ -7,7 +7,7 @@ contract('HasNoContracts', function ([_, owner, anyone]) {
let
hasNoContracts
=
null
;
let
ownable
=
null
;
beforeEach
(
async
()
=>
{
beforeEach
(
async
function
()
{
// Create contract and token
hasNoContracts
=
await
HasNoContracts
.
new
({
from
:
owner
});
ownable
=
await
Ownable
.
new
({
from
:
owner
});
...
...
test/ownership/HasNoTokens.test.js
View file @
64c324e3
...
...
@@ -13,7 +13,7 @@ contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
let
hasNoTokens
=
null
;
let
token
=
null
;
beforeEach
(
async
()
=>
{
beforeEach
(
async
function
()
{
// Create contract and token
hasNoTokens
=
await
HasNoTokens
.
new
({
from
:
owner
});
token
=
await
ERC223TokenMock
.
new
(
initialAccount
,
100
);
...
...
test/ownership/Superuser.test.js
View file @
64c324e3
...
...
@@ -13,7 +13,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone])
this
.
superuser
=
await
Superuser
.
new
({
from
:
firstOwner
});
});
context
(
'in normal conditions'
,
()
=>
{
context
(
'in normal conditions'
,
function
()
{
it
(
'should set the owner as the default superuser'
,
async
function
()
{
(
await
this
.
superuser
.
isSuperuser
(
firstOwner
)).
should
.
be
.
be
.
true
;
});
...
...
@@ -53,7 +53,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone])
});
});
context
(
'in adversarial conditions'
,
()
=>
{
context
(
'in adversarial conditions'
,
function
()
{
it
(
'should prevent non-superusers from transfering the superuser role'
,
async
function
()
{
await
expectThrow
(
this
.
superuser
.
transferSuperuser
(
newOwner
,
{
from
:
anyone
})
...
...
test/ownership/rbac/RBAC.test.js
View file @
64c324e3
...
...
@@ -11,50 +11,50 @@ const ROLE_ADVISOR = 'advisor';
contract
(
'RBAC'
,
function
([
_
,
admin
,
anyone
,
advisor
,
otherAdvisor
,
futureAdvisor
])
{
let
mock
;
beforeEach
(
async
()
=>
{
beforeEach
(
async
function
()
{
mock
=
await
RBACMock
.
new
([
advisor
,
otherAdvisor
],
{
from
:
admin
});
});
context
(
'in normal conditions'
,
()
=>
{
it
(
'allows admin to call #onlyAdminsCanDoThis'
,
async
()
=>
{
context
(
'in normal conditions'
,
function
()
{
it
(
'allows admin to call #onlyAdminsCanDoThis'
,
async
function
()
{
await
mock
.
onlyAdminsCanDoThis
({
from
:
admin
});
});
it
(
'allows admin to call #onlyAdvisorsCanDoThis'
,
async
()
=>
{
it
(
'allows admin to call #onlyAdvisorsCanDoThis'
,
async
function
()
{
await
mock
.
onlyAdvisorsCanDoThis
({
from
:
admin
});
});
it
(
'allows advisors to call #onlyAdvisorsCanDoThis'
,
async
()
=>
{
it
(
'allows advisors to call #onlyAdvisorsCanDoThis'
,
async
function
()
{
await
mock
.
onlyAdvisorsCanDoThis
({
from
:
advisor
});
});
it
(
'allows admin to call #eitherAdminOrAdvisorCanDoThis'
,
async
()
=>
{
it
(
'allows admin to call #eitherAdminOrAdvisorCanDoThis'
,
async
function
()
{
await
mock
.
eitherAdminOrAdvisorCanDoThis
({
from
:
admin
});
});
it
(
'allows advisors to call #eitherAdminOrAdvisorCanDoThis'
,
async
()
=>
{
it
(
'allows advisors to call #eitherAdminOrAdvisorCanDoThis'
,
async
function
()
{
await
mock
.
eitherAdminOrAdvisorCanDoThis
({
from
:
advisor
});
});
it
(
'does not allow admins to call #nobodyCanDoThis'
,
async
()
=>
{
it
(
'does not allow admins to call #nobodyCanDoThis'
,
async
function
()
{
await
expectThrow
(
mock
.
nobodyCanDoThis
({
from
:
admin
}));
});
it
(
'does not allow advisors to call #nobodyCanDoThis'
,
async
()
=>
{
it
(
'does not allow advisors to call #nobodyCanDoThis'
,
async
function
()
{
await
expectThrow
(
mock
.
nobodyCanDoThis
({
from
:
advisor
}));
});
it
(
'does not allow anyone to call #nobodyCanDoThis'
,
async
()
=>
{
it
(
'does not allow anyone to call #nobodyCanDoThis'
,
async
function
()
{
await
expectThrow
(
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
function
()
{
await
mock
.
removeAdvisor
(
advisor
,
{
from
:
admin
});
});
it
(
'allows admins to #adminRemoveRole'
,
async
()
=>
{
it
(
'allows admins to #adminRemoveRole'
,
async
function
()
{
await
mock
.
adminRemoveRole
(
advisor
,
ROLE_ADVISOR
,
{
from
:
admin
});
});
it
(
'announces a RoleAdded event on addRole'
,
async
()
=>
{
it
(
'announces a RoleAdded event on addRole'
,
async
function
()
{
await
expectEvent
.
inTransaction
(
mock
.
adminAddRole
(
futureAdvisor
,
ROLE_ADVISOR
,
{
from
:
admin
}),
'RoleAdded'
);
});
it
(
'announces a RoleRemoved event on removeRole'
,
async
()
=>
{
it
(
'announces a RoleRemoved event on removeRole'
,
async
function
()
{
await
expectEvent
.
inTransaction
(
mock
.
adminRemoveRole
(
futureAdvisor
,
ROLE_ADVISOR
,
{
from
:
admin
}),
'RoleRemoved'
...
...
@@ -62,11 +62,11 @@ contract('RBAC', function ([_, admin, anyone, advisor, otherAdvisor, futureAdvis
});
});
context
(
'in adversarial conditions'
,
()
=>
{
it
(
'does not allow an advisor to remove another advisor'
,
async
()
=>
{
context
(
'in adversarial conditions'
,
function
()
{
it
(
'does not allow an advisor to remove another advisor'
,
async
function
()
{
await
expectThrow
(
mock
.
removeAdvisor
(
otherAdvisor
,
{
from
:
advisor
}));
});
it
(
'does not allow "anyone" to remove an advisor'
,
async
()
=>
{
it
(
'does not allow "anyone" to remove an advisor'
,
async
function
()
{
await
expectThrow
(
mock
.
removeAdvisor
(
advisor
,
{
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