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

Minor refactor: factor out Begin(End)Block calls from simibc #588

Merged
merged 5 commits into from
Jan 4, 2023

Conversation

danwt
Copy link
Contributor

@danwt danwt commented Dec 13, 2022

Description

This is a pure refactors that extracts BeginBlock and EndBlock methods from simibc to make them useable in other contexts

Type of change

Please delete options that are not relevant.

  • Non-breaking changes

How was the feature tested?

  • Custom difference tests

Checklist:

Please delete options that are not relevant.

  • Tests are passing (make test)

@danwt danwt changed the title Factors out BeginBlock, EndBlock calls Minor refactor: factor out Begin(End)Block calls from simibc Dec 13, 2022
Copy link
Contributor

@shaspitz shaspitz left a comment

Choose a reason for hiding this comment

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

LGTM, for my understanding could you give an example where executing logic/assertions after EndBlock but before committing the block is useful?

@danwt
Copy link
Contributor Author

danwt commented Dec 14, 2022

executing logic/assertions after

Yes, if you write a test and what to check the state that was actually going into the blockchain, this is exactly the committed state. But to write the test you probably want to use ctx as argument in query methods to read the data, to compare to what you expect. You have to do this after EndBlock, if there is business logic in EndBlock that you want to check, and before BeginBlock, because any business logic in BeginBlock my mess up your test. If you test in between EndBlock and BeginBlock, you need a ctx, and the ctx is not available after committing.

This is used in the difftests matchState() function.

@mpoke mpoke requested a review from MSalopek December 16, 2022 10:35
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

func BeginBlock(c *ibctesting.TestChain, dt time.Duration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment explaining what the function does, especially the dt param.


c.LastHeader = c.CurrentTMClientHeader()

// Store header to be used in UpdateClient
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this comment removed?

}

// Commit packets emmitted up to this point
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@danwt danwt merged commit daece1c into main Jan 4, 2023
@danwt danwt deleted the danwt/simibc-util-lift-methods branch January 4, 2023 13:54
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.

3 participants