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
9155bfe2
Unverified
Commit
9155bfe2
authored
Oct 18, 2018
by
Nicolás Venturo
Committed by
GitHub
Oct 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IncPriceCrowdsale consistently returns 0 outside of the crowdsale window. (#1442)
parent
1c5f16ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
IncreasingPriceCrowdsale.sol
contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
+4
-0
IncreasingPriceCrowdsale.test.js
test/crowdsale/IncreasingPriceCrowdsale.test.js
+9
-0
No files found.
contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
View file @
9155bfe2
...
@@ -47,6 +47,10 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
...
@@ -47,6 +47,10 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
* @return The number of tokens a buyer gets per wei at a given time
* @return The number of tokens a buyer gets per wei at a given time
*/
*/
function getCurrentRate() public view returns (uint256) {
function getCurrentRate() public view returns (uint256) {
if (!isOpen()) {
return 0;
}
// solium-disable-next-line security/no-block-members
// solium-disable-next-line security/no-block-members
uint256 elapsedTime = block.timestamp.sub(openingTime());
uint256 elapsedTime = block.timestamp.sub(openingTime());
uint256 timeRange = closingTime().sub(openingTime());
uint256 timeRange = closingTime().sub(openingTime());
...
...
test/crowdsale/IncreasingPriceCrowdsale.test.js
View file @
9155bfe2
...
@@ -59,6 +59,15 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
...
@@ -59,6 +59,15 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
(
await
this
.
crowdsale
.
finalRate
()).
should
.
be
.
bignumber
.
equal
(
finalRate
);
(
await
this
.
crowdsale
.
finalRate
()).
should
.
be
.
bignumber
.
equal
(
finalRate
);
});
});
it
(
'returns a rate of 0 before the crowdsale starts'
,
async
function
()
{
(
await
this
.
crowdsale
.
getCurrentRate
()).
should
.
be
.
bignumber
.
equal
(
0
);
});
it
(
'returns a rate of 0 after the crowdsale ends'
,
async
function
()
{
await
time
.
increaseTo
(
this
.
afterClosingTime
);
(
await
this
.
crowdsale
.
getCurrentRate
()).
should
.
be
.
bignumber
.
equal
(
0
);
});
it
(
'at start'
,
async
function
()
{
it
(
'at start'
,
async
function
()
{
await
time
.
increaseTo
(
this
.
startTime
);
await
time
.
increaseTo
(
this
.
startTime
);
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
await
this
.
crowdsale
.
buyTokens
(
investor
,
{
value
,
from
:
purchaser
});
...
...
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