From 1549341aa997fdd38e807d61fe74588373633446 Mon Sep 17 00:00:00 2001 From: Ryan Tinianov Date: Thu, 16 May 2024 11:59:00 -0400 Subject: [PATCH] Use one test to run chain reader interface tests, and properly skip unimplemented events (#708) --- go.mod | 2 +- go.sum | 4 +- integration-tests/go.mod | 2 +- integration-tests/go.sum | 4 +- pkg/solana/chainreader/chain_reader_test.go | 50 +++++++++++++++------ 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index d24e3f5fb..a2d9d9405 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/pelletier/go-toml/v2 v2.1.1 github.com/prometheus/client_golang v1.17.0 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240507142850-569a909ad3b4 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10 github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052 github.com/stretchr/testify v1.9.0 go.uber.org/zap v1.26.0 diff --git a/go.sum b/go.sum index 086317ad8..a977cafcf 100644 --- a/go.sum +++ b/go.sum @@ -452,8 +452,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.1.7-0.20240507142850-569a909ad3b4 h1:6PP8T5py2K+0Vd+8LP0DlDvPKhyXXhz1i2RwKoFhKPI= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240507142850-569a909ad3b4/go.mod h1:sj0pjL+METqeYL9ibp0T8SXquymlaQsofa6bdfLgXX8= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10 h1:IwJKWZHPBJbbh4oI3BGX8VNT3c/ChNiPZ/XI4iq6c0E= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10/go.mod h1:sj0pjL+METqeYL9ibp0T8SXquymlaQsofa6bdfLgXX8= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 7f8da14b0..49e42190d 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -12,7 +12,7 @@ require ( github.com/lib/pq v1.10.9 github.com/onsi/gomega v1.30.0 github.com/rs/zerolog v1.30.0 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240514153505-0ddba5aa4d2c + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10 github.com/smartcontractkit/chainlink-solana v1.0.3-0.20240510181707-46b1311a5a83 github.com/smartcontractkit/chainlink-testing-framework v1.28.12 github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240515225456-aeb9f4d50d65 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index a6972b200..d50d05972 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1406,8 +1406,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE= github.com/smartcontractkit/chainlink-automation v1.0.3 h1:h/ijT0NiyV06VxYVgcNfsE3+8OEzT3Q0Z9au0z1BPWs= github.com/smartcontractkit/chainlink-automation v1.0.3/go.mod h1:RjboV0Qd7YP+To+OrzHGXaxUxoSONveCoAK2TQ1INLU= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240514153505-0ddba5aa4d2c h1:KiG8PAwUrdYn/AGBQ+B4p6erEUbEB+g6LJKhAaDjJ2s= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240514153505-0ddba5aa4d2c/go.mod h1:sj0pjL+METqeYL9ibp0T8SXquymlaQsofa6bdfLgXX8= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10 h1:IwJKWZHPBJbbh4oI3BGX8VNT3c/ChNiPZ/XI4iq6c0E= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240516150131-e1be553a9d10/go.mod h1:sj0pjL+METqeYL9ibp0T8SXquymlaQsofa6bdfLgXX8= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240508101745-af1ed7bc8a69 h1:Sec/GpBpUVaTEax1kSHlTvkzF/+d3w5roAQXaj5+SLA= github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240508101745-af1ed7bc8a69/go.mod h1:ZQKf+0OLzCLYIisH/OdOIQuFRI6bDuw+jPBTATyHfFM= github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo= diff --git a/pkg/solana/chainreader/chain_reader_test.go b/pkg/solana/chainreader/chain_reader_test.go index bd74ffa59..c644e8a4f 100644 --- a/pkg/solana/chainreader/chain_reader_test.go +++ b/pkg/solana/chainreader/chain_reader_test.go @@ -3,7 +3,6 @@ package chainreader_test import ( "context" "encoding/json" - "errors" "fmt" "os" "strconv" @@ -42,8 +41,9 @@ func TestSolanaChainReaderService_ReaderInterface(t *testing.T) { t.Parallel() it := &chainReaderInterfaceTester{} - RunChainReaderGetLatestValueInterfaceTests(t, it) - RunChainReaderGetLatestValueInterfaceTests(t, commontestutils.WrapChainReaderTesterForLoop(it)) + RunChainReaderInterfaceTests(t, it) + lsIt := &skipEventsChainReaderTester{ChainReaderInterfaceTester: commontestutils.WrapChainReaderTesterForLoop(it)} + RunChainReaderInterfaceTests(t, lsIt) } func TestSolanaChainReaderService_ServiceCtx(t *testing.T) { @@ -534,12 +534,10 @@ func (r *chainReaderInterfaceTester) GetChainReader(t *testing.T) types.ChainRea }) if r.reader == nil { - r.reader = &wrappedTestChainReader{ - test: t, - tester: r, - } + r.reader = &wrappedTestChainReader{tester: r} } + r.reader.test = t r.reader.service = svc r.reader.client = client @@ -561,9 +559,7 @@ func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, contractNam ) switch contractName + method { case AnyContractName + EventName: - // t.Skip won't skip the test here - // returning the expected error to satisfy the test - return types.ErrNotFound + r.test.Skip("Events are not yet supported in Solana") case AnyContractName + MethodReturningUint64: cdc := makeTestCodec(r.test, fmt.Sprintf(baseIDL, uint64BaseTypeIDL, ""), config.EncodingTypeBorsh) onChainStruct := struct { @@ -650,7 +646,8 @@ func (r *wrappedTestChainReader) GetLatestValue(ctx context.Context, contractNam // QueryKey implements the types.ChainReader interface. func (r *wrappedTestChainReader) QueryKey(ctx context.Context, contractName string, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]types.Sequence, error) { - return nil, errors.New("unimplemented") + r.test.Skip("QueryKey is not yet supported in Solana") + return nil, nil } func getAddresses(t *testing.T, tester ChainReaderInterfaceTester, a, b int) (ag_solana.PublicKey, ag_solana.PublicKey) { @@ -668,8 +665,7 @@ func (r *wrappedTestChainReader) Bind(ctx context.Context, bindings []types.Boun func (r *wrappedTestChainReader) CreateContractType(contractName, itemType string, forEncoding bool) (any, error) { if AnyContractName+EventName == contractName+itemType { - // events are not supported, so just make the tests pass - return nil, types.ErrNotFound + r.test.Skip("Events are not yet supported in Solana") } return r.service.CreateContractType(contractName, itemType, forEncoding) @@ -825,3 +821,31 @@ const ( } }` ) + +// Required to allow test skipping to be on the same goroutine +type skipEventsChainReaderTester struct{ ChainReaderInterfaceTester } + +func (s *skipEventsChainReaderTester) GetChainReader(t *testing.T) types.ChainReader { + return &skipEventsChainReader{ + ChainReader: s.ChainReaderInterfaceTester.GetChainReader(t), + t: t, + } +} + +type skipEventsChainReader struct { + types.ChainReader + t *testing.T +} + +func (s *skipEventsChainReader) GetLatestValue(ctx context.Context, contractName string, method string, params, returnVal any) error { + if contractName == AnyContractName && method == EventName { + s.t.Skip("Events are not yet supported in Solana") + } + + return s.ChainReader.GetLatestValue(ctx, contractName, method, params, returnVal) +} + +func (s *skipEventsChainReader) QueryKey(ctx context.Context, contractName string, filter query.KeyFilter, limitAndSort query.LimitAndSort, sequenceDataType any) ([]types.Sequence, error) { + s.t.Skip("QueryKey is not yet supported in Solana") + return nil, nil +}