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

[CENT-331]: Unify checkVariables and checkState #221

Merged
merged 6 commits into from
Sep 28, 2018

Conversation

mirathewhite
Copy link
Contributor

-Created checkMINTp0 that is specific for testing MINT p0 contracts.
-Created ControllerState and MintControllerState objects
-Replaced cloneState with 3rd party clone() function.

@mirathewhite mirathewhite changed the title CENT-316: [Test] Unify checkVariables and checkState [CENT-331]: Unify checkVariables and checkState Sep 26, 2018
Copy link
Contributor

@walkerq walkerq left a comment

Choose a reason for hiding this comment

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

Awesome to see these tests working!

It would be nice if we could run all the tests with just checkVariables, rather than a new method checkMINTp0 that requires different syntax for writing tests. This might be better suited for a separate PR, but here's what I'm thinking:

When we create the MintController token object, add a property to the truffle contract object, mintController.tokenType = "MintController". Then in checkVariables, the buildExpectedState and getActualState functions check the tokenType property before determining what state the token should have. If tokenType == MintController, delegate to getActualStateOfMintController and buildMintControllerExpectedState.

I left some other minor questions/comments, we don't necessarily have to address the checkVariables thing in this PR, but figured I'd bring it up.

@@ -1,5 +1,6 @@
var BigNumber = require('bignumber.js');
var Q = require('q');
var clone = require('clone');
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks unused in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleting.

}


// Gets the actual state of the mintController contract.
// Evaluates all mappings on the provided accounts.
async function getActualMintControllerState(mintController, accounts) {
return {
'minterManager': await mintController.minterManager.call()
var minterManager = await mintController.minterManager.call();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this check that the value of each account in accounts in the controllers mapping? Looks like that was the original plan based on the accounts param and the comment. Also, maybe owner should be added, since that is also part of the state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function checkMintControllerState calls checkControllerState in ControllerTestUtils.js. This lets us take advantage of inheritance: MintController is Controller. So the controllersmapping andowner` variable states are checked there.

Copy link
Contributor

@walkerq walkerq Sep 28, 2018

Choose a reason for hiding this comment

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

In that case can we remove the accounts param here?

@@ -23,9 +23,9 @@
version "0.7.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like we need to run "yarn install" again from build error

@mirathewhite
Copy link
Contributor Author

We discussed creating a special function checkMINTp0 to force all unit tests to check both the token and the mintController. I don't want to spend time making checkVariables more generic since it will go away eventually. We plan to use the same framework for testing token as we do for the new contracts.

@mirathewhite mirathewhite merged commit 7059470 into circlefin:multi-issuer Sep 28, 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