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

[Feature]: module level testing #17555

Closed
tac0turtle opened this issue Aug 27, 2023 · 5 comments
Closed

[Feature]: module level testing #17555

tac0turtle opened this issue Aug 27, 2023 · 5 comments

Comments

@tac0turtle
Copy link
Member

tac0turtle commented Aug 27, 2023

Summary

Currently modules rely on consensus level steps (finalizeblock) to begin a new block in testing. This is a legacy design as a module should only worry about the steps of a state machine and how they are called when a consensus engine would give the application a block to execute.

Currently the sdk has a begin, end block and execute txs. This issue proposes we make finalize block and the steps of consensus private to baseapp and only expose logic that is needed for a module to execute (i.e. beginblock, devliertx and endblock). this would be a partial revert of the migration to finalize block that was done as part of 0.50.

Problem Definition

Modules deal with consensus level steps that group application steps together, which could make testing and debugging harder.

Proposed Feature

Explore exposing begin and endblock to modules for testing while making the steps of abci private to baseapp.

ref #17425

@facundomedica
Copy link
Member

I've explored exposing begin and endblock to modules but at the moment there's some setup for the state and context happening in FinalizeBlock that is required. Also, all of these functions are currently using app.finalizeBlockState.ctx regardless of the context passed

@robert-zaremba
Copy link
Collaborator

Is this blocking v0.50 release?

@Olshansk
Copy link

@tac0turtle Is there a recommended way to testing business logic in EndBlock / BeginBlock handlers? Not looking for an explanation but just a link/pointer (if one exists) that you'd point to as a good reference to follow or learn from.

@tac0turtle
Copy link
Member Author

this is more or less completed now. We have moved away from calling begin endblock from comet as it is no longer a comet level design. Since this is the case we can close this as all the types for begin/endblock have been moved to cosmossdk.io/core

@github-project-automation github-project-automation bot moved this from 📋 Backlog to 🥳 Done in Cosmos-SDK Jul 29, 2024
@Olshansk
Copy link

Noted @tac0turtle. Posting here for posterity and as a reference to others.

I actually ended up doing a workshop at Modular Summit about our local development environment: https://www.youtube.com/watch?v=mDldfwaGtOI&t=1609s.

With respect to integration testing specifically. A search for NewCompleteIntegrationApp links to what our approach ended up being (see screenshot below).

The way we define (since it's nuanced and opinionated on a per-team per-project basis) Integration Testing is:

  1. No Mocks (easier to maintain and real)
  2. Not a simulation
  3. Not true E2E (doesn't require infrastructure or service management)
  4. Tests more than just unit tests
  5. Validates lifecycle-based logic (e.g. across blocks)

Screenshot 2024-07-29 at 8 09 01 PM

@tac0turtle tac0turtle removed this from Cosmos-SDK Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants