From 558f577b265dd113004ecf8cc73230efcc92caaf Mon Sep 17 00:00:00 2001 From: David Orchard Date: Tue, 10 Sep 2024 15:11:29 -0700 Subject: [PATCH] add clock to servicewrapper --- core/capabilities/gateway_connector/service_wrapper.go | 6 ++++-- core/capabilities/gateway_connector/service_wrapper_test.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/capabilities/gateway_connector/service_wrapper.go b/core/capabilities/gateway_connector/service_wrapper.go index 834828616a3..9302a52292d 100644 --- a/core/capabilities/gateway_connector/service_wrapper.go +++ b/core/capabilities/gateway_connector/service_wrapper.go @@ -27,6 +27,7 @@ type ServiceWrapper struct { keystore keystore.Eth connector connector.GatewayConnector lggr logger.Logger + clock clockwork.Clock } type connectorSigner struct { @@ -71,10 +72,11 @@ func translateConfigs(f config.GatewayConnector) connector.ConnectorConfig { } // NOTE: this wrapper is needed to make sure that our services are started after Keystore. -func NewGatewayConnectorServiceWrapper(config config.GatewayConnector, keystore keystore.Eth, lggr logger.Logger) *ServiceWrapper { +func NewGatewayConnectorServiceWrapper(config config.GatewayConnector, keystore keystore.Eth, clock clockwork.Clock, lggr logger.Logger) *ServiceWrapper { return &ServiceWrapper{ config: config, keystore: keystore, + clock: clock, lggr: lggr, } } @@ -107,7 +109,7 @@ func (e *ServiceWrapper) Start(ctx context.Context) error { return err } translated := translateConfigs(conf) - e.connector, err = connector.NewGatewayConnector(&translated, signer, clockwork.NewFakeClock(), e.lggr) + e.connector, err = connector.NewGatewayConnector(&translated, signer, e.clock, e.lggr) if err != nil { return err } diff --git a/core/capabilities/gateway_connector/service_wrapper_test.go b/core/capabilities/gateway_connector/service_wrapper_test.go index 0545ec7e68a..ecbb896a8ec 100644 --- a/core/capabilities/gateway_connector/service_wrapper_test.go +++ b/core/capabilities/gateway_connector/service_wrapper_test.go @@ -4,6 +4,7 @@ import ( "crypto/ecdsa" "testing" + "github.com/jonboulle/clockwork" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -42,7 +43,7 @@ func generateWrapper(t *testing.T, privateKey *ecdsa.PrivateKey, keystoreKey *ec ethKeystore := ksmocks.NewEth(t) ethKeystore.On("EnabledKeysForChain", mock.Anything, mock.Anything).Return([]ethkey.KeyV2{keystoreKeyV2}, nil) gc := config.Capabilities().GatewayConnector() - wrapper := NewGatewayConnectorServiceWrapper(gc, ethKeystore, logger) + wrapper := NewGatewayConnectorServiceWrapper(gc, ethKeystore, clockwork.NewFakeClock(), logger) require.NoError(t, err) return wrapper, err }