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
60bc6a6d
Commit
60bc6a6d
authored
Jul 22, 2017
by
Francisco Giordano
Committed by
GitHub
Jul 22, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #327 from jakub-wojciechowski/master
fix testing error throwing
parents
e9cf6dfb
b3f60b93
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
46 deletions
+54
-46
BasicToken.js
test/BasicToken.js
+3
-3
Claimable.js
test/Claimable.js
+6
-4
DayLimit.js
test/DayLimit.js
+10
-6
LimitBalance.js
test/LimitBalance.js
+7
-7
Ownable.js
test/Ownable.js
+1
-0
Pausable.js
test/Pausable.js
+3
-1
PausableToken.js
test/PausableToken.js
+4
-5
SafeMath.js
test/SafeMath.js
+6
-6
StandardToken.js
test/StandardToken.js
+4
-4
VestedToken.js
test/VestedToken.js
+10
-10
No files found.
test/BasicToken.js
View file @
60bc6a6d
...
...
@@ -26,10 +26,10 @@ contract('BasicToken', function(accounts) {
let
token
=
await
BasicTokenMock
.
new
(
accounts
[
0
],
100
);
try
{
let
transfer
=
await
token
.
transfer
(
accounts
[
1
],
101
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
assertJump
(
error
);
}
});
});
test/Claimable.js
View file @
60bc6a6d
...
...
@@ -25,9 +25,10 @@ contract('Claimable', function(accounts) {
it
(
'should prevent to claimOwnership from no pendingOwner'
,
async
function
()
{
try
{
await
claimable
.
claimOwnership
({
from
:
accounts
[
2
]});
await
claimable
.
claimOwnership
({
from
:
accounts
[
2
]});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
assertJump
(
error
);
}
});
...
...
@@ -36,9 +37,10 @@ contract('Claimable', function(accounts) {
const
owner
=
await
claimable
.
owner
.
call
();
assert
.
isTrue
(
owner
!==
other
);
try
{
await
claimable
.
transferOwnership
(
other
,
{
from
:
other
});
await
claimable
.
transferOwnership
(
other
,
{
from
:
other
});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
assertJump
(
error
);
}
});
...
...
test/DayLimit.js
View file @
60bc6a6d
...
...
@@ -35,9 +35,10 @@ contract('DayLimit', function(accounts) {
assert
.
equal
(
spentToday
,
8
);
try
{
await
dayLimit
.
attemptSpend
(
3
);
await
dayLimit
.
attemptSpend
(
3
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
assertJump
(
error
);
}
});
...
...
@@ -47,9 +48,10 @@ contract('DayLimit', function(accounts) {
assert
.
equal
(
spentToday
,
8
);
try
{
await
dayLimit
.
attemptSpend
(
3
);
await
dayLimit
.
attemptSpend
(
3
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
assertJump
(
error
);
}
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
...
...
@@ -66,9 +68,10 @@ contract('DayLimit', function(accounts) {
assert
.
equal
(
spentToday
,
8
);
try
{
await
dayLimit
.
attemptSpend
(
3
);
await
dayLimit
.
attemptSpend
(
3
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
assertJump
(
error
);
}
spentToday
=
await
dayLimit
.
spentToday
();
assert
.
equal
(
spentToday
,
8
);
...
...
@@ -89,6 +92,7 @@ contract('DayLimit', function(accounts) {
try
{
await
dayLimit
.
attemptSpend
(
3
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
}
...
...
test/LimitBalance.js
View file @
60bc6a6d
...
...
@@ -27,11 +27,11 @@ contract('LimitBalance', function(accounts) {
it
(
'shouldnt allow sending above limit'
,
async
function
()
{
let
amount
=
1110
;
try
{
await
lb
.
limitedDeposit
({
value
:
amount
});
await
lb
.
limitedDeposit
({
value
:
amount
});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
assertJump
(
error
);
}
});
it
(
'should allow multiple sends below limit'
,
async
function
()
{
...
...
@@ -52,10 +52,10 @@ contract('LimitBalance', function(accounts) {
try
{
await
lb
.
limitedDeposit
({
value
:
amount
+
1
});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
assertJump
(
error
);
}
});
});
test/Ownable.js
View file @
60bc6a6d
...
...
@@ -29,6 +29,7 @@ contract('Ownable', function(accounts) {
assert
.
isTrue
(
owner
!==
other
);
try
{
await
ownable
.
transferOwnership
(
other
,
{
from
:
other
});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
}
...
...
test/Pausable.js
View file @
60bc6a6d
...
...
@@ -23,6 +23,7 @@ contract('Pausable', function(accounts) {
try
{
await
Pausable
.
normalProcess
();
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
}
...
...
@@ -35,10 +36,10 @@ contract('Pausable', function(accounts) {
let
Pausable
=
await
PausableMock
.
new
();
try
{
await
Pausable
.
drasticMeasure
();
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
}
const
drasticMeasureTaken
=
await
Pausable
.
drasticMeasureTaken
();
assert
.
isFalse
(
drasticMeasureTaken
);
});
...
...
@@ -68,6 +69,7 @@ contract('Pausable', function(accounts) {
await
Pausable
.
unpause
();
try
{
await
Pausable
.
drasticMeasure
();
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
assertJump
(
error
);
}
...
...
test/PausableToken.js
View file @
60bc6a6d
...
...
@@ -55,19 +55,19 @@ contract('PausableToken', function(accounts) {
await
token
.
pause
();
try
{
await
token
.
transfer
(
accounts
[
1
],
100
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
});
it
(
'should throw an error trying to transfer from another account while transactions are paused'
,
async
function
()
{
await
token
.
pause
();
try
{
await
token
.
transferFrom
(
accounts
[
0
],
accounts
[
1
],
100
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
});
})
\ No newline at end of file
test/SafeMath.js
View file @
60bc6a6d
...
...
@@ -40,10 +40,10 @@ contract('SafeMath', function(accounts) {
let
b
=
5678
;
try
{
let
subtract
=
await
safeMath
.
subtract
(
a
,
b
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
});
it
(
"should throw an error on addition overflow"
,
async
function
()
{
...
...
@@ -51,10 +51,10 @@ contract('SafeMath', function(accounts) {
let
b
=
1
;
try
{
let
add
=
await
safeMath
.
add
(
a
,
b
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
});
it
(
"should throw an error on multiplication overflow"
,
async
function
()
{
...
...
@@ -62,10 +62,10 @@ contract('SafeMath', function(accounts) {
let
b
=
2
;
try
{
let
multiply
=
await
safeMath
.
multiply
(
a
,
b
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
});
});
test/StandardToken.js
View file @
60bc6a6d
...
...
@@ -39,10 +39,10 @@ contract('StandardToken', function(accounts) {
let
token
=
await
StandardTokenMock
.
new
(
accounts
[
0
],
100
);
try
{
await
token
.
transfer
(
accounts
[
1
],
101
);
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
});
it
(
'should return correct balances after transfering from another account'
,
async
function
()
{
...
...
@@ -64,10 +64,10 @@ contract('StandardToken', function(accounts) {
await
token
.
approve
(
accounts
[
1
],
99
);
try
{
await
token
.
transferFrom
(
accounts
[
0
],
accounts
[
2
],
100
,
{
from
:
accounts
[
1
]});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
});
});
test/VestedToken.js
View file @
60bc6a6d
...
...
@@ -46,20 +46,20 @@ contract('VestedToken', function(accounts) {
it
(
'throws when trying to transfer non vested tokens'
,
async
()
=>
{
try
{
await
token
.
transfer
(
accounts
[
7
],
1
,
{
from
:
receiver
})
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
})
it
(
'throws when trying to transfer from non vested tokens'
,
async
()
=>
{
try
{
await
token
.
approve
(
accounts
[
7
],
1
,
{
from
:
receiver
})
await
token
.
transferFrom
(
receiver
,
accounts
[
7
],
tokenAmount
,
{
from
:
accounts
[
7
]
})
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
})
it
(
'can be revoked by granter'
,
async
()
=>
{
...
...
@@ -71,10 +71,10 @@ contract('VestedToken', function(accounts) {
it
(
'cannot be revoked by non granter'
,
async
()
=>
{
try
{
await
token
.
revokeTokenGrant
(
receiver
,
0
,
{
from
:
accounts
[
3
]
});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
})
it
(
'can be revoked by granter and non vested tokens are returned'
,
async
()
=>
{
...
...
@@ -131,10 +131,10 @@ contract('VestedToken', function(accounts) {
it
(
'throws when granter attempts to revoke'
,
async
()
=>
{
try
{
await
token
.
revokeTokenGrant
(
receiver
,
0
,
{
from
:
granter
});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
})
})
...
...
@@ -160,10 +160,10 @@ contract('VestedToken', function(accounts) {
it
(
'cannot be revoked by non granter'
,
async
()
=>
{
try
{
await
token
.
revokeTokenGrant
(
receiver
,
0
,
{
from
:
accounts
[
3
]
});
assert
.
fail
(
'should have thrown before'
);
}
catch
(
error
)
{
return
assertJump
(
error
);
assertJump
(
error
);
}
assert
.
fail
(
'should have thrown before'
);
})
it
(
'can be revoked by granter and non vested tokens are returned'
,
async
()
=>
{
...
...
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