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

Create tests for Shareable #100

Merged
merged 3 commits into from
Dec 20, 2016
Merged

Conversation

adklempner
Copy link
Contributor

No description provided.


function isOwnerConst(address _addr) constant returns (bool) {
return isOwner(_addr);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you need to add this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling isOwner() in web3js does not return the function's return value because it's not const. Instead, it returns the transaction hash. Adding the isOwnerConst() function to the mock contract allows me to get around that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't isOwner be constant too? Yes, just checked and it makes no state changes.
Can you make that change before we merge? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

What I mean is, make isOwner constant, remove isOwnerConst from ShareableMock, and use isOwner directly in tests. In the future, feel free to change the base contracts when you're writing tests if you find this problems.
We want the code to be as simple/correct as possible.

let hash = 1234;

let initCount = await shareable.count();
initCount = initCount.toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a string here seems confusing. What's the reason?

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 double checked and it doesn't make a difference. all the toString()'s in this test method can be removed.

let hash = 1234;

let initCount = await shareable.count();
initCount = initCount.toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

same 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.

Same as above

@maraoz
Copy link
Contributor

maraoz commented Dec 20, 2016

Added a comment, and please re-check tests that seem to be failing

@adklempner
Copy link
Contributor Author

Looks like some of those toString() calls are necessary. Comparing the objects is what's causing the tests to fail: AssertionError: expected { Object (s, e, ...) } to equal { Object (s, e, ...) }

@maraoz
Copy link
Contributor

maraoz commented Dec 20, 2016

LGTM

@maraoz maraoz merged commit bb22cd6 into OpenZeppelin:master Dec 20, 2016
ProphetDaniel pushed a commit to classicdelta/Smart-Contracts that referenced this pull request Mar 9, 2018
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