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

All tests now use account names, and dont use accounts[0] (except ERC… #1137

Merged
merged 3 commits into from
Aug 2, 2018

Conversation

nventuro
Copy link
Contributor

@nventuro nventuro commented Aug 1, 2018

Test files now use explicit account names (owner, minter, anyone, etc.), and don't use the first account. Behaviors receive all explicit actors (owner, etc.), plus an array of accounts they're free to use as they see fit. This will be included in the upcoming test style guide (#1077).

The ERC721 tests are a bit of a mess, so I didn't tackle those, I think a more thorough refactor is due.

Fixes part of #1091

@nventuro nventuro added kind:improvement tests Test suite and helpers. labels Aug 1, 2018
@nventuro nventuro added this to the v2.0 milestone Aug 1, 2018
@nventuro nventuro requested review from shrugs and frangio August 1, 2018 11:25
assert.equal(finalBalance, 0);
assert.isAbove(ownerFinalBalance, ownerStartBalance);
ownerFinalBalance.should.be.bignumber.gt(ownerStartBalance);
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 know this doesn't belong here, but the previous test (assert.isAbove) was not actually working, since bignumbers are not supported.

@nventuro
Copy link
Contributor Author

nventuro commented Aug 1, 2018

Not sure what's up with coverage: coveralls reports it dropped on HasNoTokens, though I have no idea what caused that.

Copy link
Contributor

@shrugs shrugs left a comment

Choose a reason for hiding this comment

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

LGTM based @nventuro

@shrugs
Copy link
Contributor

shrugs commented Aug 2, 2018

yeah no idea about HasNoTokens; maybe the tests are silently failing so solc-coverage never sees that path executed?

@nventuro
Copy link
Contributor Author

nventuro commented Aug 2, 2018

I think it may be an issue on their end? I tried testing locally but failed to do so, and noticed there's some strange mocks-related behavior.

Anyway, I opened an issue: if there's indeed something that we need to fix, we should do it in a separate PR.

@nventuro nventuro merged commit 4544df4 into OpenZeppelin:master Aug 2, 2018
@nventuro nventuro deleted the account-names branch August 2, 2018 19:55
This was referenced Aug 2, 2018
hasNoTokens = await HasNoTokens.new();
token = await ERC223TokenMock.new(accounts[0], 100);
hasNoTokens = await HasNoTokens.new({ from: owner });
token = await ERC223TokenMock.new(initialAccount, 100);
Copy link
Contributor

@cgewecke cgewecke Aug 2, 2018

Choose a reason for hiding this comment

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

Hi @nventuro, visiting from solidity-coverage.

Is it possible an assumption changed here? The first ERC223 constructor arg is not identical to the from address of the HasNoTokens creation as before.

The test below (for the missing coverage) just throws an error - maybe it's a different one, e.g. it's hitting a revert somewhere else in the inheritance chain?

We haven't published any changes over there for a bit and all your recent CI runs look good. . .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, I think you're right! Only InitialAccount will have balance, and the other test fails on the transfer call. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Test suite and helpers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants