From 980375b0ecb9270f6122614ba8f2166b65bb8c2d Mon Sep 17 00:00:00 2001 From: Urvi Date: Mon, 30 Oct 2023 20:21:55 -0700 Subject: [PATCH] Fix linter errors --- .../actions/claimable_balance_test.go | 8 ++++++-- .../claimable_balance_batch_insert_builder.go | 5 ++--- ...e_balance_claimant_batch_insert_builder.go | 5 ++--- .../db2/history/claimable_balances_test.go | 20 ++++++++++++++----- ..._claimable_balance_batch_insert_builder.go | 5 ++--- ...e_balance_claimant_batch_insert_builder.go | 5 ++--- .../horizon/internal/ingest/verify_test.go | 8 ++++++-- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/services/horizon/internal/actions/claimable_balance_test.go b/services/horizon/internal/actions/claimable_balance_test.go index 7d2f783491..d26fc9e051 100644 --- a/services/horizon/internal/actions/claimable_balance_test.go +++ b/services/horizon/internal/actions/claimable_balance_test.go @@ -22,7 +22,9 @@ func TestGetClaimableBalanceByID(t *testing.T) { q := &history.Q{tt.HorizonSession()} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() accountID := "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML" asset := xdr.MustNewCreditAsset("USD", accountID) @@ -155,7 +157,9 @@ func TestGetClaimableBalances(t *testing.T) { q := &history.Q{tt.HorizonSession()} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() entriesMeta := []struct { id xdr.Hash diff --git a/services/horizon/internal/db2/history/claimable_balance_batch_insert_builder.go b/services/horizon/internal/db2/history/claimable_balance_batch_insert_builder.go index eb0c204688..93a6abd9de 100644 --- a/services/horizon/internal/db2/history/claimable_balance_batch_insert_builder.go +++ b/services/horizon/internal/db2/history/claimable_balance_batch_insert_builder.go @@ -12,7 +12,7 @@ import ( type ClaimableBalanceBatchInsertBuilder interface { Add(claimableBalance ClaimableBalance) error Exec(ctx context.Context, session db.SessionInterface) error - Reset() error + Reset() } // ClaimableBalanceBatchInsertBuilder is a simple wrapper around db.FastBatchInsertBuilder @@ -42,7 +42,6 @@ func (i *claimableBalanceBatchInsertBuilder) Exec(ctx context.Context, session d } // Reset clears out the current batch of claimable balances -func (i *claimableBalanceBatchInsertBuilder) Reset() error { +func (i *claimableBalanceBatchInsertBuilder) Reset() { i.builder.Reset() - return nil } diff --git a/services/horizon/internal/db2/history/claimable_balance_claimant_batch_insert_builder.go b/services/horizon/internal/db2/history/claimable_balance_claimant_batch_insert_builder.go index 3efb124ee6..37eaa67e35 100644 --- a/services/horizon/internal/db2/history/claimable_balance_claimant_batch_insert_builder.go +++ b/services/horizon/internal/db2/history/claimable_balance_claimant_batch_insert_builder.go @@ -12,7 +12,7 @@ import ( type ClaimableBalanceClaimantBatchInsertBuilder interface { Add(claimableBalanceClaimant ClaimableBalanceClaimant) error Exec(ctx context.Context, session db.SessionInterface) error - Reset() error + Reset() } // ClaimableBalanceClaimantBatchInsertBuilder is a simple wrapper around db.FastBatchInsertBuilder @@ -42,7 +42,6 @@ func (i *claimableBalanceClaimantBatchInsertBuilder) Exec(ctx context.Context, s } // Reset clears out the current batch of claimants -func (i *claimableBalanceClaimantBatchInsertBuilder) Reset() error { +func (i *claimableBalanceClaimantBatchInsertBuilder) Reset() { i.builder.Reset() - return nil } diff --git a/services/horizon/internal/db2/history/claimable_balances_test.go b/services/horizon/internal/db2/history/claimable_balances_test.go index 780e973621..964e806ae1 100644 --- a/services/horizon/internal/db2/history/claimable_balances_test.go +++ b/services/horizon/internal/db2/history/claimable_balances_test.go @@ -16,7 +16,9 @@ func TestRemoveClaimableBalance(t *testing.T) { test.ResetHorizonDB(t, tt.HorizonDB) q := &Q{tt.HorizonSession()} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() accountID := "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML" asset := xdr.MustNewCreditAsset("USD", accountID) @@ -67,7 +69,9 @@ func TestRemoveClaimableBalanceClaimants(t *testing.T) { test.ResetHorizonDB(t, tt.HorizonDB) q := &Q{tt.HorizonSession()} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() accountID := "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML" asset := xdr.MustNewCreditAsset("USD", accountID) @@ -119,7 +123,9 @@ func TestFindClaimableBalancesByDestination(t *testing.T) { q := &Q{tt.HorizonSession()} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() dest1 := "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML" dest2 := "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H" @@ -250,7 +256,9 @@ func TestFindClaimableBalance(t *testing.T) { q := &Q{tt.HorizonSession()} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() accountID := "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML" asset := xdr.MustNewCreditAsset("USD", accountID) @@ -298,7 +306,9 @@ func TestGetClaimableBalancesByID(t *testing.T) { q := &Q{tt.HorizonSession()} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() accountID := "GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML" asset := xdr.MustNewCreditAsset("USD", accountID) diff --git a/services/horizon/internal/db2/history/mock_claimable_balance_batch_insert_builder.go b/services/horizon/internal/db2/history/mock_claimable_balance_batch_insert_builder.go index 8caefcc65b..d3ce104244 100644 --- a/services/horizon/internal/db2/history/mock_claimable_balance_batch_insert_builder.go +++ b/services/horizon/internal/db2/history/mock_claimable_balance_batch_insert_builder.go @@ -21,7 +21,6 @@ func (m *MockClaimableBalanceBatchInsertBuilder) Exec(ctx context.Context, sessi return a.Error(0) } -func (m *MockClaimableBalanceBatchInsertBuilder) Reset() error { - a := m.Called() - return a.Error(0) +func (m *MockClaimableBalanceBatchInsertBuilder) Reset() { + m.Called() } diff --git a/services/horizon/internal/db2/history/mock_claimable_balance_claimant_batch_insert_builder.go b/services/horizon/internal/db2/history/mock_claimable_balance_claimant_batch_insert_builder.go index 697b1ff1f4..cf6c67e261 100644 --- a/services/horizon/internal/db2/history/mock_claimable_balance_claimant_batch_insert_builder.go +++ b/services/horizon/internal/db2/history/mock_claimable_balance_claimant_batch_insert_builder.go @@ -21,7 +21,6 @@ func (m *MockClaimableBalanceClaimantBatchInsertBuilder) Exec(ctx context.Contex return a.Error(0) } -func (m *MockClaimableBalanceClaimantBatchInsertBuilder) Reset() error { - a := m.Called() - return a.Error(0) +func (m *MockClaimableBalanceClaimantBatchInsertBuilder) Reset() { + m.Called() } diff --git a/services/horizon/internal/ingest/verify_test.go b/services/horizon/internal/ingest/verify_test.go index 4460b93e6e..2daf36823f 100644 --- a/services/horizon/internal/ingest/verify_test.go +++ b/services/horizon/internal/ingest/verify_test.go @@ -166,7 +166,9 @@ func TestStateVerifierLockBusy(t *testing.T) { q := &history.Q{&db.Session{DB: tt.HorizonDB}} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() checkpointLedger := uint32(63) changeProcessor := buildChangeProcessor(q, q.SessionInterface, &ingest.StatsChangeProcessor{}, ledgerSource, checkpointLedger) @@ -224,7 +226,9 @@ func TestStateVerifier(t *testing.T) { q := &history.Q{&db.Session{DB: tt.HorizonDB}} tt.Assert.NoError(q.SessionInterface.BeginTx(&sql.TxOptions{})) - defer q.SessionInterface.Rollback() + defer func() { + _ = q.SessionInterface.Rollback() + }() checkpointLedger := uint32(63) changeProcessor := buildChangeProcessor(q, q.SessionInterface, &ingest.StatsChangeProcessor{}, ledgerSource, checkpointLedger)