Skip to content
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

add contracts for token and crowdsale, and solidity tests #5

Merged
merged 4 commits into from
Apr 18, 2018

Conversation

come-maiz
Copy link
Contributor

No description provided.

@@ -31,7 +33,9 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "mocha --require babel-core/register --require test/setup.js",
"test": "npm run test:react && npm run test:contracts",
"test:contracts": "truffle test test/contracts/* --network unexisting",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this weird. If I didn't set network, or set it to some existing network, it would say that the contract couldn't be deployed because of gas.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that by default the test network will be the development network which has a gasLimit. Did you try a higher one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But then I had plenty of problems with deploying the contracts to geth, and I read something about a wrong constructor. I made many changes back and forth, until it started working, so I'm not sure what was wrong.
I reported #7, to investigate this.

public
returns (bool)
{
require(jurisdiction.hasAttribute(_to, 'VALID'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be checked in transfer and transferFrom too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this!
I added the overwrites, and tests specific to the token.

@@ -31,7 +33,9 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "mocha --require babel-core/register --require test/setup.js",
"test": "npm run test:react && npm run test:contracts",
"test:contracts": "truffle test test/contracts/* --network unexisting",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that by default the test network will be the development network which has a gasLimit. Did you try a higher one?


beforeEach(async function () {
this.jurisdiction = await Jurisdiction.new();
this.jurisdiction.addValidator(owner);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.


it('should create crowdsale with correct parameters', async function () {
this.crowdsale.should.exist;
this.token.should.exist;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two lines are redundant... We can assume the contract constructors to return an instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

@come-maiz
Copy link
Contributor Author

Thanks @frangio! This is ready for another review.

@come-maiz
Copy link
Contributor Author

I forgot to say that any suggestions about the style of the contracts and tests would be appreciated. I'm currently just copying stuff I saw somewhere else.

{ from: owner }
).should.be.fulfilled;
(await this.token.balanceOf(investor1))
.should.be.bignumber.equal(investmentAmount);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're using chai-as-promised you should be able to write

await this.token.balanceOf(investor1).should.eventually.be.bignumber.equal(investmentAmount)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that reads better? It's a lot longer than adding two parentheses.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably doesn't read better. No strong feelings about this.

@come-maiz
Copy link
Contributor Author

Alright, merging. Thanks @frangio!

@come-maiz come-maiz merged commit 4f92304 into TPL-protocol:master Apr 18, 2018
@come-maiz come-maiz deleted the feature/crowdsale branch April 18, 2018 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants