diff --git a/pkg/loop/internal/relayer.go b/pkg/loop/internal/relayer.go index 60c775e63..e865cd05b 100644 --- a/pkg/loop/internal/relayer.go +++ b/pkg/loop/internal/relayer.go @@ -511,3 +511,14 @@ func RegisterStandAloneMedianProvider(s *grpc.Server, p types.MedianProvider) { pb.RegisterMedianContractServer(s, &medianContractServer{impl: p.MedianContract()}) pb.RegisterOnchainConfigCodecServer(s, &onchainConfigCodecServer{impl: p.OnchainConfigCodec()}) } + +// RegisterStandAlonePluginProvider register the servers needed for a generic plugin provider, +// this is a workaround to test the Node API on EVM until the EVM relayer is loopifyed +func RegisterStandAlonePluginProvider(s *grpc.Server, p types.PluginProvider) { + pb.RegisterServiceServer(s, &ServiceServer{Srv: p}) + pb.RegisterOffchainConfigDigesterServer(s, &offchainConfigDigesterServer{impl: p.OffchainConfigDigester()}) + pb.RegisterContractConfigTrackerServer(s, &contractConfigTrackerServer{impl: p.ContractConfigTracker()}) + pb.RegisterContractTransmitterServer(s, &contractTransmitterServer{impl: p.ContractTransmitter()}) + pb.RegisterChainReaderServer(s, &chainReaderServer{impl: p.ChainReader()}) + pb.RegisterCodecServer(s, &codecServer{impl: p.Codec()}) +} diff --git a/pkg/loop/plugin_median_test.go b/pkg/loop/plugin_median_test.go index 14e3aa8a1..5e11cc602 100644 --- a/pkg/loop/plugin_median_test.go +++ b/pkg/loop/plugin_median_test.go @@ -75,3 +75,16 @@ func newMedianProvider(t *testing.T, pr loop.PluginRelayer) types.MedianProvider servicetest.Run(t, mp) return mp } + +func newGenericPluginProvider(t *testing.T, pr loop.PluginRelayer) types.PluginProvider { + ctx := context.Background() + r, err := pr.NewRelayer(ctx, test.ConfigTOML, test.StaticKeystore{}) + require.NoError(t, err) + servicetest.Run(t, r) + ra := test.RelayArgs + ra.ProviderType = string(types.GenericPlugin) + p, err := r.NewPluginProvider(ctx, ra, test.PluginArgs) + require.NoError(t, err) + servicetest.Run(t, p) + return p +} diff --git a/pkg/loop/standalone_provider.go b/pkg/loop/standalone_provider.go index b54f1a64b..1d96e9117 100644 --- a/pkg/loop/standalone_provider.go +++ b/pkg/loop/standalone_provider.go @@ -10,17 +10,20 @@ import ( ) // RegisterStandAloneProvider register the servers needed for a plugin provider, -// this is a workaround to test the Node API medianpoc on EVM until the EVM relayer is loopifyed +// this is a workaround to test the Node API POCs on EVM until the EVM relayer is loopifyed func RegisterStandAloneProvider(s *grpc.Server, p types.PluginProvider, pType types.OCR2PluginType) error { switch pType { case types.Median: - mp, ok := p.(types.MedianProvider) + provider, ok := p.(types.MedianProvider) if !ok { return fmt.Errorf("expected median provider got %T", p) } - internal.RegisterStandAloneMedianProvider(s, mp) + internal.RegisterStandAloneMedianProvider(s, provider) + return nil + case types.GenericPlugin: + internal.RegisterStandAlonePluginProvider(s, p) return nil default: - return fmt.Errorf("stand alone provider only supports median, got %q", pType) + return fmt.Errorf("unsupported stand alone provider: %q", pType) } } diff --git a/pkg/loop/standalone_provider_test.go b/pkg/loop/standalone_provider_test.go index 9513ec4d3..a5b7611ce 100644 --- a/pkg/loop/standalone_provider_test.go +++ b/pkg/loop/standalone_provider_test.go @@ -10,12 +10,12 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/test" ) -func TestRegisterStandAloneProvider(t *testing.T) { +func TestRegisterStandAloneProvider_Median(t *testing.T) { s := grpc.NewServer() p := test.StaticPluginProvider{} err := loop.RegisterStandAloneProvider(s, p, "some-type-we-do-not-support") - require.ErrorContains(t, err, "stand alone provider only supports median") + require.ErrorContains(t, err, "unsupported stand alone provider") err = loop.RegisterStandAloneProvider(s, p, "median") require.ErrorContains(t, err, "expected median provider got") @@ -26,3 +26,13 @@ func TestRegisterStandAloneProvider(t *testing.T) { err = loop.RegisterStandAloneProvider(s, mp, "median") require.NoError(t, err) } + +func TestRegisterStandAloneProvider_GenericPlugin(t *testing.T) { + s := grpc.NewServer() + + stopCh := newStopCh(t) + pr := newPluginRelayerExec(t, false, stopCh) + gp := newGenericPluginProvider(t, pr) + err := loop.RegisterStandAloneProvider(s, gp, "plugin") + require.NoError(t, err) +}