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
34bc709b
Unverified
Commit
34bc709b
authored
Oct 02, 2018
by
Nicolás Venturo
Committed by
GitHub
Oct 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged latestTime, increaseTime and duration into a time helper. (#1364)
parent
6ae041bc
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
84 additions
and
95 deletions
+84
-95
FinalizableCrowdsale.test.js
test/crowdsale/FinalizableCrowdsale.test.js
+7
-8
IncreasingPriceCrowdsale.test.js
test/crowdsale/IncreasingPriceCrowdsale.test.js
+11
-12
PostDeliveryCrowdsale.test.js
test/crowdsale/PostDeliveryCrowdsale.test.js
+6
-7
RefundableCrowdsale.test.js
test/crowdsale/RefundableCrowdsale.test.js
+7
-8
TimedCrowdsale.test.js
test/crowdsale/TimedCrowdsale.test.js
+9
-10
SampleCrowdsale.test.js
test/examples/SampleCrowdsale.test.js
+11
-12
latestTime.js
test/helpers/latestTime.js
+0
-11
time.js
test/helpers/time.js
+14
-7
TokenTimelock.test.js
test/token/ERC20/TokenTimelock.test.js
+7
-8
TokenVesting.test.js
test/token/ERC20/TokenVesting.test.js
+12
-12
No files found.
test/crowdsale/FinalizableCrowdsale.test.js
View file @
34bc709b
const
expectEvent
=
require
(
'../helpers/expectEvent'
);
const
expectEvent
=
require
(
'../helpers/expectEvent'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../helpers/increaseTime'
);
const
time
=
require
(
'../helpers/time'
);
const
{
latestTime
}
=
require
(
'../helpers/latestTime'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
...
@@ -23,9 +22,9 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
...
@@ -23,9 +22,9 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
});
});
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
openingTime
=
(
await
latestTime
())
+
duration
.
weeks
(
1
);
this
.
openingTime
=
(
await
time
.
latest
())
+
time
.
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
time
.
duration
.
weeks
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
duration
.
seconds
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
time
.
duration
.
seconds
(
1
);
this
.
token
=
await
ERC20
.
new
();
this
.
token
=
await
ERC20
.
new
();
this
.
crowdsale
=
await
FinalizableCrowdsaleImpl
.
new
(
this
.
crowdsale
=
await
FinalizableCrowdsaleImpl
.
new
(
...
@@ -38,18 +37,18 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
...
@@ -38,18 +37,18 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
});
});
it
(
'can be finalized by anyone after ending'
,
async
function
()
{
it
(
'can be finalized by anyone after ending'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
});
});
it
(
'cannot be finalized twice'
,
async
function
()
{
it
(
'cannot be finalized twice'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
await
expectThrow
(
this
.
crowdsale
.
finalize
({
from
:
anyone
}),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
finalize
({
from
:
anyone
}),
EVMRevert
);
});
});
it
(
'logs finalized'
,
async
function
()
{
it
(
'logs finalized'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
const
{
logs
}
=
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
const
{
logs
}
=
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
expectEvent
.
inLogs
(
logs
,
'CrowdsaleFinalized'
);
expectEvent
.
inLogs
(
logs
,
'CrowdsaleFinalized'
);
});
});
...
...
test/crowdsale/IncreasingPriceCrowdsale.test.js
View file @
34bc709b
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../helpers/increaseTime'
);
const
time
=
require
(
'../helpers/time'
);
const
{
latestTime
}
=
require
(
'../helpers/latestTime'
);
const
{
assertRevert
}
=
require
(
'../helpers/assertRevert'
);
const
{
assertRevert
}
=
require
(
'../helpers/assertRevert'
);
const
BigNumber
=
web3
.
BigNumber
;
const
BigNumber
=
web3
.
BigNumber
;
...
@@ -29,9 +28,9 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
...
@@ -29,9 +28,9 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
await
advanceBlock
();
await
advanceBlock
();
this
.
startTime
=
(
await
latestTime
())
+
duration
.
weeks
(
1
);
this
.
startTime
=
(
await
time
.
latest
())
+
time
.
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
startTime
+
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
startTime
+
time
.
duration
.
weeks
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
duration
.
seconds
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
time
.
duration
.
seconds
(
1
);
this
.
token
=
await
SimpleToken
.
new
();
this
.
token
=
await
SimpleToken
.
new
();
});
});
...
@@ -61,43 +60,43 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
...
@@ -61,43 +60,43 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
});
});
it
(
'at start'
,
async
function
()
{
it
(
'at start'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
startTime
);
await
time
.
increas
eTo
(
this
.
startTime
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
initialRate
));
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
initialRate
));
});
});
it
(
'at time 150'
,
async
function
()
{
it
(
'at time 150'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
startTime
+
150
);
await
time
.
increas
eTo
(
this
.
startTime
+
150
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime150
));
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime150
));
});
});
it
(
'at time 300'
,
async
function
()
{
it
(
'at time 300'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
startTime
+
300
);
await
time
.
increas
eTo
(
this
.
startTime
+
300
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime300
));
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime300
));
});
});
it
(
'at time 1500'
,
async
function
()
{
it
(
'at time 1500'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
startTime
+
1500
);
await
time
.
increas
eTo
(
this
.
startTime
+
1500
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime1500
));
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime1500
));
});
});
it
(
'at time 30'
,
async
function
()
{
it
(
'at time 30'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
startTime
+
30
);
await
time
.
increas
eTo
(
this
.
startTime
+
30
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime30
));
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime30
));
});
});
it
(
'at time 150000'
,
async
function
()
{
it
(
'at time 150000'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
startTime
+
150000
);
await
time
.
increas
eTo
(
this
.
startTime
+
150000
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime150000
));
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime150000
));
});
});
it
(
'at time 450000'
,
async
function
()
{
it
(
'at time 450000'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
startTime
+
450000
);
await
time
.
increas
eTo
(
this
.
startTime
+
450000
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime450000
));
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
value
.
mul
(
rateAtTime450000
));
});
});
...
...
test/crowdsale/PostDeliveryCrowdsale.test.js
View file @
34bc709b
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../helpers/increaseTime'
);
const
time
=
require
(
'../helpers/time'
);
const
{
latestTime
}
=
require
(
'../helpers/latestTime'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
ether
}
=
require
(
'../helpers/ether'
);
...
@@ -24,9 +23,9 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -24,9 +23,9 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
});
});
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
openingTime
=
(
await
latestTime
())
+
duration
.
weeks
(
1
);
this
.
openingTime
=
(
await
time
.
latest
())
+
time
.
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
time
.
duration
.
weeks
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
duration
.
seconds
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
time
.
duration
.
seconds
(
1
);
this
.
token
=
await
SimpleToken
.
new
();
this
.
token
=
await
SimpleToken
.
new
();
this
.
crowdsale
=
await
PostDeliveryCrowdsaleImpl
.
new
(
this
.
crowdsale
=
await
PostDeliveryCrowdsaleImpl
.
new
(
this
.
openingTime
,
this
.
closingTime
,
rate
,
wallet
,
this
.
token
.
address
this
.
openingTime
,
this
.
closingTime
,
rate
,
wallet
,
this
.
token
.
address
...
@@ -36,7 +35,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -36,7 +35,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
context
(
'after opening time'
,
function
()
{
context
(
'after opening time'
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
await
increaseTim
eTo
(
this
.
openingTime
);
await
time
.
increas
eTo
(
this
.
openingTime
);
});
});
context
(
'with bought tokens'
,
function
()
{
context
(
'with bought tokens'
,
function
()
{
...
@@ -57,7 +56,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -57,7 +56,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
context
(
'after closing time'
,
function
()
{
context
(
'after closing time'
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
});
});
it
(
'allows beneficiaries to withdraw tokens'
,
async
function
()
{
it
(
'allows beneficiaries to withdraw tokens'
,
async
function
()
{
...
...
test/crowdsale/RefundableCrowdsale.test.js
View file @
34bc709b
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../helpers/increaseTime'
);
const
time
=
require
(
'../helpers/time'
);
const
{
latestTime
}
=
require
(
'../helpers/latestTime'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
ethGetBalance
}
=
require
(
'../helpers/web3'
);
const
{
ethGetBalance
}
=
require
(
'../helpers/web3'
);
...
@@ -27,9 +26,9 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
...
@@ -27,9 +26,9 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
});
});
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
openingTime
=
(
await
latestTime
())
+
duration
.
weeks
(
1
);
this
.
openingTime
=
(
await
time
.
latest
())
+
time
.
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
time
.
duration
.
weeks
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
duration
.
seconds
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
time
.
duration
.
seconds
(
1
);
this
.
preWalletBalance
=
await
ethGetBalance
(
wallet
);
this
.
preWalletBalance
=
await
ethGetBalance
(
wallet
);
this
.
token
=
await
SimpleToken
.
new
();
this
.
token
=
await
SimpleToken
.
new
();
...
@@ -61,7 +60,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
...
@@ -61,7 +60,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
context
(
'after opening time'
,
function
()
{
context
(
'after opening time'
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
await
increaseTim
eTo
(
this
.
openingTime
);
await
time
.
increas
eTo
(
this
.
openingTime
);
});
});
it
(
'denies refunds'
,
async
function
()
{
it
(
'denies refunds'
,
async
function
()
{
...
@@ -75,7 +74,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
...
@@ -75,7 +74,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
context
(
'after closing time and finalization'
,
function
()
{
context
(
'after closing time and finalization'
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
});
});
...
@@ -95,7 +94,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
...
@@ -95,7 +94,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
context
(
'after closing time and finalization'
,
function
()
{
context
(
'after closing time and finalization'
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
await
this
.
crowdsale
.
finalize
({
from
:
anyone
});
});
});
...
...
test/crowdsale/TimedCrowdsale.test.js
View file @
34bc709b
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../helpers/increaseTime'
);
const
time
=
require
(
'../helpers/time'
);
const
{
latestTime
}
=
require
(
'../helpers/latestTime'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
...
@@ -25,21 +24,21 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -25,21 +24,21 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
});
});
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
openingTime
=
(
await
latestTime
())
+
duration
.
weeks
(
1
);
this
.
openingTime
=
(
await
time
.
latest
())
+
time
.
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
time
.
duration
.
weeks
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
duration
.
seconds
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
time
.
duration
.
seconds
(
1
);
this
.
token
=
await
SimpleToken
.
new
();
this
.
token
=
await
SimpleToken
.
new
();
});
});
it
(
'rejects an opening time in the past'
,
async
function
()
{
it
(
'rejects an opening time in the past'
,
async
function
()
{
await
expectThrow
(
TimedCrowdsaleImpl
.
new
(
await
expectThrow
(
TimedCrowdsaleImpl
.
new
(
(
await
latestTime
())
-
duration
.
days
(
1
),
this
.
closingTime
,
rate
,
wallet
,
this
.
token
.
address
(
await
time
.
latest
())
-
time
.
duration
.
days
(
1
),
this
.
closingTime
,
rate
,
wallet
,
this
.
token
.
address
),
EVMRevert
);
),
EVMRevert
);
});
});
it
(
'rejects a closing time before the opening time'
,
async
function
()
{
it
(
'rejects a closing time before the opening time'
,
async
function
()
{
await
expectThrow
(
TimedCrowdsaleImpl
.
new
(
await
expectThrow
(
TimedCrowdsaleImpl
.
new
(
this
.
openingTime
,
this
.
openingTime
-
duration
.
seconds
(
1
),
rate
,
wallet
,
this
.
token
.
address
this
.
openingTime
,
this
.
openingTime
-
time
.
duration
.
seconds
(
1
),
rate
,
wallet
,
this
.
token
.
address
),
EVMRevert
);
),
EVMRevert
);
});
});
...
@@ -53,7 +52,7 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -53,7 +52,7 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
it
(
'should be ended only after end'
,
async
function
()
{
it
(
'should be ended only after end'
,
async
function
()
{
(
await
this
.
crowdsale
.
hasClosed
()).
should
.
equal
(
false
);
(
await
this
.
crowdsale
.
hasClosed
()).
should
.
equal
(
false
);
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
(
await
this
.
crowdsale
.
isOpen
()).
should
.
equal
(
false
);
(
await
this
.
crowdsale
.
isOpen
()).
should
.
equal
(
false
);
(
await
this
.
crowdsale
.
hasClosed
()).
should
.
equal
(
true
);
(
await
this
.
crowdsale
.
hasClosed
()).
should
.
equal
(
true
);
});
});
...
@@ -66,14 +65,14 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
...
@@ -66,14 +65,14 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
});
});
it
(
'should accept payments after start'
,
async
function
()
{
it
(
'should accept payments after start'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
openingTime
);
await
time
.
increas
eTo
(
this
.
openingTime
);
(
await
this
.
crowdsale
.
isOpen
()).
should
.
equal
(
true
);
(
await
this
.
crowdsale
.
isOpen
()).
should
.
equal
(
true
);
await
this
.
crowdsale
.
send
(
value
);
await
this
.
crowdsale
.
send
(
value
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
value
,
from
:
purchaser
});
});
});
it
(
'should reject payments after end'
,
async
function
()
{
it
(
'should reject payments after end'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
expectThrow
(
this
.
crowdsale
.
send
(
value
),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
send
(
value
),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
value
,
from
:
purchaser
}),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
value
,
from
:
purchaser
}),
EVMRevert
);
});
});
...
...
test/examples/SampleCrowdsale.test.js
View file @
34bc709b
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
ether
}
=
require
(
'../helpers/ether'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
advanceBlock
}
=
require
(
'../helpers/advanceToBlock'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../helpers/increaseTime'
);
const
time
=
require
(
'../helpers/time'
);
const
{
latestTime
}
=
require
(
'../helpers/latestTime'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
assertRevert
}
=
require
(
'../helpers/assertRevert'
);
const
{
assertRevert
}
=
require
(
'../helpers/assertRevert'
);
...
@@ -27,9 +26,9 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
...
@@ -27,9 +26,9 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
});
});
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
openingTime
=
(
await
latestTime
())
+
duration
.
weeks
(
1
);
this
.
openingTime
=
(
await
time
.
latest
())
+
time
.
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
duration
.
weeks
(
1
);
this
.
closingTime
=
this
.
openingTime
+
time
.
duration
.
weeks
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
duration
.
seconds
(
1
);
this
.
afterClosingTime
=
this
.
closingTime
+
time
.
duration
.
seconds
(
1
);
this
.
token
=
await
SampleCrowdsaleToken
.
new
({
from
:
deployer
});
this
.
token
=
await
SampleCrowdsaleToken
.
new
({
from
:
deployer
});
this
.
crowdsale
=
await
SampleCrowdsale
.
new
(
this
.
crowdsale
=
await
SampleCrowdsale
.
new
(
...
@@ -68,7 +67,7 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
...
@@ -68,7 +67,7 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
const
investmentAmount
=
ether
(
1
);
const
investmentAmount
=
ether
(
1
);
const
expectedTokenAmount
=
RATE
.
mul
(
investmentAmount
);
const
expectedTokenAmount
=
RATE
.
mul
(
investmentAmount
);
await
increaseTim
eTo
(
this
.
openingTime
);
await
time
.
increas
eTo
(
this
.
openingTime
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
investmentAmount
,
from
:
investor
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
investmentAmount
,
from
:
investor
});
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
expectedTokenAmount
);
(
await
this
.
token
.
balanceOf
(
investor
)).
should
.
be
.
bignumber
.
equal
(
expectedTokenAmount
);
...
@@ -76,23 +75,23 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
...
@@ -76,23 +75,23 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
});
});
it
(
'should reject payments after end'
,
async
function
()
{
it
(
'should reject payments after end'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
expectThrow
(
this
.
crowdsale
.
send
(
ether
(
1
)),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
send
(
ether
(
1
)),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
ether
(
1
),
from
:
investor
}),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
:
ether
(
1
),
from
:
investor
}),
EVMRevert
);
});
});
it
(
'should reject payments over cap'
,
async
function
()
{
it
(
'should reject payments over cap'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
openingTime
);
await
time
.
increas
eTo
(
this
.
openingTime
);
await
this
.
crowdsale
.
send
(
CAP
);
await
this
.
crowdsale
.
send
(
CAP
);
await
expectThrow
(
this
.
crowdsale
.
send
(
1
),
EVMRevert
);
await
expectThrow
(
this
.
crowdsale
.
send
(
1
),
EVMRevert
);
});
});
it
(
'should allow finalization and transfer funds to wallet if the goal is reached'
,
async
function
()
{
it
(
'should allow finalization and transfer funds to wallet if the goal is reached'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
openingTime
);
await
time
.
increas
eTo
(
this
.
openingTime
);
await
this
.
crowdsale
.
send
(
GOAL
);
await
this
.
crowdsale
.
send
(
GOAL
);
const
beforeFinalization
=
await
ethGetBalance
(
wallet
);
const
beforeFinalization
=
await
ethGetBalance
(
wallet
);
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
this
.
crowdsale
.
finalize
({
from
:
owner
});
await
this
.
crowdsale
.
finalize
({
from
:
owner
});
const
afterFinalization
=
await
ethGetBalance
(
wallet
);
const
afterFinalization
=
await
ethGetBalance
(
wallet
);
...
@@ -102,9 +101,9 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
...
@@ -102,9 +101,9 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
it
(
'should allow refunds if the goal is not reached'
,
async
function
()
{
it
(
'should allow refunds if the goal is not reached'
,
async
function
()
{
const
balanceBeforeInvestment
=
await
ethGetBalance
(
investor
);
const
balanceBeforeInvestment
=
await
ethGetBalance
(
investor
);
await
increaseTim
eTo
(
this
.
openingTime
);
await
time
.
increas
eTo
(
this
.
openingTime
);
await
this
.
crowdsale
.
sendTransaction
({
value
:
ether
(
1
),
from
:
investor
,
gasPrice
:
0
});
await
this
.
crowdsale
.
sendTransaction
({
value
:
ether
(
1
),
from
:
investor
,
gasPrice
:
0
});
await
increaseTim
eTo
(
this
.
afterClosingTime
);
await
time
.
increas
eTo
(
this
.
afterClosingTime
);
await
this
.
crowdsale
.
finalize
({
from
:
owner
});
await
this
.
crowdsale
.
finalize
({
from
:
owner
});
await
this
.
crowdsale
.
claimRefund
(
investor
,
{
gasPrice
:
0
});
await
this
.
crowdsale
.
claimRefund
(
investor
,
{
gasPrice
:
0
});
...
...
test/helpers/latestTime.js
deleted
100644 → 0
View file @
6ae041bc
const
{
ethGetBlock
}
=
require
(
'./web3'
);
// Returns the time of the last mined block in seconds
async
function
latestTime
()
{
const
block
=
await
ethGetBlock
(
'latest'
);
return
block
.
timestamp
;
}
module
.
exports
=
{
latestTime
,
};
test/helpers/
increaseT
ime.js
→
test/helpers/
t
ime.js
View file @
34bc709b
const
{
latestTime
}
=
require
(
'./latestTime'
);
const
{
ethGetBlock
}
=
require
(
'./web3'
);
// Returns the time of the last mined block in seconds
async
function
latest
()
{
const
block
=
await
ethGetBlock
(
'latest'
);
return
block
.
timestamp
;
}
// Increases ganache time by the passed duration in seconds
// Increases ganache time by the passed duration in seconds
function
increase
Time
(
duration
)
{
function
increase
(
duration
)
{
const
id
=
Date
.
now
();
const
id
=
Date
.
now
();
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
@@ -31,12 +37,12 @@ function increaseTime (duration) {
...
@@ -31,12 +37,12 @@ function increaseTime (duration) {
*
*
* @param target time in seconds
* @param target time in seconds
*/
*/
async
function
increaseT
imeT
o
(
target
)
{
async
function
increaseTo
(
target
)
{
const
now
=
(
await
latest
Time
());
const
now
=
(
await
latest
());
if
(
target
<
now
)
throw
Error
(
`Cannot increase current time(
${
now
}
) to a moment in the past(
${
target
}
)`
);
if
(
target
<
now
)
throw
Error
(
`Cannot increase current time(
${
now
}
) to a moment in the past(
${
target
}
)`
);
const
diff
=
target
-
now
;
const
diff
=
target
-
now
;
return
increase
Time
(
diff
);
return
increase
(
diff
);
}
}
const
duration
=
{
const
duration
=
{
...
@@ -49,7 +55,8 @@ const duration = {
...
@@ -49,7 +55,8 @@ const duration = {
};
};
module
.
exports
=
{
module
.
exports
=
{
increaseTime
,
latest
,
increaseTimeTo
,
increase
,
increaseTo
,
duration
,
duration
,
};
};
test/token/ERC20/TokenTimelock.test.js
View file @
34bc709b
const
{
latestTime
}
=
require
(
'../../helpers/latestTime'
);
const
time
=
require
(
'../../helpers/time'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../../helpers/increaseTime'
);
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
BigNumber
=
web3
.
BigNumber
;
const
BigNumber
=
web3
.
BigNumber
;
...
@@ -20,7 +19,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
...
@@ -20,7 +19,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
});
});
it
(
'rejects a release time in the past'
,
async
function
()
{
it
(
'rejects a release time in the past'
,
async
function
()
{
const
pastReleaseTime
=
(
await
latestTime
())
-
duration
.
years
(
1
);
const
pastReleaseTime
=
(
await
time
.
latest
())
-
time
.
duration
.
years
(
1
);
await
expectThrow
(
await
expectThrow
(
TokenTimelock
.
new
(
this
.
token
.
address
,
beneficiary
,
pastReleaseTime
)
TokenTimelock
.
new
(
this
.
token
.
address
,
beneficiary
,
pastReleaseTime
)
);
);
...
@@ -28,7 +27,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
...
@@ -28,7 +27,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
context
(
'once deployed'
,
function
()
{
context
(
'once deployed'
,
function
()
{
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
releaseTime
=
(
await
latestTime
())
+
duration
.
years
(
1
);
this
.
releaseTime
=
(
await
time
.
latest
())
+
time
.
duration
.
years
(
1
);
this
.
timelock
=
await
TokenTimelock
.
new
(
this
.
token
.
address
,
beneficiary
,
this
.
releaseTime
);
this
.
timelock
=
await
TokenTimelock
.
new
(
this
.
token
.
address
,
beneficiary
,
this
.
releaseTime
);
await
this
.
token
.
mint
(
this
.
timelock
.
address
,
amount
,
{
from
:
minter
});
await
this
.
token
.
mint
(
this
.
timelock
.
address
,
amount
,
{
from
:
minter
});
});
});
...
@@ -44,24 +43,24 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
...
@@ -44,24 +43,24 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
});
});
it
(
'cannot be released just before time limit'
,
async
function
()
{
it
(
'cannot be released just before time limit'
,
async
function
()
{
await
increaseTimeTo
(
this
.
releaseTime
-
duration
.
seconds
(
3
));
await
time
.
increaseTo
(
this
.
releaseTime
-
time
.
duration
.
seconds
(
3
));
await
expectThrow
(
this
.
timelock
.
release
());
await
expectThrow
(
this
.
timelock
.
release
());
});
});
it
(
'can be released just after limit'
,
async
function
()
{
it
(
'can be released just after limit'
,
async
function
()
{
await
increaseTimeTo
(
this
.
releaseTime
+
duration
.
seconds
(
1
));
await
time
.
increaseTo
(
this
.
releaseTime
+
time
.
duration
.
seconds
(
1
));
await
this
.
timelock
.
release
();
await
this
.
timelock
.
release
();
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
be
.
bignumber
.
equal
(
amount
);
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
be
.
bignumber
.
equal
(
amount
);
});
});
it
(
'can be released after time limit'
,
async
function
()
{
it
(
'can be released after time limit'
,
async
function
()
{
await
increaseTimeTo
(
this
.
releaseTime
+
duration
.
years
(
1
));
await
time
.
increaseTo
(
this
.
releaseTime
+
time
.
duration
.
years
(
1
));
await
this
.
timelock
.
release
();
await
this
.
timelock
.
release
();
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
be
.
bignumber
.
equal
(
amount
);
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
be
.
bignumber
.
equal
(
amount
);
});
});
it
(
'cannot be released twice'
,
async
function
()
{
it
(
'cannot be released twice'
,
async
function
()
{
await
increaseTimeTo
(
this
.
releaseTime
+
duration
.
years
(
1
));
await
time
.
increaseTo
(
this
.
releaseTime
+
time
.
duration
.
years
(
1
));
await
this
.
timelock
.
release
();
await
this
.
timelock
.
release
();
await
expectThrow
(
this
.
timelock
.
release
());
await
expectThrow
(
this
.
timelock
.
release
());
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
be
.
bignumber
.
equal
(
amount
);
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
be
.
bignumber
.
equal
(
amount
);
...
...
test/token/ERC20/TokenVesting.test.js
View file @
34bc709b
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
{
expectThrow
}
=
require
(
'../../helpers/expectThrow'
);
const
{
EVMRevert
}
=
require
(
'../../helpers/EVMRevert'
);
const
{
EVMRevert
}
=
require
(
'../../helpers/EVMRevert'
);
const
{
latestTime
}
=
require
(
'../../helpers/latestTime'
);
const
time
=
require
(
'../../helpers/time'
);
const
{
increaseTimeTo
,
duration
}
=
require
(
'../../helpers/increaseTime'
);
const
{
ethGetBlock
}
=
require
(
'../../helpers/web3'
);
const
{
ethGetBlock
}
=
require
(
'../../helpers/web3'
);
const
BigNumber
=
web3
.
BigNumber
;
const
BigNumber
=
web3
.
BigNumber
;
...
@@ -18,9 +17,10 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
...
@@ -18,9 +17,10 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const
ZERO_ADDRESS
=
'0x0000000000000000000000000000000000000000'
;
const
ZERO_ADDRESS
=
'0x0000000000000000000000000000000000000000'
;
beforeEach
(
async
function
()
{
beforeEach
(
async
function
()
{
this
.
start
=
(
await
latestTime
())
+
duration
.
minutes
(
1
);
// +1 minute so it starts after contract instantiation
// +1 minute so it starts after contract instantiation
this
.
cliffDuration
=
duration
.
years
(
1
);
this
.
start
=
(
await
time
.
latest
())
+
time
.
duration
.
minutes
(
1
);
this
.
duration
=
duration
.
years
(
2
);
this
.
cliffDuration
=
time
.
duration
.
years
(
1
);
this
.
duration
=
time
.
duration
.
years
(
2
);
});
});
it
(
'rejects a duration shorter than the cliff'
,
async
function
()
{
it
(
'rejects a duration shorter than the cliff'
,
async
function
()
{
...
@@ -65,12 +65,12 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
...
@@ -65,12 +65,12 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
});
});
it
(
'can be released after cliff'
,
async
function
()
{
it
(
'can be released after cliff'
,
async
function
()
{
await
increaseTimeTo
(
this
.
start
+
this
.
cliffDuration
+
duration
.
weeks
(
1
));
await
time
.
increaseTo
(
this
.
start
+
this
.
cliffDuration
+
time
.
duration
.
weeks
(
1
));
await
this
.
vesting
.
release
(
this
.
token
.
address
);
await
this
.
vesting
.
release
(
this
.
token
.
address
);
});
});
it
(
'should release proper amount after cliff'
,
async
function
()
{
it
(
'should release proper amount after cliff'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
start
+
this
.
cliffDuration
);
await
time
.
increas
eTo
(
this
.
start
+
this
.
cliffDuration
);
const
{
receipt
}
=
await
this
.
vesting
.
release
(
this
.
token
.
address
);
const
{
receipt
}
=
await
this
.
vesting
.
release
(
this
.
token
.
address
);
const
block
=
await
ethGetBlock
(
receipt
.
blockNumber
);
const
block
=
await
ethGetBlock
(
receipt
.
blockNumber
);
...
@@ -87,7 +87,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
...
@@ -87,7 +87,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
for
(
let
i
=
1
;
i
<=
checkpoints
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
checkpoints
;
i
++
)
{
const
now
=
this
.
start
+
this
.
cliffDuration
+
i
*
(
vestingPeriod
/
checkpoints
);
const
now
=
this
.
start
+
this
.
cliffDuration
+
i
*
(
vestingPeriod
/
checkpoints
);
await
increaseTim
eTo
(
now
);
await
time
.
increas
eTo
(
now
);
await
this
.
vesting
.
release
(
this
.
token
.
address
);
await
this
.
vesting
.
release
(
this
.
token
.
address
);
const
expectedVesting
=
amount
.
mul
(
now
-
this
.
start
).
div
(
this
.
duration
).
floor
();
const
expectedVesting
=
amount
.
mul
(
now
-
this
.
start
).
div
(
this
.
duration
).
floor
();
...
@@ -97,7 +97,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
...
@@ -97,7 +97,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
});
});
it
(
'should have released all after end'
,
async
function
()
{
it
(
'should have released all after end'
,
async
function
()
{
await
increaseTim
eTo
(
this
.
start
+
this
.
duration
);
await
time
.
increas
eTo
(
this
.
start
+
this
.
duration
);
await
this
.
vesting
.
release
(
this
.
token
.
address
);
await
this
.
vesting
.
release
(
this
.
token
.
address
);
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
bignumber
.
equal
(
amount
);
(
await
this
.
token
.
balanceOf
(
beneficiary
)).
should
.
bignumber
.
equal
(
amount
);
(
await
this
.
vesting
.
released
(
this
.
token
.
address
)).
should
.
bignumber
.
equal
(
amount
);
(
await
this
.
vesting
.
released
(
this
.
token
.
address
)).
should
.
bignumber
.
equal
(
amount
);
...
@@ -120,7 +120,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
...
@@ -120,7 +120,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
});
});
it
(
'should return the non-vested tokens when revoked by owner'
,
async
function
()
{
it
(
'should return the non-vested tokens when revoked by owner'
,
async
function
()
{
await
increaseTimeTo
(
this
.
start
+
this
.
cliffDuration
+
duration
.
weeks
(
12
));
await
time
.
increaseTo
(
this
.
start
+
this
.
cliffDuration
+
time
.
duration
.
weeks
(
12
));
const
vested
=
await
this
.
vesting
.
vestedAmount
(
this
.
token
.
address
);
const
vested
=
await
this
.
vesting
.
vestedAmount
(
this
.
token
.
address
);
...
@@ -130,7 +130,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
...
@@ -130,7 +130,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
});
});
it
(
'should keep the vested tokens when revoked by owner'
,
async
function
()
{
it
(
'should keep the vested tokens when revoked by owner'
,
async
function
()
{
await
increaseTimeTo
(
this
.
start
+
this
.
cliffDuration
+
duration
.
weeks
(
12
));
await
time
.
increaseTo
(
this
.
start
+
this
.
cliffDuration
+
time
.
duration
.
weeks
(
12
));
const
vestedPre
=
await
this
.
vesting
.
vestedAmount
(
this
.
token
.
address
);
const
vestedPre
=
await
this
.
vesting
.
vestedAmount
(
this
.
token
.
address
);
...
@@ -142,7 +142,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
...
@@ -142,7 +142,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
});
});
it
(
'should fail to be revoked a second time'
,
async
function
()
{
it
(
'should fail to be revoked a second time'
,
async
function
()
{
await
increaseTimeTo
(
this
.
start
+
this
.
cliffDuration
+
duration
.
weeks
(
12
));
await
time
.
increaseTo
(
this
.
start
+
this
.
cliffDuration
+
time
.
duration
.
weeks
(
12
));
await
this
.
vesting
.
vestedAmount
(
this
.
token
.
address
);
await
this
.
vesting
.
vestedAmount
(
this
.
token
.
address
);
...
...
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