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

Add EmulatorBackend.Reset method and beforeEach / afterEach hooks #128

Merged

Conversation

m-Peter
Copy link
Contributor

@m-Peter m-Peter commented May 26, 2023

Work towards: onflow/developer-grants#148

Description

The general idea here, is to have better control at resetting the state of the blockchain, and some flexible hooks to run before/after each test case. For example:

import Test

pub let blockchain = Test.newEmulatorBlockchain()

pub fun beforeEach() {
    // Reset the state of the blockchain
    blockchain.reset()
}

// or the afterEach() can be used to reset the state
pub fun afterEach() {
    blockchain.reset()
}

This feature was first discussed about in https://github.com/orgs/onflow/discussions/1330


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@m-Peter m-Peter mentioned this pull request May 26, 2023
6 tasks
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice! 👌

@turbolent turbolent self-assigned this May 26, 2023
@SupunS SupunS merged commit 248ddf3 into onflow:master May 26, 2023
@m-Peter m-Peter deleted the add-reset-method-and-before-after-hooks branch June 5, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants