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

Created a GetFilters function for the logpoller #12621

Merged
merged 7 commits into from
Mar 29, 2024
Merged

Conversation

KuphJr
Copy link
Collaborator

@KuphJr KuphJr commented Mar 27, 2024

The GetFilters method should return a full deep copy of the underlying lp.filters mapping with no pointers whatsoever to the original mapping.

This will be used by Functions to facilitate cleaning up old filters for previous contract versions which are no longer in use.

See here for context: https://chainlink-core.slack.com/archives/C03RCTX5RU0/p1711494411843329

Copy link
Contributor

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset.

filters := th.LogPoller.GetFilters()
assert.Equal(t, 3, len(filters))
assert.True(t, filters["first Filter"].Name == "first Filter")
assert.True(t, reflect.DeepEqual(filters["first Filter"].EventSigs, filter1.EventSigs))
Copy link
Contributor

@reductionista reductionista Mar 28, 2024

Choose a reason for hiding this comment

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

You don't need to call reflect.DeepEqual here, that's already called internally by assert.Equal. For example, this should work:

Suggested change
assert.True(t, reflect.DeepEqual(filters["first Filter"].EventSigs, filter1.EventSigs))
assert.Equal(t, filter1.EventSigs, filters["first Filter"].EventSigs)

Actually, all 3 fields could be probably be compared in just one line:

assert.Equal(t, filter1, filters["first Filter"])

But we'd have to add Topic2, Topic3, & Topic4 in the original definition of filter1:

		Topic2:    evmtypes.HashArray{},
		Topic3:    evmtypes.HashArray{},
		Topic4:    evmtypes.HashArray{},

Either way is fine with me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! I just decided to use assert.Equal everywhere to remove the use of reflect. I think this should be fine.

Copy link
Contributor

@reductionista reductionista left a comment

Choose a reason for hiding this comment

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

LGTM!

@KuphJr KuphJr added this pull request to the merge queue Mar 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 28, 2024
@KuphJr KuphJr added this pull request to the merge queue Mar 29, 2024
Merged via the queue into develop with commit 9c2764a Mar 29, 2024
102 checks passed
@KuphJr KuphJr deleted the log_poller-GetFilters branch March 29, 2024 17:12
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.

2 participants