diff --git a/.golangci.yml b/.golangci.yml index 2891a8ba..c8eb5527 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,14 +9,29 @@ run: linters: enable: - - whitespace - - gosec + - whitespace # Tool for detection of leading and trailing whitespace + - gosec # Security problems - gci - - misspell + - misspell # Misspelled English words in comments - gomnd - - gofmt - - goimports + - gofmt # Whether the code was gofmt-ed + - goimports # Unused imports - revive + - wastedassign # Finds wasted assignment statements + - unconvert # Unnecessary type conversions + - prealloc # Finds slice declarations that could potentially be pre-allocated + - predeclared # Finds code that shadows one of Go's predeclared identifiers + - nolintlint # Ill-formed or insufficient nolint directives + - makezero # Finds slice declarations with non-zero initial length + - importas # Enforces consistent import aliases + - dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f()) + - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error + - goconst # Repeated strings that could be replaced by a constant + - forcetypeassert # Finds forced type assertions + - tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes + - thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers + - errcheck # Errcheck is a go lint rule for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases + - lll # Long lines linters-settings: revive: @@ -24,8 +39,16 @@ linters-settings: - name: exported arguments: - disableStutteringCheck + goconst: + min-len: 4 + min-occurrences: 3 issues: + exclude-rules: + - path: _test\.go + linters: + - gosec + - lll include: - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments diff --git a/client/client_test.go b/client/client_test.go index 2abf5735..1e5b0c16 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -17,6 +17,8 @@ import ( ) func TestClient_GetStatus(t *testing.T) { + t.Parallel() + tests := []struct { name string result string @@ -80,6 +82,8 @@ func TestClient_GetStatus(t *testing.T) { } func TestClient_SignSequence(t *testing.T) { + t.Parallel() + tests := []struct { name string ss types.SignedSequence @@ -163,6 +167,8 @@ func TestClient_SignSequence(t *testing.T) { } func TestClient_GetOffChainData(t *testing.T) { + t.Parallel() + tests := []struct { name string hash common.Hash @@ -234,6 +240,8 @@ func TestClient_GetOffChainData(t *testing.T) { } func TestClient_ListOffChainData(t *testing.T) { + t.Parallel() + tests := []struct { name string hashes []common.Hash diff --git a/config/config.go b/config/config.go index 5835e357..3fce8ad2 100644 --- a/config/config.go +++ b/config/config.go @@ -75,7 +75,12 @@ func Load(ctx *cli.Context) (*Config, error) { decodeHooks := []viper.DecoderConfigOption{ // this allows arrays to be decoded from env var separated by ",", example: MY_VAR="value1,value2,value3" - viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(mapstructure.TextUnmarshallerHookFunc(), mapstructure.StringToSliceHookFunc(","))), + viper.DecodeHook( + mapstructure.ComposeDecodeHookFunc( + mapstructure.TextUnmarshallerHookFunc(), + mapstructure.StringToSliceHookFunc(","), + ), + ), } err = viper.Unmarshal(&cfg, decodeHooks...) return cfg, err diff --git a/db/db_test.go b/db/db_test.go index f2ac5eca..413cdbf5 100644 --- a/db/db_test.go +++ b/db/db_test.go @@ -14,6 +14,8 @@ import ( ) func Test_DB_StoreLastProcessedBlock(t *testing.T) { + t.Parallel() + testTable := []struct { name string task string @@ -69,6 +71,8 @@ func Test_DB_StoreLastProcessedBlock(t *testing.T) { } func Test_DB_GetLastProcessedBlock(t *testing.T) { + t.Parallel() + testTable := []struct { name string task string @@ -133,6 +137,8 @@ func Test_DB_GetLastProcessedBlock(t *testing.T) { } func Test_DB_StoreUnresolvedBatchKeys(t *testing.T) { + t.Parallel() + testTable := []struct { name string bk []types.BatchKey @@ -212,6 +218,8 @@ func Test_DB_StoreUnresolvedBatchKeys(t *testing.T) { } func Test_DB_GetUnresolvedBatchKeys(t *testing.T) { + t.Parallel() + testTable := []struct { name string bks []types.BatchKey @@ -277,6 +285,8 @@ func Test_DB_GetUnresolvedBatchKeys(t *testing.T) { } func Test_DB_DeleteUnresolvedBatchKeys(t *testing.T) { + t.Parallel() + testTable := []struct { name string bks []types.BatchKey @@ -343,6 +353,8 @@ func Test_DB_DeleteUnresolvedBatchKeys(t *testing.T) { } func Test_DB_StoreOffChainData(t *testing.T) { + t.Parallel() + testTable := []struct { name string od []types.OffChainData @@ -422,6 +434,8 @@ func Test_DB_StoreOffChainData(t *testing.T) { } func Test_DB_GetOffChainData(t *testing.T) { + t.Parallel() + testTable := []struct { name string od []types.OffChainData @@ -505,6 +519,8 @@ func Test_DB_GetOffChainData(t *testing.T) { } func Test_DB_ListOffChainData(t *testing.T) { + t.Parallel() + testTable := []struct { name string od []types.OffChainData @@ -638,6 +654,8 @@ func Test_DB_ListOffChainData(t *testing.T) { } func Test_DB_CountOffchainData(t *testing.T) { + t.Parallel() + testTable := []struct { name string od []types.OffChainData diff --git a/log/config.go b/log/config.go index f30be52b..763999ad 100644 --- a/log/config.go +++ b/log/config.go @@ -3,11 +3,13 @@ package log // Config for log type Config struct { // Environment defining the log format ("production" or "development"). - // In development mode enables development mode (which makes DPanicLevel logs panic), uses a console encoder, writes to standard error, and disables sampling. Stacktraces are automatically included on logs of WarnLevel and above. + // In development mode enables development mode (which makes DPanicLevel logs panic), + // uses a console encoder, writes to standard error, and disables sampling. + // Stacktraces are automatically included on logs of WarnLevel and above. // Check [here](https://pkg.go.dev/go.uber.org/zap@v1.24.0#NewDevelopmentConfig) Environment Environment `mapstructure:"Environment" jsonschema:"enum=production,enum=development"` // Level of log. As lower value more logs are going to be generated - Level string `mapstructure:"Level" jsonschema:"enum=debug,enum=info,enum=warn,enum=error,enum=dpanic,enum=panic,enum=fatal"` + Level string `mapstructure:"Level" jsonschema:"enum=debug,enum=info,enum=warn,enum=error,enum=dpanic,enum=panic,enum=fatal"` //nolint:lll // Outputs Outputs []string `mapstructure:"Outputs"` } diff --git a/log/log.go b/log/log.go index 0289cb6d..0b8b773f 100644 --- a/log/log.go +++ b/log/log.go @@ -91,7 +91,7 @@ func NewLogger(cfg Config) (*zap.SugaredLogger, *zap.AtomicLevel, error) { if err != nil { return nil, nil, err } - defer logger.Sync() //nolint:gosec,errcheck + defer logger.Sync() //nolint:errcheck // skip 2 callers: one for our wrapper methods and one for the package functions withOptions := logger.WithOptions(zap.AddCallerSkip(2)) //nolint:gomnd diff --git a/rpc/client_test.go b/rpc/client_test.go index fc84f00e..a08a703c 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -13,6 +13,8 @@ import ( ) func Test_JSONRPCCallWithContext(t *testing.T) { + t.Parallel() + tests := []struct { name string result string diff --git a/rpc/error.go b/rpc/error.go index a1d2d131..14c33eb2 100644 --- a/rpc/error.go +++ b/rpc/error.go @@ -25,8 +25,8 @@ const ( ) var ( - // invalidJSONReqErr denotes error that is returned when invalid JSON request is received - invalidJSONReqErr = errors.New("Invalid json request") + // errInvalidJSONReq denotes error that is returned when invalid JSON request is received + errInvalidJSONReq = errors.New("invalid json request") ) // Error interface diff --git a/rpc/handler.go b/rpc/handler.go index e95cd1b9..50ff50e8 100644 --- a/rpc/handler.go +++ b/rpc/handler.go @@ -123,7 +123,11 @@ func (h *Handler) Handle(req handleRequest) Response { // check params passed by request match function params var testStruct []interface{} if err := json.Unmarshal(req.Params, &testStruct); err == nil && len(testStruct) > fd.numParams() { - return NewResponse(req.Request, nil, NewRPCError(InvalidParamsErrorCode, fmt.Sprintf("too many arguments, want at most %d", fd.numParams()))) + return NewResponse( + req.Request, + nil, + NewRPCError(InvalidParamsErrorCode, fmt.Sprintf("too many arguments, want at most %d", fd.numParams())), + ) } inputs := make([]interface{}, fd.numParams()-inArgsOffset) @@ -161,7 +165,7 @@ func (h *Handler) HandleWs(reqBody []byte, wsConn *websocket.Conn, httpReq *http log.Debugf("WS message received: %v", string(reqBody)) var req Request if err := json.Unmarshal(reqBody, &req); err != nil { - return NewResponse(req, nil, NewRPCError(InvalidRequestErrorCode, invalidJSONReqErr.Error())).Bytes() + return NewResponse(req, nil, NewRPCError(InvalidRequestErrorCode, errInvalidJSONReq.Error())).Bytes() } handleReq := handleRequest{ @@ -254,7 +258,12 @@ func validateFunc(funcName string, fv reflect.Value, isMethod bool) (inNum int, return } if !isRPCErrorType(ft.Out(1)) { - err = fmt.Errorf("unexpected type for the second return value of the function '%s': '%s'. Expected '%s'", funcName, ft.Out(1), rpcErrType) + err = fmt.Errorf( + "unexpected type for the second return value of the function '%s': '%s'. Expected '%s'", + funcName, + ft.Out(1), + rpcErrType, + ) return } diff --git a/rpc/server.go b/rpc/server.go index 2165d182..1e206b2d 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -108,7 +108,10 @@ func (s *Server) handle(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "application/json") w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS") - w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization") + w.Header().Set( + "Access-Control-Allow-Headers", + "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization", + ) if (*req).Method == "OPTIONS" { // TODO(pg): need to count it in the metrics? @@ -156,7 +159,7 @@ func (s *Server) isSingleRequest(data []byte) (bool, Error) { x := bytes.TrimLeft(data, " \t\r\n") if len(x) == 0 { - return false, NewRPCError(InvalidRequestErrorCode, invalidJSONReqErr.Error()) + return false, NewRPCError(InvalidRequestErrorCode, errInvalidJSONReq.Error()) } return x[0] == '{', nil @@ -213,7 +216,7 @@ func (s *Server) parseRequest(data []byte) (Request, error) { var req Request if err := json.Unmarshal(data, &req); err != nil { - return Request{}, NewRPCError(InvalidRequestErrorCode, invalidJSONReqErr.Error()) + return Request{}, NewRPCError(InvalidRequestErrorCode, errInvalidJSONReq.Error()) } return req, nil @@ -223,7 +226,7 @@ func (s *Server) parseRequests(data []byte) ([]Request, error) { var requests []Request if err := json.Unmarshal(data, &requests); err != nil { - return nil, NewRPCError(InvalidRequestErrorCode, invalidJSONReqErr.Error()) + return nil, NewRPCError(InvalidRequestErrorCode, errInvalidJSONReq.Error()) } return requests, nil diff --git a/rpc/server_test.go b/rpc/server_test.go index e821293e..a711967c 100644 --- a/rpc/server_test.go +++ b/rpc/server_test.go @@ -120,7 +120,7 @@ func Test_ServerHandleRequest(t *testing.T) { server.handle(respRecorder, httpReq) require.Equal(t, http.StatusInternalServerError, respRecorder.Result().StatusCode) - require.Equal(t, invalidJSONReqErr.Error(), respRecorder.Body.String()) + require.Equal(t, errInvalidJSONReq.Error(), respRecorder.Body.String()) }) t.Run("GET method request", func(t *testing.T) { diff --git a/sequencer/call_test.go b/sequencer/call_test.go index 65c94e2e..cbd59575 100644 --- a/sequencer/call_test.go +++ b/sequencer/call_test.go @@ -16,6 +16,8 @@ import ( ) func Test_GetData(t *testing.T) { + t.Parallel() + tests := []struct { name string batchNum uint64 @@ -72,7 +74,10 @@ func Test_GetData(t *testing.T) { var params []interface{} require.NoError(t, json.Unmarshal(res.Params, ¶ms)) require.Equal(t, float64(tt.batchNum), params[0]) - require.True(t, params[1].(bool)) + + boolVal, ok := params[1].(bool) + require.True(t, ok, "params[1] is not of type bool") + require.True(t, boolVal) if tt.statusCode > 0 { w.WriteHeader(tt.statusCode) diff --git a/services/datacom/datacom.go b/services/datacom/datacom.go index a9637096..35da99c5 100644 --- a/services/datacom/datacom.go +++ b/services/datacom/datacom.go @@ -46,7 +46,8 @@ func (d *Endpoints) SignSequence(signedSequence types.SignedSequence) (interface // Store off-chain data by hash (hash(L2Data): L2Data) if err = d.db.StoreOffChainData(context.Background(), signedSequence.Sequence.OffChainData()); err != nil { - return "0x0", rpc.NewRPCError(rpc.DefaultErrorCode, fmt.Errorf("failed to store offchain data. Error: %w", err).Error()) + return "0x0", rpc.NewRPCError(rpc.DefaultErrorCode, + fmt.Errorf("failed to store offchain data. Error: %w", err).Error()) } // Sign diff --git a/services/datacom/datacom_test.go b/services/datacom/datacom_test.go index df871ad5..60e118b6 100644 --- a/services/datacom/datacom_test.go +++ b/services/datacom/datacom_test.go @@ -40,6 +40,8 @@ func TestDataCom_SignSequence(t *testing.T) { require.NoError(t, err) testFn := func(t *testing.T, cfg testConfig) { + t.Helper() + var ( signer = privateKey signedSequence *types.SignedSequence diff --git a/services/status/status_test.go b/services/status/status_test.go index 9be85ed9..d6ccbfd1 100644 --- a/services/status/status_test.go +++ b/services/status/status_test.go @@ -11,6 +11,8 @@ import ( ) func TestEndpoints_GetStatus(t *testing.T) { + t.Parallel() + tests := []struct { name string countOffchainData uint64 @@ -60,10 +62,13 @@ func TestEndpoints_GetStatus(t *testing.T) { } else { require.NoError(t, err) - require.NotEmpty(t, actual.(types.DACStatus).Uptime) - require.Equal(t, "v0.1.0", actual.(types.DACStatus).Version) - require.Equal(t, tt.countOffchainData, actual.(types.DACStatus).KeyCount) - require.Equal(t, tt.getLastProcessedBlock, actual.(types.DACStatus).BackfillProgress) + dacStatus, ok := actual.(types.DACStatus) + require.True(t, ok, "actual is not of type types.DACStatus") + + require.NotEmpty(t, dacStatus.Uptime) + require.Equal(t, "v0.1.0", dacStatus.Version) + require.Equal(t, tt.countOffchainData, dacStatus.KeyCount) + require.Equal(t, tt.getLastProcessedBlock, dacStatus.BackfillProgress) } }) } diff --git a/services/sync/sync_test.go b/services/sync/sync_test.go index 043cfeac..12ed3bfe 100644 --- a/services/sync/sync_test.go +++ b/services/sync/sync_test.go @@ -12,6 +12,8 @@ import ( ) func TestEndpoints_GetOffChainData(t *testing.T) { + t.Parallel() + tests := []struct { name string hash types.ArgHash @@ -68,6 +70,8 @@ func TestEndpoints_GetOffChainData(t *testing.T) { } func TestSyncEndpoints_ListOffChainData(t *testing.T) { + t.Parallel() + tests := []struct { name string hashes []types.ArgHash diff --git a/synchronizer/batches.go b/synchronizer/batches.go index c461c373..6c70cd50 100644 --- a/synchronizer/batches.go +++ b/synchronizer/batches.go @@ -29,7 +29,8 @@ type SequencerTracker interface { GetSequenceBatch(ctx context.Context, batchNum uint64) (*sequencer.SeqBatch, error) } -// BatchSynchronizer watches for number events, checks if they are "locally" stored, then retrieves and stores missing data +// BatchSynchronizer watches for number events, checks if they are +// "locally" stored, then retrieves and stores missing data type BatchSynchronizer struct { client etherman.Etherman stop chan struct{} @@ -217,7 +218,10 @@ func (bs *BatchSynchronizer) filterEvents(ctx context.Context) error { return setStartBlock(ctx, bs.db, end, L1SyncTask) } -func (bs *BatchSynchronizer) handleEvent(parentCtx context.Context, event *polygonvalidium.PolygonvalidiumSequenceBatches) error { +func (bs *BatchSynchronizer) handleEvent( + parentCtx context.Context, + event *polygonvalidium.PolygonvalidiumSequenceBatches, +) error { ctx, cancel := context.WithTimeout(parentCtx, bs.rpcTimeout) defer cancel() @@ -287,8 +291,8 @@ func (bs *BatchSynchronizer) handleUnresolvedBatches(ctx context.Context) error } // Resolve the unresolved data - var data []types.OffChainData - var resolved []types.BatchKey + data := make([]types.OffChainData, 0) + resolved := make([]types.BatchKey, 0) // Go over existing keys and mark them as resolved if they exist. // Update the batch number if it is zero. @@ -381,7 +385,8 @@ func (bs *BatchSynchronizer) resolve(ctx context.Context, batch types.BatchKey) return value, nil } - return nil, rpc.NewRPCError(rpc.NotFoundErrorCode, "no data found for number %d, key %v", batch.Number, batch.Hash.Hex()) + return nil, rpc.NewRPCError(rpc.NotFoundErrorCode, + "no data found for number %d, key %v", batch.Number, batch.Hash.Hex()) } // trySequencer returns L2Data from the trusted sequencer, but does not return errors, only logs warnings if not found. diff --git a/synchronizer/batches_test.go b/synchronizer/batches_test.go index 7722f997..0db85753 100644 --- a/synchronizer/batches_test.go +++ b/synchronizer/batches_test.go @@ -314,6 +314,8 @@ func TestBatchSynchronizer_HandleEvent(t *testing.T) { }) testFn := func(t *testing.T, config testConfig) { + t.Helper() + dbMock := mocks.NewDB(t) ethermanMock := mocks.NewEtherman(t) @@ -473,6 +475,8 @@ func TestBatchSynchronizer_HandleUnresolvedBatches(t *testing.T) { txHash := crypto.Keccak256Hash(batchL2Data) testFn := func(t *testing.T, config testConfig) { + t.Helper() + dbMock := mocks.NewDB(t) ethermanMock := mocks.NewEtherman(t) sequencerMock := mocks.NewSequencerTracker(t) diff --git a/synchronizer/committee_map.go b/synchronizer/committee_map.go index e5c5e9bc..28adc976 100644 --- a/synchronizer/committee_map.go +++ b/synchronizer/committee_map.go @@ -42,7 +42,7 @@ func (t *CommitteeMapSafe) Load(addr common.Address) (etherman.DataCommitteeMemb if !exists { return etherman.DataCommitteeMember{}, false } - return rawValue.(etherman.DataCommitteeMember), exists + return rawValue.(etherman.DataCommitteeMember), exists //nolint:forcetypeassert } // Delete deletes the value for a key. @@ -57,7 +57,7 @@ func (t *CommitteeMapSafe) Delete(key common.Address) { func (t *CommitteeMapSafe) AsSlice() []etherman.DataCommitteeMember { membersSlice := make([]etherman.DataCommitteeMember, 0, atomic.LoadInt32(&t.membersCount)) t.members.Range(func(_, rawMember any) bool { - membersSlice = append(membersSlice, rawMember.(etherman.DataCommitteeMember)) + membersSlice = append(membersSlice, rawMember.(etherman.DataCommitteeMember)) //nolint:forcetypeassert return true }) diff --git a/synchronizer/init.go b/synchronizer/init.go index d4fa78a6..81976dbe 100644 --- a/synchronizer/init.go +++ b/synchronizer/init.go @@ -18,7 +18,12 @@ const ( ) // InitStartBlock initializes the L1 sync task by finding the inception block for the CDKValidium contract -func InitStartBlock(parentCtx context.Context, db db.DB, em etherman.Etherman, genesisBlock uint64, validiumAddr common.Address) error { +func InitStartBlock( + parentCtx context.Context, + db db.DB, em etherman.Etherman, + genesisBlock uint64, + validiumAddr common.Address, +) error { ctx, cancel := context.WithTimeout(parentCtx, initBlockTimeout) defer cancel() diff --git a/synchronizer/init_test.go b/synchronizer/init_test.go index f3710360..dc232369 100644 --- a/synchronizer/init_test.go +++ b/synchronizer/init_test.go @@ -45,6 +45,8 @@ func Test_InitStartBlock(t *testing.T) { } testFn := func(t *testing.T, config testConfig) { + t.Helper() + dbMock := mocks.NewDB(t) emMock := mocks.NewEtherman(t) diff --git a/synchronizer/store_test.go b/synchronizer/store_test.go index f85f4c66..7a9315a3 100644 --- a/synchronizer/store_test.go +++ b/synchronizer/store_test.go @@ -25,6 +25,7 @@ func Test_getStartBlock(t *testing.T) { { name: "GetLastProcessedBlock returns error", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("GetLastProcessedBlock", mock.Anything, "L1"). @@ -38,6 +39,7 @@ func Test_getStartBlock(t *testing.T) { { name: "all good", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("GetLastProcessedBlock", mock.Anything, "L1").Return(uint64(5), nil) @@ -73,6 +75,7 @@ func Test_setStartBlock(t *testing.T) { { name: "StoreLastProcessedBlock returns error", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("StoreLastProcessedBlock", mock.Anything, uint64(2), "L1"). @@ -86,6 +89,7 @@ func Test_setStartBlock(t *testing.T) { { name: "all good", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("StoreLastProcessedBlock", mock.Anything, uint64(4), "L1"). @@ -127,6 +131,7 @@ func Test_storeUnresolvedBatchKeys(t *testing.T) { { name: "StoreUnresolvedBatchKeys returns error", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("StoreUnresolvedBatchKeys", mock.Anything, testData).Return(testError) @@ -139,6 +144,7 @@ func Test_storeUnresolvedBatchKeys(t *testing.T) { { name: "all good", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("StoreUnresolvedBatchKeys", mock.Anything, testData).Return(nil) @@ -179,6 +185,7 @@ func Test_getUnresolvedBatchKeys(t *testing.T) { { name: "GetUnresolvedBatchKeys returns error", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("GetUnresolvedBatchKeys", mock.Anything, uint(100)). @@ -191,6 +198,7 @@ func Test_getUnresolvedBatchKeys(t *testing.T) { { name: "all good", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("GetUnresolvedBatchKeys", mock.Anything, uint(100)).Return(testData, nil) @@ -231,6 +239,7 @@ func Test_deleteUnresolvedBatchKeys(t *testing.T) { { name: "DeleteUnresolvedBatchKeys returns error", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("DeleteUnresolvedBatchKeys", mock.Anything, testData). @@ -243,6 +252,7 @@ func Test_deleteUnresolvedBatchKeys(t *testing.T) { { name: "all good", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("DeleteUnresolvedBatchKeys", mock.Anything, testData). @@ -283,6 +293,7 @@ func Test_storeOffchainData(t *testing.T) { { name: "StoreOffChainData returns error", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("StoreOffChainData", mock.Anything, testData).Return(testError) @@ -295,6 +306,7 @@ func Test_storeOffchainData(t *testing.T) { { name: "all good", db: func(t *testing.T) db.DB { + t.Helper() mockDB := mocks.NewDB(t) mockDB.On("StoreOffChainData", mock.Anything, testData).Return(nil) diff --git a/synchronizer/util.go b/synchronizer/util.go index 15bac5d3..5fecd27e 100644 --- a/synchronizer/util.go +++ b/synchronizer/util.go @@ -16,10 +16,14 @@ import ( var ( // methodIDSequenceBatchesValidiumEtrog is sequenceBatchesValidium method id in Etrog fork (0x2d72c248) - methodIDSequenceBatchesValidiumEtrog = crypto.Keccak256([]byte("sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes)"))[:methodIDLen] + methodIDSequenceBatchesValidiumEtrog = crypto.Keccak256( + []byte("sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes)"), + )[:methodIDLen] // methodIDSequenceBatchesValidiumElderberry is sequenceBatchesValidium method id in Elderberry fork (0xdb5b0ed7) - methodIDSequenceBatchesValidiumElderberry = crypto.Keccak256([]byte("sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes)"))[:methodIDLen] + methodIDSequenceBatchesValidiumElderberry = crypto.Keccak256( + []byte("sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes)"), + )[:methodIDLen] ) const (