Skip to content

Commit

Permalink
Add invalid regex test for 100% coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
  • Loading branch information
matthew1001 committed Aug 15, 2023
1 parent e8aff93 commit 5c42f98
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions internal/ethereum/ethereum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions internal/msgs/en_error_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

0 comments on commit 5c42f98

Please sign in to comment.