-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Increase test coverage #1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Increase test coverage #1237
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
991d0ee
Fixed a SplitPayment test
nventuro 1573086
Deleted unnecessary function.
nventuro 22788d9
Improved PostDeliveryCrowdsale tests.
nventuro aeb5407
Improved RefundableCrowdsale tests.
nventuro ba02ab0
Improved MintedCrowdsale tests.
nventuro 193a506
Improved IncreasingPriceCrowdsale tests.
nventuro 12f4420
Fixed a CappedCrowdsale test.
nventuro 5b0d148
Improved TimedCrowdsale tests.
nventuro 33a6c5d
Improved descriptions of added tests.
nventuro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improved PostDeliveryCrowdsale tests.
- Loading branch information
commit 22788d96ff96e3b965b3317d763ee4cd7b22263f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ const SimpleToken = artifacts.require('SimpleToken'); | |
|
|
||
| contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { | ||
| const rate = new BigNumber(1); | ||
| const value = ether(42); | ||
| const tokenSupply = new BigNumber('1e22'); | ||
|
|
||
| before(async function () { | ||
|
|
@@ -27,7 +26,6 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { | |
| beforeEach(async function () { | ||
| this.openingTime = (await latestTime()) + duration.weeks(1); | ||
| this.closingTime = this.openingTime + duration.weeks(1); | ||
| this.beforeEndTime = this.closingTime - duration.hours(1); | ||
| this.afterClosingTime = this.closingTime + duration.seconds(1); | ||
| this.token = await SimpleToken.new(); | ||
| this.crowdsale = await PostDeliveryCrowdsale.new( | ||
|
|
@@ -36,30 +34,41 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { | |
| await this.token.transfer(this.crowdsale.address, tokenSupply); | ||
| }); | ||
|
|
||
| it('should not immediately assign tokens to beneficiary', async function () { | ||
| await increaseTimeTo(this.openingTime); | ||
| await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); | ||
| (await this.token.balanceOf(investor)).should.be.bignumber.equal(0); | ||
| }); | ||
| context('after opening time', function () { | ||
| beforeEach(async function () { | ||
| await increaseTimeTo(this.openingTime); | ||
| }); | ||
|
|
||
| it('should not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { | ||
| await increaseTimeTo(this.beforeEndTime); | ||
| await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); | ||
| await expectThrow(this.crowdsale.withdrawTokens({ from: investor }), EVMRevert); | ||
| }); | ||
| context('with bought tokens', function () { | ||
| const value = ether(42); | ||
|
|
||
| it('should allow beneficiaries to withdraw tokens after crowdsale ends', async function () { | ||
| await increaseTimeTo(this.openingTime); | ||
| await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); | ||
| await increaseTimeTo(this.afterClosingTime); | ||
| await this.crowdsale.withdrawTokens({ from: investor }); | ||
| }); | ||
| beforeEach(async function () { | ||
| await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); | ||
| }); | ||
|
|
||
| it('should not immediately assign tokens to beneficiary', async function () { | ||
| (await this.token.balanceOf(investor)).should.be.bignumber.equal(0); | ||
| }); | ||
|
|
||
| it('should not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { | ||
| await expectThrow(this.crowdsale.withdrawTokens({ from: investor }), EVMRevert); | ||
| }); | ||
|
|
||
| context('after closing time', function () { | ||
| beforeEach(async function () { | ||
| await increaseTimeTo(this.afterClosingTime); | ||
| }); | ||
|
|
||
| it('should allow beneficiaries to withdraw tokens', async function () { | ||
| await this.crowdsale.withdrawTokens({ from: investor }); | ||
| (await this.token.balanceOf(investor)).should.be.bignumber.equal(value); | ||
| }); | ||
|
|
||
| it('should return the amount of tokens bought', async function () { | ||
| await increaseTimeTo(this.openingTime); | ||
| await this.crowdsale.buyTokens(investor, { value: value, from: purchaser }); | ||
| await increaseTimeTo(this.afterClosingTime); | ||
| await this.crowdsale.withdrawTokens({ from: investor }); | ||
| (await this.token.balanceOf(investor)).should.be.bignumber.equal(value); | ||
| it('should ony allow a single withdrawal', async function () { | ||
|
||
| await this.crowdsale.withdrawTokens({ from: investor }); | ||
| await expectThrow(this.crowdsale.withdrawTokens({ from: investor }), EVMRevert); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say "before closing time" to be consistent with the other descriptions.