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

Commit plugin e2e tests using OCR3Runner #82

Merged
merged 18 commits into from
Aug 29, 2024
Merged

Conversation

dimkouv
Copy link
Contributor

@dimkouv dimkouv commented Aug 27, 2024

OCR3Runner commit plugin e2e unit tests.


Plugin still has lot's of tests missing, with this PR we achieve +20% coverage in our codebase and few bugs were already found and fixed. I don't want to make this PR huge, will add more tests in separate ones. Thank you.

commit/plugin_e2e_test.go Outdated Show resolved Hide resolved
commit/plugin_e2e_test.go Outdated Show resolved Hide resolved
@@ -106,6 +106,8 @@ func (o ObserverImpl) ObserveOffRampNextSeqNums(ctx context.Context) []plugintyp
o.lggr.Warnw("call to KnownSourceChainsSlice failed", "err", err)
return nil
}

sort.Slice(sourceChains, func(i, j int) bool { return sourceChains[i] < sourceChains[j] })
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this sort necessary here? I thought in the aggregation step we would handle different orders somehow

Copy link
Contributor Author

@dimkouv dimkouv Aug 27, 2024

Choose a reason for hiding this comment

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

Makes testing much easier, because we can verify what's passed in the call in a certain order and match specific cases with return data

commit/plugin_e2e_test.go Outdated Show resolved Hide resolved
commit/plugin_e2e_test.go Outdated Show resolved Hide resolved
commit/plugin_e2e_test.go Outdated Show resolved Hide resolved
nodeIDs := []commontypes.OracleID{1, 2, 3}
peerIDs := []libocrtypes.PeerID{{1}, {2}, {3}}

oracleIDToP2pID := make(map[commontypes.OracleID]libocrtypes.PeerID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe we can move this and chainConfig definitions to a setup func that returns all of this data in a struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made many changes to the test since u reviewed, lmk if you still have the same suggestion

@dimkouv dimkouv marked this pull request as ready for review August 28, 2024 12:57
@dimkouv dimkouv requested a review from a team as a code owner August 28, 2024 12:57
Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

Looks great.

Comment on lines 37 to 38
require.Len(t, mapset.NewSet(destChain, sourceChain1, sourceChain2).ToSlice(), 3)
require.Less(t, sourceChain1, sourceChain2, "test below expected source chain1 to be LT chain2")
Copy link
Contributor

Choose a reason for hiding this comment

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

These seem unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have it just in case someone updates the test


func TestPlugin_E2E_AllNodesAgree(t *testing.T) {
require.Len(t, mapset.NewSet(destChain, sourceChain1, sourceChain2).ToSlice(), 3)
require.Less(t, sourceChain1, sourceChain2, "test below expected source chain1 to be LT chain2")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this here because the arrays / etc. will be sorted a certain way by the plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, and that's how this test has been set up

)

func TestPlugin_E2E_AllNodesAgree(t *testing.T) {
require.Len(t, mapset.NewSet(destChain, sourceChain1, sourceChain2).ToSlice(), 3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check seems kind of weird, maybe we can pull out mapset.NewSet(destChain, sourceChain1, sourceChain2).ToSlice() into a var and then here we do a require.Len(t, chains, 3) if the goal is to make sure we don't add chains to the test?

@dimkouv
Copy link
Contributor Author

dimkouv commented Aug 29, 2024

I removed both of this test setup validations, since they seem confusing. Test will just fail in case someone edits the test setup, but shouldn't be hard to figure out why.

Copy link

Test Coverage

Branch Coverage
dk/commit-e2e-test 72.0%
ccip-develop 51.3%

@dimkouv dimkouv merged commit 338ad4e into ccip-develop Aug 29, 2024
3 checks passed
@mateusz-sekara mateusz-sekara deleted the dk/commit-e2e-test branch November 8, 2024 09:24
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