Skip to content

Commit

Permalink
add clock to servicewrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidOrchard committed Sep 10, 2024
1 parent c3f5616 commit 558f577
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core/capabilities/gateway_connector/service_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ServiceWrapper struct {
keystore keystore.Eth
connector connector.GatewayConnector
lggr logger.Logger
clock clockwork.Clock
}

type connectorSigner struct {
Expand Down Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion core/capabilities/gateway_connector/service_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 558f577

Please sign in to comment.