mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: remove redundant pgx.ErrNoRows checks
pgx/v5 defines ErrNoRows as a wrapped sql.ErrNoRows, so this code covers both of them: errors.Is(err, sql.ErrNoRows).
This commit is contained in:
parent
3b54b19eeb
commit
25056c6547
3 changed files with 10 additions and 8 deletions
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/loopdb/sqlc"
|
||||
|
|
@ -176,9 +175,7 @@ func (s *SqlStore) DepositForOutpoint(ctx context.Context,
|
|||
}
|
||||
row, err := q.DepositForOutpoint(ctx, params)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) ||
|
||||
errors.Is(err, pgx.ErrNoRows) {
|
||||
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ErrDepositNotFound
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package deposit
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
"github.com/lightninglabs/loop/loopdb/sqlc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
|
|
@ -76,3 +78,9 @@ func dummyHashBytes() []byte {
|
|||
0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23}
|
||||
}
|
||||
|
||||
// TestErrNoRows ensures that pgx.ErrNoRows is a wrapped sql.ErrNoRows, so we
|
||||
// don't have to check against both of them.
|
||||
func TestErrNoRows(t *testing.T) {
|
||||
require.ErrorIs(t, pgx.ErrNoRows, sql.ErrNoRows)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/lightninglabs/loop/fsm"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/loopdb/sqlc"
|
||||
|
|
@ -422,9 +421,7 @@ func (s *SqlStore) SwapHashesForDepositIDs(ctx context.Context,
|
|||
for _, id := range depositIDs {
|
||||
swapHash, err := s.baseDB.SwapHashForDepositID(ctx, id[:])
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) ||
|
||||
errors.Is(err, pgx.ErrNoRows) {
|
||||
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue