Add complex crowdsale example #331#342
Conversation
frangio
left a comment
There was a problem hiding this comment.
This is great! Thanks @jakub-wojciechowski. A couple of comments.
Let's put both contracts (crowdsale and token) in the same SampleCrowdsale.sol file. I envision each file in examples/ to be like a self-contained tutorial which you can read from top to bottom to learn about a part of OpenZeppelin.
Keep in mind this will be where newcomers will come to learn, so the examples should be thoroughly documented and explain what each line does. You don't need to include that in this PR, though go ahead if you want to!
The test is great too. It'll be useful as an integration test of all crowdsale features.
|
|
||
| string public constant name = "Sample Crowdsale Token"; | ||
| string public constant symbol = "SCT"; | ||
| uint256 public constant decimals = 18; |
There was a problem hiding this comment.
decimals should be uint8 according to ERC20. (I've just realized this is wrong in the SimpleToken example too.)
| (await this.crowdsale.startBlock()).should.be.bignumber.equal(this.startBlock); | ||
| (await this.crowdsale.endBlock()).should.be.bignumber.equal(this.endBlock); | ||
| (await this.crowdsale.rate()).should.be.bignumber.equal(RATE); | ||
| (await this.crowdsale.wallet()).should.be.bignumber.equal(wallet); |
There was a problem hiding this comment.
I'd have to confirm but I'm pretty sure Truffle returns address typed values as strings, not BigNumber instances. The test works because addresses are numbers anyway and they get converted, but it would be best to compare them as strings.
|
Thx for the comments @frangio. I'm glad that you liked integration tests :) |
Add complex crowdsale example OpenZeppelin#331
Resolves #331
Submitted together with SampleCrowdsaleToken to illustrate which components are needed to launch a crowdsale. Contains tests to demonstrate basic features of a crowdsale and to assure that combining different subclasses maintains their functionalities.