diff --git a/loopdb/sqlc/batch.sql.go b/loopdb/sqlc/batch.sql.go index c8fab1f2..4bdce262 100644 --- a/loopdb/sqlc/batch.sql.go +++ b/loopdb/sqlc/batch.sql.go @@ -8,7 +8,6 @@ package sqlc import ( "context" "database/sql" - "time" ) const confirmBatch = `-- name: ConfirmBatch :exec @@ -36,73 +35,24 @@ func (q *Queries) DropBatch(ctx context.Context, id int32) error { const getBatchSweeps = `-- name: GetBatchSweeps :many SELECT - sweeps.id, sweeps.swap_hash, sweeps.batch_id, sweeps.outpoint_txid, sweeps.outpoint_index, sweeps.amt, sweeps.completed, - swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, - loopout_swaps.swap_hash, loopout_swaps.dest_address, loopout_swaps.swap_invoice, loopout_swaps.max_swap_routing_fee, loopout_swaps.sweep_conf_target, loopout_swaps.htlc_confirmations, loopout_swaps.outgoing_chan_set, loopout_swaps.prepay_invoice, loopout_swaps.max_prepay_routing_fee, loopout_swaps.publication_deadline, loopout_swaps.single_sweep, loopout_swaps.payment_timeout, - htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index + id, swap_hash, batch_id, outpoint_txid, outpoint_index, amt, completed FROM sweeps -JOIN - swaps ON sweeps.swap_hash = swaps.swap_hash -JOIN - loopout_swaps ON sweeps.swap_hash = loopout_swaps.swap_hash -JOIN - htlc_keys ON sweeps.swap_hash = htlc_keys.swap_hash WHERE - sweeps.batch_id = $1 + batch_id = $1 ORDER BY - sweeps.id ASC + id ASC ` -type GetBatchSweepsRow struct { - ID int32 - SwapHash []byte - BatchID int32 - OutpointTxid []byte - OutpointIndex int32 - Amt int64 - Completed bool - ID_2 int32 - SwapHash_2 []byte - Preimage []byte - InitiationTime time.Time - AmountRequested int64 - CltvExpiry int32 - MaxMinerFee int64 - MaxSwapFee int64 - InitiationHeight int32 - ProtocolVersion int32 - Label string - SwapHash_3 []byte - DestAddress string - SwapInvoice string - MaxSwapRoutingFee int64 - SweepConfTarget int32 - HtlcConfirmations int32 - OutgoingChanSet string - PrepayInvoice string - MaxPrepayRoutingFee int64 - PublicationDeadline time.Time - SingleSweep bool - PaymentTimeout int32 - SwapHash_4 []byte - SenderScriptPubkey []byte - ReceiverScriptPubkey []byte - SenderInternalPubkey []byte - ReceiverInternalPubkey []byte - ClientKeyFamily int32 - ClientKeyIndex int32 -} - -func (q *Queries) GetBatchSweeps(ctx context.Context, batchID int32) ([]GetBatchSweepsRow, error) { +func (q *Queries) GetBatchSweeps(ctx context.Context, batchID int32) ([]Sweep, error) { rows, err := q.db.QueryContext(ctx, getBatchSweeps, batchID) if err != nil { return nil, err } defer rows.Close() - var items []GetBatchSweepsRow + var items []Sweep for rows.Next() { - var i GetBatchSweepsRow + var i Sweep if err := rows.Scan( &i.ID, &i.SwapHash, @@ -111,36 +61,6 @@ func (q *Queries) GetBatchSweeps(ctx context.Context, batchID int32) ([]GetBatch &i.OutpointIndex, &i.Amt, &i.Completed, - &i.ID_2, - &i.SwapHash_2, - &i.Preimage, - &i.InitiationTime, - &i.AmountRequested, - &i.CltvExpiry, - &i.MaxMinerFee, - &i.MaxSwapFee, - &i.InitiationHeight, - &i.ProtocolVersion, - &i.Label, - &i.SwapHash_3, - &i.DestAddress, - &i.SwapInvoice, - &i.MaxSwapRoutingFee, - &i.SweepConfTarget, - &i.HtlcConfirmations, - &i.OutgoingChanSet, - &i.PrepayInvoice, - &i.MaxPrepayRoutingFee, - &i.PublicationDeadline, - &i.SingleSweep, - &i.PaymentTimeout, - &i.SwapHash_4, - &i.SenderScriptPubkey, - &i.ReceiverScriptPubkey, - &i.SenderInternalPubkey, - &i.ReceiverInternalPubkey, - &i.ClientKeyFamily, - &i.ClientKeyIndex, ); err != nil { return nil, err } @@ -184,7 +104,7 @@ WHERE sweeps.swap_hash = $1 AND sweeps.completed = TRUE -AND +AND sweep_batches.confirmed = TRUE ` diff --git a/loopdb/sqlc/instantout.sql.go b/loopdb/sqlc/instantout.sql.go index 73fb0ac2..fac01ae2 100644 --- a/loopdb/sqlc/instantout.sql.go +++ b/loopdb/sqlc/instantout.sql.go @@ -133,7 +133,7 @@ func (q *Queries) GetInstantOutSwapUpdates(ctx context.Context, swapHash []byte) } const getInstantOutSwaps = `-- name: GetInstantOutSwaps :many -SELECT +SELECT swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, instantout_swaps.swap_hash, instantout_swaps.preimage, instantout_swaps.sweep_address, instantout_swaps.outgoing_chan_set, instantout_swaps.htlc_fee_rate, instantout_swaps.reservation_ids, instantout_swaps.swap_invoice, instantout_swaps.finalized_htlc_tx, instantout_swaps.sweep_tx_hash, instantout_swaps.finalized_sweepless_sweep_tx, instantout_swaps.sweep_confirmation_height, htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index @@ -235,7 +235,7 @@ func (q *Queries) GetInstantOutSwaps(ctx context.Context) ([]GetInstantOutSwapsR const insertInstantOut = `-- name: InsertInstantOut :exec INSERT INTO instantout_swaps ( swap_hash, - preimage, + preimage, sweep_address, outgoing_chan_set, htlc_fee_rate, diff --git a/loopdb/sqlc/querier.go b/loopdb/sqlc/querier.go index d12c6ed7..11e7d3e4 100644 --- a/loopdb/sqlc/querier.go +++ b/loopdb/sqlc/querier.go @@ -13,7 +13,7 @@ type Querier interface { CreateReservation(ctx context.Context, arg CreateReservationParams) error DropBatch(ctx context.Context, id int32) error FetchLiquidityParams(ctx context.Context) ([]byte, error) - GetBatchSweeps(ctx context.Context, batchID int32) ([]GetBatchSweepsRow, error) + GetBatchSweeps(ctx context.Context, batchID int32) ([]Sweep, error) GetBatchSweptAmount(ctx context.Context, batchID int32) (int64, error) GetInstantOutSwap(ctx context.Context, swapHash []byte) (GetInstantOutSwapRow, error) GetInstantOutSwapUpdates(ctx context.Context, swapHash []byte) ([]InstantoutUpdate, error) diff --git a/loopdb/sqlc/queries/batch.sql b/loopdb/sqlc/queries/batch.sql index 5951dfe4..70d04da4 100644 --- a/loopdb/sqlc/queries/batch.sql +++ b/loopdb/sqlc/queries/batch.sql @@ -76,7 +76,7 @@ WHERE sweeps.swap_hash = $1 AND sweeps.completed = TRUE -AND +AND sweep_batches.confirmed = TRUE; -- name: GetBatchSweptAmount :one @@ -91,22 +91,13 @@ AND -- name: GetBatchSweeps :many SELECT - sweeps.*, - swaps.*, - loopout_swaps.*, - htlc_keys.* + * FROM sweeps -JOIN - swaps ON sweeps.swap_hash = swaps.swap_hash -JOIN - loopout_swaps ON sweeps.swap_hash = loopout_swaps.swap_hash -JOIN - htlc_keys ON sweeps.swap_hash = htlc_keys.swap_hash WHERE - sweeps.batch_id = $1 + batch_id = $1 ORDER BY - sweeps.id ASC; + id ASC; -- name: GetSweepStatus :one SELECT diff --git a/loopdb/sqlc/queries/instantout.sql b/loopdb/sqlc/queries/instantout.sql index 56f9052d..4b37a2ff 100644 --- a/loopdb/sqlc/queries/instantout.sql +++ b/loopdb/sqlc/queries/instantout.sql @@ -1,7 +1,7 @@ -- name: InsertInstantOut :exec INSERT INTO instantout_swaps ( swap_hash, - preimage, + preimage, sweep_address, outgoing_chan_set, htlc_fee_rate, @@ -53,7 +53,7 @@ WHERE swaps.swap_hash = $1; -- name: GetInstantOutSwaps :many -SELECT +SELECT swaps.*, instantout_swaps.*, htlc_keys.* diff --git a/loopdb/sqlc/queries/swaps.sql b/loopdb/sqlc/queries/swaps.sql index 8d8dd66e..effcb060 100644 --- a/loopdb/sqlc/queries/swaps.sql +++ b/loopdb/sqlc/queries/swaps.sql @@ -1,9 +1,9 @@ -- name: GetLoopOutSwaps :many -SELECT +SELECT swaps.*, loopout_swaps.*, htlc_keys.* -FROM +FROM swaps JOIN loopout_swaps ON swaps.swap_hash = loopout_swaps.swap_hash @@ -13,7 +13,7 @@ ORDER BY swaps.id; -- name: GetLoopOutSwap :one -SELECT +SELECT swaps.*, loopout_swaps.*, htlc_keys.* @@ -27,7 +27,7 @@ WHERE swaps.swap_hash = $1; -- name: GetLoopInSwaps :many -SELECT +SELECT swaps.*, loopin_swaps.*, htlc_keys.* @@ -41,7 +41,7 @@ ORDER BY swaps.id; -- name: GetLoopInSwap :one -SELECT +SELECT swaps.*, loopin_swaps.*, htlc_keys.* @@ -55,7 +55,7 @@ WHERE swaps.swap_hash = $1; -- name: GetSwapUpdates :many -SELECT +SELECT * FROM swap_updates diff --git a/loopdb/sqlc/swaps.sql.go b/loopdb/sqlc/swaps.sql.go index cda5dec5..e5cda442 100644 --- a/loopdb/sqlc/swaps.sql.go +++ b/loopdb/sqlc/swaps.sql.go @@ -11,7 +11,7 @@ import ( ) const getLoopInSwap = `-- name: GetLoopInSwap :one -SELECT +SELECT swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, loopin_swaps.swap_hash, loopin_swaps.htlc_conf_target, loopin_swaps.last_hop, loopin_swaps.external_htlc, htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index @@ -81,7 +81,7 @@ func (q *Queries) GetLoopInSwap(ctx context.Context, swapHash []byte) (GetLoopIn } const getLoopInSwaps = `-- name: GetLoopInSwaps :many -SELECT +SELECT swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, loopin_swaps.swap_hash, loopin_swaps.htlc_conf_target, loopin_swaps.last_hop, loopin_swaps.external_htlc, htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index @@ -167,7 +167,7 @@ func (q *Queries) GetLoopInSwaps(ctx context.Context) ([]GetLoopInSwapsRow, erro } const getLoopOutSwap = `-- name: GetLoopOutSwap :one -SELECT +SELECT swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, loopout_swaps.swap_hash, loopout_swaps.dest_address, loopout_swaps.swap_invoice, loopout_swaps.max_swap_routing_fee, loopout_swaps.sweep_conf_target, loopout_swaps.htlc_confirmations, loopout_swaps.outgoing_chan_set, loopout_swaps.prepay_invoice, loopout_swaps.max_prepay_routing_fee, loopout_swaps.publication_deadline, loopout_swaps.single_sweep, loopout_swaps.payment_timeout, htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index @@ -253,11 +253,11 @@ func (q *Queries) GetLoopOutSwap(ctx context.Context, swapHash []byte) (GetLoopO } const getLoopOutSwaps = `-- name: GetLoopOutSwaps :many -SELECT +SELECT swaps.id, swaps.swap_hash, swaps.preimage, swaps.initiation_time, swaps.amount_requested, swaps.cltv_expiry, swaps.max_miner_fee, swaps.max_swap_fee, swaps.initiation_height, swaps.protocol_version, swaps.label, loopout_swaps.swap_hash, loopout_swaps.dest_address, loopout_swaps.swap_invoice, loopout_swaps.max_swap_routing_fee, loopout_swaps.sweep_conf_target, loopout_swaps.htlc_confirmations, loopout_swaps.outgoing_chan_set, loopout_swaps.prepay_invoice, loopout_swaps.max_prepay_routing_fee, loopout_swaps.publication_deadline, loopout_swaps.single_sweep, loopout_swaps.payment_timeout, htlc_keys.swap_hash, htlc_keys.sender_script_pubkey, htlc_keys.receiver_script_pubkey, htlc_keys.sender_internal_pubkey, htlc_keys.receiver_internal_pubkey, htlc_keys.client_key_family, htlc_keys.client_key_index -FROM +FROM swaps JOIN loopout_swaps ON swaps.swap_hash = loopout_swaps.swap_hash @@ -355,7 +355,7 @@ func (q *Queries) GetLoopOutSwaps(ctx context.Context) ([]GetLoopOutSwapsRow, er } const getSwapUpdates = `-- name: GetSwapUpdates :many -SELECT +SELECT id, swap_hash, update_timestamp, update_state, htlc_txhash, server_cost, onchain_cost, offchain_cost FROM swap_updates diff --git a/loopout_test.go b/loopout_test.go index 7827b4ff..3138b1a3 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -297,7 +297,7 @@ func testCustomSweepConfTarget(t *testing.T) { errChan := make(chan error, 2) - batcherStore := sweepbatcher.NewStoreMock(cfg.store) + batcherStore := sweepbatcher.NewStoreMock() batcher := sweepbatcher.NewBatcher( lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, @@ -530,7 +530,7 @@ func testPreimagePush(t *testing.T) { errChan := make(chan error, 2) - batcherStore := sweepbatcher.NewStoreMock(cfg.store) + batcherStore := sweepbatcher.NewStoreMock() batcher := sweepbatcher.NewBatcher( lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, @@ -951,7 +951,7 @@ func TestLoopOutMuSig2Sweep(t *testing.T) { errChan := make(chan error, 2) - batcherStore := sweepbatcher.NewStoreMock(cfg.store) + batcherStore := sweepbatcher.NewStoreMock() batcher := sweepbatcher.NewBatcher( lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, diff --git a/sweepbatcher/store.go b/sweepbatcher/store.go index aff5ff51..b1a700c0 100644 --- a/sweepbatcher/store.go +++ b/sweepbatcher/store.go @@ -21,7 +21,7 @@ type BaseDB interface { // GetBatchSweeps fetches all the sweeps that are part a batch. GetBatchSweeps(ctx context.Context, batchID int32) ( - []sqlc.GetBatchSweepsRow, error) + []sqlc.Sweep, error) // GetBatchSweptAmount returns the total amount of sats swept by a // (confirmed) batch. @@ -34,10 +34,6 @@ type BaseDB interface { GetParentBatch(ctx context.Context, swapHash []byte) (sqlc.SweepBatch, error) - // GetSwapUpdates fetches all the updates for a swap. - GetSwapUpdates(ctx context.Context, swapHash []byte) ( - []sqlc.SwapUpdate, error) - // GetUnconfirmedBatches fetches all the batches from the // database that are not in a confirmed state. GetUnconfirmedBatches(ctx context.Context) ([]sqlc.SweepBatch, error) @@ -154,14 +150,7 @@ func (s *SQLStore) FetchBatchSweeps(ctx context.Context, id int32) ( } for _, dbSweep := range dbSweeps { - updates, err := s.baseDb.GetSwapUpdates( - ctx, dbSweep.SwapHash, - ) - if err != nil { - return err - } - - sweep, err := s.convertSweepRow(dbSweep, updates) + sweep, err := s.convertSweepRow(dbSweep) if err != nil { return err } @@ -260,9 +249,6 @@ type dbSweep struct { // Completed indicates whether this sweep is completed. Completed bool - - // LoopOut is the loop out that the sweep belongs to. - LoopOut *loopdb.LoopOut } // convertBatchRow converts a batch row from db to a sweepbatcher.Batch struct. @@ -354,9 +340,7 @@ func batchToUpdateArgs(batch dbBatch) sqlc.UpdateBatchParams { } // convertSweepRow converts a sweep row from db to a sweep struct. -func (s *SQLStore) convertSweepRow(row sqlc.GetBatchSweepsRow, - updates []sqlc.SwapUpdate) (dbSweep, error) { - +func (s *SQLStore) convertSweepRow(row sqlc.Sweep) (dbSweep, error) { sweep := dbSweep{ ID: row.ID, BatchID: row.BatchID, @@ -380,40 +364,7 @@ func (s *SQLStore) convertSweepRow(row sqlc.GetBatchSweepsRow, Index: uint32(row.OutpointIndex), } - sweep.LoopOut, err = loopdb.ConvertLoopOutRow( - s.network, - sqlc.GetLoopOutSwapRow{ - ID: row.ID, - SwapHash: row.SwapHash, - Preimage: row.Preimage, - InitiationTime: row.InitiationTime, - AmountRequested: row.AmountRequested, - CltvExpiry: row.CltvExpiry, - MaxMinerFee: row.MaxMinerFee, - MaxSwapFee: row.MaxSwapFee, - InitiationHeight: row.InitiationHeight, - ProtocolVersion: row.ProtocolVersion, - Label: row.Label, - DestAddress: row.DestAddress, - SwapInvoice: row.SwapInvoice, - MaxSwapRoutingFee: row.MaxSwapRoutingFee, - SweepConfTarget: row.SweepConfTarget, - HtlcConfirmations: row.HtlcConfirmations, - OutgoingChanSet: row.OutgoingChanSet, - PrepayInvoice: row.PrepayInvoice, - MaxPrepayRoutingFee: row.MaxPrepayRoutingFee, - PublicationDeadline: row.PublicationDeadline, - SingleSweep: row.SingleSweep, - SenderScriptPubkey: row.SenderScriptPubkey, - ReceiverScriptPubkey: row.ReceiverScriptPubkey, - SenderInternalPubkey: row.SenderInternalPubkey, - ReceiverInternalPubkey: row.ReceiverInternalPubkey, - ClientKeyFamily: row.ClientKeyFamily, - ClientKeyIndex: row.ClientKeyIndex, - }, updates, - ) - - return sweep, err + return sweep, nil } // sweepToUpsertArgs converts a Sweep struct to the arguments needed to insert. diff --git a/sweepbatcher/store_mock.go b/sweepbatcher/store_mock.go index 96d5dcf4..57cdd34b 100644 --- a/sweepbatcher/store_mock.go +++ b/sweepbatcher/store_mock.go @@ -3,7 +3,6 @@ package sweepbatcher import ( "context" "errors" - "fmt" "sort" "github.com/btcsuite/btcd/btcutil" @@ -12,17 +11,15 @@ import ( // StoreMock implements a mock client swap store. type StoreMock struct { - batches map[int32]dbBatch - sweeps map[lntypes.Hash]dbSweep - swapStore LoopOutFetcher + batches map[int32]dbBatch + sweeps map[lntypes.Hash]dbSweep } // NewStoreMock instantiates a new mock store. -func NewStoreMock(swapStore LoopOutFetcher) *StoreMock { +func NewStoreMock() *StoreMock { return &StoreMock{ - batches: make(map[int32]dbBatch), - sweeps: make(map[lntypes.Hash]dbSweep), - swapStore: swapStore, + batches: make(map[int32]dbBatch), + sweeps: make(map[lntypes.Hash]dbSweep), } } @@ -93,21 +90,9 @@ func (s *StoreMock) FetchBatchSweeps(ctx context.Context, result := []*dbSweep{} for _, sweep := range s.sweeps { sweep := sweep - if sweep.BatchID != id { - continue + if sweep.BatchID == id { + result = append(result, &sweep) } - - // Load swap from loopdb. - swap, err := s.swapStore.FetchLoopOutSwap( - ctx, sweep.SwapHash, - ) - if err != nil { - return nil, fmt.Errorf("failed to fetch swap "+ - "for SwapHash=%v", sweep.SwapHash) - } - sweep.LoopOut = swap - - result = append(result, &sweep) } sort.Slice(result, func(i, j int) bool { diff --git a/sweepbatcher/sweep_batcher.go b/sweepbatcher/sweep_batcher.go index 749da451..79481a11 100644 --- a/sweepbatcher/sweep_batcher.go +++ b/sweepbatcher/sweep_batcher.go @@ -450,7 +450,7 @@ func (b *Batcher) spinUpBatchFromDB(ctx context.Context, batch *batch) error { sweeps := make(map[lntypes.Hash]sweep) for _, dbSweep := range dbSweeps { - sweep, err := b.convertSweep(dbSweep) + sweep, err := b.convertSweep(ctx, dbSweep) if err != nil { return err } @@ -656,9 +656,16 @@ func (b *Batcher) writeToErrChan(ctx context.Context, err error) error { } // convertSweep converts a fetched sweep from the database to a sweep that is -// ready to be processed by the batcher. -func (b *Batcher) convertSweep(dbSweep *dbSweep) (*sweep, error) { - swap := dbSweep.LoopOut +// ready to be processed by the batcher. It loads swap from loopdb by calling +// method FetchLoopOutSwap. +func (b *Batcher) convertSweep(ctx context.Context, dbSweep *dbSweep) ( + *sweep, error) { + + swap, err := b.swapStore.FetchLoopOutSwap(ctx, dbSweep.SwapHash) + if err != nil { + return nil, fmt.Errorf("failed to fetch loop out for %x: %w", + dbSweep.SwapHash[:6], err) + } htlc, err := utils.GetHtlc( dbSweep.SwapHash, &swap.Contract.SwapContract, b.chainParams, diff --git a/sweepbatcher/sweep_batcher_test.go b/sweepbatcher/sweep_batcher_test.go index 4b73cfaa..4afb7262 100644 --- a/sweepbatcher/sweep_batcher_test.go +++ b/sweepbatcher/sweep_batcher_test.go @@ -64,7 +64,7 @@ func TestSweepBatcherBatchCreation(t *testing.T) { store := loopdb.NewStoreMock(t) - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store) @@ -218,7 +218,7 @@ func TestSweepBatcherSimpleLifecycle(t *testing.T) { store := loopdb.NewStoreMock(t) - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store) @@ -355,7 +355,7 @@ func TestSweepBatcherSweepReentry(t *testing.T) { store := loopdb.NewStoreMock(t) - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store) @@ -562,7 +562,7 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) { store := loopdb.NewStoreMock(t) - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store) @@ -727,7 +727,7 @@ func TestSweepBatcherComposite(t *testing.T) { store := loopdb.NewStoreMock(t) - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store) @@ -1044,7 +1044,7 @@ func TestRestoringEmptyBatch(t *testing.T) { store := loopdb.NewStoreMock(t) - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() _, err := batcherStore.InsertSweepBatch(ctx, &dbBatch{}) require.NoError(t, err) @@ -1158,7 +1158,7 @@ func TestHandleSweepTwice(t *testing.T) { store := newLoopStoreMock() - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store) @@ -1314,7 +1314,7 @@ func TestRestoringPreservesConfTarget(t *testing.T) { store := loopdb.NewStoreMock(t) - batcherStore := NewStoreMock(store) + batcherStore := NewStoreMock() batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer, testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store) diff --git a/testcontext_test.go b/testcontext_test.go index 9f8f120d..423eb31d 100644 --- a/testcontext_test.go +++ b/testcontext_test.go @@ -77,7 +77,7 @@ func newSwapClient(config *clientConfig) *Client { lndServices := config.LndServices - batcherStore := sweepbatcher.NewStoreMock(config.Store) + batcherStore := sweepbatcher.NewStoreMock() batcher := sweepbatcher.NewBatcher( config.LndServices.WalletKit, config.LndServices.ChainNotifier,