diff --git a/go.mod b/go.mod index 2f608af84..f6f9c5516 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/hashicorp/go-plugin v1.6.2-0.20240829161738-06afb6d7ae99 github.com/pelletier/go-toml/v2 v2.2.0 github.com/prometheus/client_golang v1.17.0 - github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913191949-44d96950c886 + github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b github.com/smartcontractkit/libocr v0.0.0-20240702141926-063ceef8c42e github.com/stretchr/testify v1.9.0 go.uber.org/zap v1.27.0 diff --git a/go.sum b/go.sum index d1163d17c..dff4e51ee 100644 --- a/go.sum +++ b/go.sum @@ -435,8 +435,8 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913191949-44d96950c886 h1:69C4DkuBLomL5mO4pt82B4zjv+ruT76LZdfXiVK08lg= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913191949-44d96950c886/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b h1:7RyN8+dNTN+hjnKfgfEYdRfxqeHTnPq8ILcHn/gOe6k= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20240702141926-063ceef8c42e h1:9ypZ/8aW8Vm497i1gXHcT96oNLiu88jbg9QdX+IUE3E= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index d11f4f319..93aedeea3 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -14,7 +14,7 @@ require ( github.com/lib/pq v1.10.9 github.com/pelletier/go-toml/v2 v2.2.2 github.com/rs/zerolog v1.33.0 - github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913191949-44d96950c886 + github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b github.com/smartcontractkit/chainlink-solana v1.1.1-0.20240911182932-3c609a6ac664 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.5 github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.1 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 279329543..8f785a4eb 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1394,8 +1394,8 @@ github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8um github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM= github.com/smartcontractkit/chainlink-ccip v0.0.0-20240911145028-d346e3ace978 h1:BPuehkAQ8R112SlTitukSdKYRJMY3zkvaQS4VSTNn0Q= github.com/smartcontractkit/chainlink-ccip v0.0.0-20240911145028-d346e3ace978/go.mod h1:X1f4CKlR1RilSgzArQv5HNvMrVSt+Zloihm3REwxhdQ= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913191949-44d96950c886 h1:69C4DkuBLomL5mO4pt82B4zjv+ruT76LZdfXiVK08lg= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240913191949-44d96950c886/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b h1:7RyN8+dNTN+hjnKfgfEYdRfxqeHTnPq8ILcHn/gOe6k= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240916214706-e7280848cd7b/go.mod h1:sjiiPwd4KsYOCf68MwL86EKphdXeT66EY7j53WH5DCc= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240906125718-9f0a98d32fbc h1:tRmTlaoAt+7FakMXXgeCuRPmzzBo5jsGpeCVvcU6KMc= diff --git a/pkg/solana/chainreader/chain_reader_test.go b/pkg/solana/chainreader/chain_reader_test.go index d85ddf77c..9e54f0332 100644 --- a/pkg/solana/chainreader/chain_reader_test.go +++ b/pkg/solana/chainreader/chain_reader_test.go @@ -430,7 +430,40 @@ func (r *chainReaderInterfaceTester) Name() string { return "Solana" } -func (r *chainReaderInterfaceTester) Setup(t *testing.T) { +func (r *chainReaderInterfaceTester) Setup(t *testing.T, started bool) { + r.setContractReader(t, started) +} + +func (r *chainReaderInterfaceTester) setContractReader(t *testing.T, started bool) { + t.Cleanup(func() { + if started { + require.NoError(t, r.reader.Close()) + } + }) + + r.setContractReaderConfig(t) + + client := new(mockedRPCClient) + svc, err := chainreader.NewChainReaderService(logger.Test(t), client, r.conf) + if err != nil { + t.Logf("contract reader service was not able to start: %s", err.Error()) + t.FailNow() + } + + if started { + require.NoError(t, svc.Start(tests.Context(t))) + } + + if r.reader == nil { + r.reader = &wrappedTestChainReader{tester: r} + } + + r.reader.test = t + r.reader.service = svc + r.reader.client = client +} + +func (r *chainReaderInterfaceTester) setContractReaderConfig(t *testing.T) { r.address = make([]string, 7) for idx := range r.address { r.address[idx] = ag_solana.NewWallet().PublicKey().String() @@ -527,26 +560,6 @@ func (r *chainReaderInterfaceTester) Setup(t *testing.T) { } func (r *chainReaderInterfaceTester) GetContractReader(t *testing.T) types.ContractReader { - client := new(mockedRPCClient) - svc, err := chainreader.NewChainReaderService(logger.Test(t), client, r.conf) - if err != nil { - t.Logf("chain reader service was not able to start: %s", err.Error()) - t.FailNow() - } - - require.NoError(t, svc.Start(context.Background())) - t.Cleanup(func() { - require.NoError(t, svc.Close()) - }) - - if r.reader == nil { - r.reader = &wrappedTestChainReader{tester: r} - } - - r.reader.test = t - r.reader.service = svc - r.reader.client = client - return r.reader } @@ -590,6 +603,12 @@ func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, readIdentif a ag_solana.PublicKey b ag_solana.PublicKey ) + + // If you called the method and the service is not started + if err := r.service.Ready(); err != nil { + return fmt.Errorf("service not ready. err: %w", err) + } + parts := strings.Split(readIdentifier, "-") if len(parts) < 3 { panic("unexpected readIdentifier length")