-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37c2c98
commit 470d6ba
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package loop | ||
|
||
import ( | ||
"fmt" | ||
|
||
"google.golang.org/grpc" | ||
|
||
"github.com/smartcontractkit/chainlink-relay/pkg/loop/internal" | ||
"github.com/smartcontractkit/chainlink-relay/pkg/types" | ||
) | ||
|
||
// 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 | ||
func RegisterStandAloneProvider(s *grpc.Server, p types.PluginProvider, pType types.OCR2PluginType) error { | ||
switch pType { | ||
case types.Median: | ||
mp, ok := p.(types.MedianProvider) | ||
if !ok { | ||
return fmt.Errorf("expected median provider got %T", p) | ||
} | ||
internal.RegisterStandAloneMedianProvider(s, mp) | ||
return nil | ||
default: | ||
return fmt.Errorf("stand alone provider only supports median, got %q", pType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package loop_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"google.golang.org/grpc" | ||
|
||
"github.com/smartcontractkit/chainlink-relay/pkg/loop" | ||
"github.com/smartcontractkit/chainlink-relay/pkg/loop/internal/test" | ||
) | ||
|
||
func TestRegisterStandAloneProvider(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") | ||
|
||
err = loop.RegisterStandAloneProvider(s, p, "median") | ||
require.ErrorContains(t, err, "expected median provider got") | ||
|
||
stopCh := newStopCh(t) | ||
pr := newPluginRelayerExec(t, stopCh) | ||
mp := newMedianProvider(t, pr) | ||
err = loop.RegisterStandAloneProvider(s, mp, "median") | ||
require.NoError(t, err) | ||
} |