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

[Test] Test.Blockchain struct reuses one single backend implementation #139

Closed
m-Peter opened this issue Jun 7, 2023 · 0 comments · Fixed by onflow/cadence#2744
Closed
Labels
Bug The issue represents a bug, malfunction, regression Improvement Technical work without new features, refactoring, improving tests

Comments

@m-Peter
Copy link
Contributor

m-Peter commented Jun 7, 2023

Problem

Currently, when the Test.newEmulatorBlockchain() is called, it returns a new Test.Blockchain struct. However, the underlying backend implementation is the same for all Test.Blockchain structs that are created in a single test file. This is due to the fact that the ContractValueHandler injects only once the backend implementation, when it first encounters the Test contract in a test file.

Steps to Reproduce

import Test

pub let blockchain = Test.newEmulatorBlockchain()
pub let account = blockchain.createAccount()

pub fun testEventRetrieval() {
    let evts = blockchain.events()
    Test.assert(evts.length == 19)
    
    let blockchain2 = Test.newEmulatorBlockchain()
    Test.assert(blockchain2.events().length == 19)
}

Acceptance Criteria

Either returns a newly-created backend implementation for every call of Test.newEmulatorBlockchain(), or maybe move towards making the Test.Blockchain a singleton. Creating many backend implementations should add some overhead when running tests, and right now, it is possible to call Reset() on a Test.Blockchain value. See discussion in #138.

Context

onflow/developer-grants#148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug The issue represents a bug, malfunction, regression Improvement Technical work without new features, refactoring, improving tests
Projects
None yet
2 participants