Skip to content

test(verifier): replace recordingChecker with a mockery mock - #1418

Open
tt-cll wants to merge 1 commit into
tt/composable-verifier-gatesfrom
tt/policy-checker-mockery
Open

test(verifier): replace recordingChecker with a mockery mock#1418
tt-cll wants to merge 1 commit into
tt/composable-verifier-gatesfrom
tt/policy-checker-mockery

Conversation

@tt-cll

@tt-cll tt-cll commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Description

Testing

Checklist

  • Breaking changes documented in changelog (see changelog directory)
  • Cross link related PRs (in this or other repositories)

Stack created with GitHub Stacks CLIGive Feedback 💬

@tt-cll
tt-cll requested a review from a team as a code owner September 5, 2026 19:03
Copilot AI lite review requested due to automatic review settings September 9, 2026 11:20
@tt-cll
tt-cll force-pushed the tt/policy-checker-mockery branch from cc57825 to a345386 Compare September 9, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The generated Checker mock exposes an internal request type in its public helper API and the added .mockery.yaml rationale comment is misleading about import-cycle avoidance.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the verifier policy-hook tests to use a mockery-generated Checker mock instead of a bespoke recordingChecker, and wires mockery config to generate that mock in a dedicated package.

Changes:

  • Added a mockery-generated MockChecker for policy.Checker.
  • Updated policy_hook_test.go to assert Checker.Evaluate interactions via testify/mock expectations.
  • Extended .mockery.yaml to generate the Checker mock into verifier/pkg/policy/mocks.
File summaries
File Description
verifier/pkg/policy/mocks/mock_Checker.go Adds mockery-generated mock for policy.Checker.
verifier/pkg/commit/policy_hook_test.go Replaces custom checker stub with mockery mock + interaction assertions.
.mockery.yaml Configures mockery generation for the new Checker mock output directory/package.
Review details

Files not reviewed (1)

  • verifier/pkg/policy/mocks/mock_Checker.go: Generated file
  • Files reviewed: 2/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +26 to +28
// Evaluate provides a mock function with given fields: ctx, req
func (_m *MockChecker) Evaluate(ctx context.Context, req policyapi.EvaluateRequest) (policy.Verdict, error) {
ret := _m.Called(ctx, req)
Comment thread .mockery.yaml
Comment on lines +125 to +129
# The Checker mock gets its own package rather than the flat verifier/internal/mocks, because
# both packages that would import it are in-package tests that the flat one cannot serve:
# gate_test.go is package policy, and a mocks package importing policy is a cycle for it; and
# verifier/pkg/commit reaches commit again through the flat package's cctp mock. Its own
# directory imports only policy, so neither cycle exists.
@tt-cll
tt-cll force-pushed the tt/policy-checker-mockery branch from a345386 to 3e4b699 Compare September 9, 2026 12:38
@tt-cll
tt-cll force-pushed the tt/policy-checker-mockery branch from 3e4b699 to 158ff89 Compare September 9, 2026 16:20
@tt-cll
tt-cll force-pushed the tt/policy-checker-mockery branch from 158ff89 to 36eebf2 Compare September 9, 2026 19:36
@tt-cll
tt-cll force-pushed the tt/policy-checker-mockery branch from 36eebf2 to 7eb6346 Compare September 9, 2026 23:10
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Code coverage report:

Package main tt/policy-checker-mockery Diff
github.com/smartcontractkit/chainlink-ccv/aggregator 50.84% 50.86% +0.02%
github.com/smartcontractkit/chainlink-ccv/bootstrap 72.00% 72.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/cli 58.12% 58.12% +0.00%
github.com/smartcontractkit/chainlink-ccv/cmd 35.65% 35.65% +0.00%
github.com/smartcontractkit/chainlink-ccv/common 48.17% 48.50% +0.33%
github.com/smartcontractkit/chainlink-ccv/executor 42.80% 42.80% +0.00%
github.com/smartcontractkit/chainlink-ccv/indexer 35.55% 35.54% -0.01%
github.com/smartcontractkit/chainlink-ccv/integration 60.31% 60.31% +0.00%
github.com/smartcontractkit/chainlink-ccv/internal 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/migration 78.70% 78.70% +0.00%
github.com/smartcontractkit/chainlink-ccv/pkg 100.00% 100.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/pricer 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/protocol 63.46% 63.46% +0.00%
github.com/smartcontractkit/chainlink-ccv/tools 43.61% 43.61% +0.00%
github.com/smartcontractkit/chainlink-ccv/verifier 36.40% 36.73% +0.33%
Total 50.70% 50.80% +0.10%

Files removed (from main):

  • github.com/smartcontractkit/chainlink-ccv/verifier/pkg/storagewriter/backoff.go

Files added (in tt/policy-checker-mockery):

  • github.com/smartcontractkit/chainlink-ccv/common/backoff.go
  • github.com/smartcontractkit/chainlink-ccv/verifier/pkg/vtypes/decorator.go

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