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
a936cbf5
Commit
a936cbf5
authored
Oct 19, 2018
by
Nicolás Venturo
Committed by
Leo Arias
Oct 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InitialRate must be strictly larger than finalRate. (#1441)
parent
1ac1ac98
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
IncreasingPriceCrowdsale.sol
contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
+9
-1
IncreasingPriceCrowdsale.test.js
test/crowdsale/IncreasingPriceCrowdsale.test.js
+12
-2
No files found.
contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
View file @
a936cbf5
...
...
@@ -22,12 +22,20 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
*/
constructor(uint256 initialRate, uint256 finalRate) internal {
require(finalRate > 0);
require(initialRate >
=
finalRate);
require(initialRate > finalRate);
_initialRate = initialRate;
_finalRate = finalRate;
}
/**
* The base rate function is overridden to revert, since this crowdsale doens't use it, and
* all calls to it are a mistake.
*/
function rate() public view returns(uint256) {
revert();
}
/**
* @return the initial rate of the crowdsale.
*/
function initialRate() public view returns(uint256) {
...
...
test/crowdsale/IncreasingPriceCrowdsale.test.js
View file @
a936cbf5
...
...
@@ -34,13 +34,19 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
this
.
token
=
await
SimpleToken
.
new
();
});
it
(
're
jects
a final rate larger than the initial rate'
,
async
function
()
{
it
(
're
verts with
a final rate larger than the initial rate'
,
async
function
()
{
await
shouldFail
.
reverting
(
IncreasingPriceCrowdsaleImpl
.
new
(
this
.
startTime
,
this
.
closingTime
,
wallet
,
this
.
token
.
address
,
initialRate
,
initialRate
.
plus
(
1
)
));
});
it
(
'rejects a final rate of zero'
,
async
function
()
{
it
(
'reverts with a final equal to the initial rate'
,
async
function
()
{
await
shouldFail
.
reverting
(
IncreasingPriceCrowdsaleImpl
.
new
(
this
.
startTime
,
this
.
closingTime
,
wallet
,
this
.
token
.
address
,
initialRate
,
initialRate
));
});
it
(
'reverts with a final rate of zero'
,
async
function
()
{
await
shouldFail
.
reverting
(
IncreasingPriceCrowdsaleImpl
.
new
(
this
.
startTime
,
this
.
closingTime
,
wallet
,
this
.
token
.
address
,
initialRate
,
0
));
...
...
@@ -59,6 +65,10 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
(
await
this
.
crowdsale
.
finalRate
()).
should
.
be
.
bignumber
.
equal
(
finalRate
);
});
it
(
'reverts when the base Crowdsale
\'
s rate function is called'
,
async
function
()
{
await
shouldFail
.
reverting
(
this
.
crowdsale
.
rate
());
});
it
(
'returns a rate of 0 before the crowdsale starts'
,
async
function
()
{
(
await
this
.
crowdsale
.
getCurrentRate
()).
should
.
be
.
bignumber
.
equal
(
0
);
});
...
...
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