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 testing for client events #5686

Merged
merged 24 commits into from
Jan 25, 2024
Merged

Add testing for client events #5686

merged 24 commits into from
Jan 25, 2024

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Jan 23, 2024

Description

Merge after #5682

Ref #2823

I had to do some refactoring of the AssertEvents function. The changes ensure that it is possible to pass either res.Events or ctx.EventManager().Events().ToABCIEvents() as expected events.

I opted to add some event testing into existing tests as they have quite an elaborate set up, and it decided it would be cleaner to just add additional assertions into those tests.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Awesome! 😎

Thanks for picking these events tests up! Much appreciated

rebased to see if CI would all go green! 🍏

// containsAttribute returns true if the given key/value pair is contained in the given attributes.
// NOTE: this ignores the indexed field, which can be set or unset depending on how the events are retrieved.
func containsAttribute(attrs []abci.EventAttribute, key, value string) bool {
for _, attr := range attrs {
Copy link
Contributor

Choose a reason for hiding this comment

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

a slices.ContainsFn() can be used on these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice suggestion we can use

	return slices.ContainsFunc(attrs, func(attr abci.EventAttribute) bool {
		return attr.Key == key && attr.Value == value
	})

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Nice, thanks for picking these up!

suite.SetupTest()
path := ibctesting.NewPath(suite.chainA, suite.chainB)

path.EndpointA.Counterparty.Chain.NextBlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

this line might not be necessary anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like the test fails without this.

@chatton chatton enabled auto-merge (squash) January 25, 2024 10:12
@chatton chatton merged commit f49fd45 into main Jan 25, 2024
71 of 73 checks passed
@chatton chatton deleted the cian/issue#2823-client-events branch January 25, 2024 10:19
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