-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactor tests #595
Refactor tests #595
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking forward to this PR. Thank you!
just some small requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big deal but I added a suggestion
test/util/utils.js
Outdated
@@ -284,8 +289,134 @@ function objectToArray(input) { | |||
return result; | |||
} | |||
|
|||
async function setupTestEnvironment( | |||
contracts, | |||
{ returnClient = false, returnAccessController = false, bosonTokenAddress, forwarderAddress } = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Properties returnAccessController
and returnClient
from setupTestEnvironment
args seem unnecessary to me. Why don't you return the entire extraReturnValues by default and leave the decision of which properties to extract from extraReturnValues
directly in the test files? Since there are no "heavy" behaviors inside the ifs statements (such as promises, etc) it seems unnecessary to have these variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #593
I made three changes:
setupTestEnvironment
which deploys protocol. It can be reused across most of the tests. There are some exceptions (ConfigHandlerTest
,ProtocolDiamondTest
andProtocolInitializationHandlerTest
) where tests were written in a way that usingsetupTestEnvironment
did not make sensebeforeEach
in most of the test files was changed intobefore
block, where we take evm snapshot at the end of the deployment and then after each test callevm_revert
. This significantly improved execution time. To take snapshot and revert back to it I added two more util functions (getSnapshot
,revertToSnapshot
)split-unit-tests-into-chunks
to make more even chunks which should on average result in lower execution time.