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

[BCI-3989][common] - CR methods err when service unstarted #705

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

Farber98
Copy link
Contributor

@Farber98 Farber98 commented Aug 14, 2024

solana ref: BCI-3989-cr-methods-error-when-unstarted
core ref: BCI-3989-cr-methods-error-when-unstarted

Task Description:

We only want GetLatestValue, BatchGetLatestValue and QueryKey to be called when CR service is in Started state. If CR is not started yet, we should return an error.

This PR:

Ticket:

Unblocks:

Merging flow:

  1. merge common (point to solana and core for CI to pass)
  2. Then merge Solana by pointing to merged common
  3. Finally merge core after changing Solana and common refs

Comment on lines 302 to 303
require.NoError(t, it.impl.Start(context.Background()))
t.Cleanup(func() { require.NoError(t, it.impl.Close()) })
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use servicetest.Run. Notice it uses assert during cleanup.

…rted"

This reverts commit 54d7016, reversing
changes made to 4e67d8d.
@@ -15,8 +15,28 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
)

type ChainComponentsInterfaceTester[T TestingT[T]] interface {
type ChainComponentsTester[T any] interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • defined ChainComponentsTester so we use the Setup(t T, startCR bool) only for chainComponents tests
  • defined chainComponentsTestcase so we use the startCR testcase flag only for chainComponents testcases
  • defined runChainComponentsTests to execute chainComponents specific tests using the ChainComponentsTester interface with Setup(t T, startCR bool)

@@ -19,8 +19,27 @@ type EncodeRequest struct {
TestOn string
}

type codecTestcase[T any] 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.

  • defined CodecTester so we use the Setup(t T) without the startCR flag for the codec
  • defined codecTestcase so we don't use the startCR testcase flag for codec testcases
  • defined runCodecTests to execute codec specific tests using the CodecTester interface with Setup(t T)

fake, ok := it.impl.(*fakeContractReader)
if ok {
fake.vals = []valConfidencePair{}
fake.triggers = []eventConfidencePair{}
fake.stored = []TestStruct{}

if startCR {
servicetest.Run(t, it.impl)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added servicetest.Run(t, it.impl)

Copy link
Contributor

@ilija42 ilija42 left a comment

Choose a reason for hiding this comment

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

Wdyt about this solution

#777
smartcontractkit/chainlink#14480

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.

4 participants