From 5c42f986734ed1ba6bcb302ef7b83f2e9c490355 Mon Sep 17 00:00:00 2001 From: Matthew Whitehead Date: Tue, 15 Aug 2023 13:21:22 +0100 Subject: [PATCH] Add invalid regex test for 100% coverage Signed-off-by: Matthew Whitehead --- internal/ethereum/ethereum.go | 2 +- internal/ethereum/ethereum_test.go | 4 ++++ internal/msgs/en_error_messages.go | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/ethereum/ethereum.go b/internal/ethereum/ethereum.go index b302ebc..2e1354a 100644 --- a/internal/ethereum/ethereum.go +++ b/internal/ethereum/ethereum.go @@ -91,7 +91,7 @@ func NewEthereumConnector(ctx context.Context, conf config.Section) (cc ffcapi.A c.catchupDownscaleRegex, err = regexp.Compile(conf.GetString(EventsCatchupDownscaleRegex)) if err != nil { - log.L(ctx).Warnf("Catchup downscale regex pattern '%s' not a valid regular expression. Catchup downscaling is disabled.", conf.GetString(EventsCatchupDownscaleRegex)) + return nil, i18n.WrapError(ctx, err, msgs.MsgInvalidRegex, c.catchupDownscaleRegex) } httpClient, err := ffresty.New(ctx, conf) diff --git a/internal/ethereum/ethereum_test.go b/internal/ethereum/ethereum_test.go index 83ba832..3a492f2 100644 --- a/internal/ethereum/ethereum_test.go +++ b/internal/ethereum/ethereum_test.go @@ -120,4 +120,8 @@ func TestConnectorInit(t *testing.T) { cc, err = NewEthereumConnector(context.Background(), conf) assert.Regexp(t, "FF23040", err) + conf.Set(TxCacheSize, "1") + conf.Set(EventsCatchupDownscaleRegex, "[") + cc, err = NewEthereumConnector(context.Background(), conf) + assert.Regexp(t, "FF23051", err) } diff --git a/internal/msgs/en_error_messages.go b/internal/msgs/en_error_messages.go index 71d9293..8df7c8a 100644 --- a/internal/msgs/en_error_messages.go +++ b/internal/msgs/en_error_messages.go @@ -66,4 +66,5 @@ var ( MsgInvalidTXHashReturned = ffe("FF23048", "Received invalid transaction hash from node len=%d") MsgUnmarshalErrorFail = ffe("FF23049", "Failed to parse error %d: %s") MsgUnmarshalABIErrorsFail = ffe("FF23050", "Failed to parse errors ABI: %s") + MsgInvalidRegex = ffe("FF23051", "Invalid regular expression for auto-backoff catchup error: %s") )