Skip to content

Commit

Permalink
fix: lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
parketh committed Aug 6, 2024
1 parent 04a6c73 commit cfad1d3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions db/bbolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (bb *BBoltHandler) GetLatestBlock() (*types.Block, error) {

func (bb *BBoltHandler) DeleteDB() error {
absPath, err := filepath.Abs(bb.db.Path())
bb.logger.Info("Deleting DB", zap.String("path", absPath))
if err != nil {
bb.logger.Error("Error getting db absolute path", zap.Error(err))
return fmt.Errorf("failed to get db absolute path: %w", err)
Expand Down
5 changes: 4 additions & 1 deletion db/bbolt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ func setupDB(t *testing.T) (*BBoltHandler, func()) {

// Cleanup function to close DB and remove temp file
cleanup := func() {
err := db.DeleteDB()
if err != nil {
t.Fatalf("Failed to delete DB: %v", err)
}
db.Close()
db.DeleteDB()
}

return db, cleanup
Expand Down
7 changes: 3 additions & 4 deletions finalitygadget/finalitygadget.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ type FinalityGadget struct {
cwClient cwclient.ICosmWasmClient
l2Client ethl2client.IEthL2Client

db db.IDatabaseHandler
mutex sync.Mutex
db db.IDatabaseHandler
logger *zap.Logger
mutex sync.Mutex

pollInterval time.Duration
currHeight uint64

logger *zap.Logger
}

//////////////////////////////
Expand Down
8 changes: 2 additions & 6 deletions finalitygadget/finalitygadget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,16 +428,12 @@ func TestGetBlockByHashForNonExistentBlock(t *testing.T) {
}

func TestGetBlockStatusByHeight(t *testing.T) {
block := &types.Block{
BlockHeight: 1,
BlockHash: "0x123",
BlockTimestamp: 1000,
}
blockHeight := uint64(1)

// mock db and finality gadget
ctl := gomock.NewController(t)
mockDbHandler := mocks.NewMockIDatabaseHandler(ctl)
mockDbHandler.EXPECT().GetBlockStatusByHeight(block.BlockHeight).Return(true, nil).Times(1)
mockDbHandler.EXPECT().GetBlockStatusByHeight(blockHeight).Return(true, nil).Times(1)

mockFinalityGadget := &FinalityGadget{
db: mockDbHandler,
Expand Down

0 comments on commit cfad1d3

Please sign in to comment.