Revert "sweepbatcher/StoreMock: load LoopOut from loopdb"

This reverts commit d38b7c55a7.

Batcher does not use this data anymore, since previous commit.
pull/761/head
Boris Nagaev 4 months ago
parent 16132d1593
commit 4be69e186e
No known key found for this signature in database

@ -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,

@ -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 {

@ -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)

@ -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,

Loading…
Cancel
Save