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

Remove global state from evm helpers #1684

Merged
merged 2 commits into from
Sep 17, 2019

Conversation

typescribe
Copy link
Contributor

No description provided.

As part of the effort of making helpers.ts usable by consumers, the file
helpers.ts has had its functions and variables for initializing accounts
+ roles + personas refactored so that they are no longer globally
exposed. Instead, each test that needs personas and roles call
initializeRolesAndPersonas() to create their own copy of the variables
to use. This removes the dependence on global state that might not be
intialized properly either through user error or the require.cache being
cleared.
@typescribe typescribe mentioned this pull request Sep 17, 2019
@typescribe typescribe changed the base branch from chore/cleanup_evm to develop September 17, 2019 21:37
@@ -4,14 +4,22 @@ import { assertBigNum } from '../src/matchers'
const BasicConsumer = artifacts.require('BasicConsumer.sol')
const Oracle = artifacts.require('Oracle.sol')

let roles

before(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we cut down this boiler plate and call h.initializeRolesAndPersonas() in the module, and then export roles, personas...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its asynchronous initialisation so you can't synchronously call it, hence the before hook

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't want to use that hook within helpers.ts since that now introduces side-effects on import. it also assumes the importer is using mocha for their test framework, which may not be the case for external module consumers

@typescribe typescribe merged commit 2ac7357 into develop Sep 17, 2019
@se3000 se3000 deleted the chore/remove_global_state_from_evm_helpers branch September 20, 2019 16:40
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.

None yet

2 participants