Skip to content

Commit 4be69e1

Browse files
committed
Revert "sweepbatcher/StoreMock: load LoopOut from loopdb"
This reverts commit d38b7c5. Batcher does not use this data anymore, since previous commit.
1 parent 16132d1 commit 4be69e1

File tree

4 files changed

+19
-34
lines changed

4 files changed

+19
-34
lines changed

loopout_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func testCustomSweepConfTarget(t *testing.T) {
297297

298298
errChan := make(chan error, 2)
299299

300-
batcherStore := sweepbatcher.NewStoreMock(cfg.store)
300+
batcherStore := sweepbatcher.NewStoreMock()
301301

302302
batcher := sweepbatcher.NewBatcher(
303303
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
@@ -530,7 +530,7 @@ func testPreimagePush(t *testing.T) {
530530

531531
errChan := make(chan error, 2)
532532

533-
batcherStore := sweepbatcher.NewStoreMock(cfg.store)
533+
batcherStore := sweepbatcher.NewStoreMock()
534534

535535
batcher := sweepbatcher.NewBatcher(
536536
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
@@ -951,7 +951,7 @@ func TestLoopOutMuSig2Sweep(t *testing.T) {
951951

952952
errChan := make(chan error, 2)
953953

954-
batcherStore := sweepbatcher.NewStoreMock(cfg.store)
954+
batcherStore := sweepbatcher.NewStoreMock()
955955

956956
batcher := sweepbatcher.NewBatcher(
957957
lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,

sweepbatcher/store_mock.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package sweepbatcher
33
import (
44
"context"
55
"errors"
6-
"fmt"
76
"sort"
87

98
"github.com/btcsuite/btcd/btcutil"
@@ -12,17 +11,15 @@ import (
1211

1312
// StoreMock implements a mock client swap store.
1413
type StoreMock struct {
15-
batches map[int32]dbBatch
16-
sweeps map[lntypes.Hash]dbSweep
17-
swapStore LoopOutFetcher
14+
batches map[int32]dbBatch
15+
sweeps map[lntypes.Hash]dbSweep
1816
}
1917

2018
// NewStoreMock instantiates a new mock store.
21-
func NewStoreMock(swapStore LoopOutFetcher) *StoreMock {
19+
func NewStoreMock() *StoreMock {
2220
return &StoreMock{
23-
batches: make(map[int32]dbBatch),
24-
sweeps: make(map[lntypes.Hash]dbSweep),
25-
swapStore: swapStore,
21+
batches: make(map[int32]dbBatch),
22+
sweeps: make(map[lntypes.Hash]dbSweep),
2623
}
2724
}
2825

@@ -93,21 +90,9 @@ func (s *StoreMock) FetchBatchSweeps(ctx context.Context,
9390
result := []*dbSweep{}
9491
for _, sweep := range s.sweeps {
9592
sweep := sweep
96-
if sweep.BatchID != id {
97-
continue
93+
if sweep.BatchID == id {
94+
result = append(result, &sweep)
9895
}
99-
100-
// Load swap from loopdb.
101-
swap, err := s.swapStore.FetchLoopOutSwap(
102-
ctx, sweep.SwapHash,
103-
)
104-
if err != nil {
105-
return nil, fmt.Errorf("failed to fetch swap "+
106-
"for SwapHash=%v", sweep.SwapHash)
107-
}
108-
sweep.LoopOut = swap
109-
110-
result = append(result, &sweep)
11196
}
11297

11398
sort.Slice(result, func(i, j int) bool {

sweepbatcher/sweep_batcher_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestSweepBatcherBatchCreation(t *testing.T) {
6464

6565
store := loopdb.NewStoreMock(t)
6666

67-
batcherStore := NewStoreMock(store)
67+
batcherStore := NewStoreMock()
6868

6969
batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
7070
testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store)
@@ -218,7 +218,7 @@ func TestSweepBatcherSimpleLifecycle(t *testing.T) {
218218

219219
store := loopdb.NewStoreMock(t)
220220

221-
batcherStore := NewStoreMock(store)
221+
batcherStore := NewStoreMock()
222222

223223
batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
224224
testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store)
@@ -355,7 +355,7 @@ func TestSweepBatcherSweepReentry(t *testing.T) {
355355

356356
store := loopdb.NewStoreMock(t)
357357

358-
batcherStore := NewStoreMock(store)
358+
batcherStore := NewStoreMock()
359359

360360
batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
361361
testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store)
@@ -562,7 +562,7 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) {
562562

563563
store := loopdb.NewStoreMock(t)
564564

565-
batcherStore := NewStoreMock(store)
565+
batcherStore := NewStoreMock()
566566

567567
batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
568568
testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store)
@@ -727,7 +727,7 @@ func TestSweepBatcherComposite(t *testing.T) {
727727

728728
store := loopdb.NewStoreMock(t)
729729

730-
batcherStore := NewStoreMock(store)
730+
batcherStore := NewStoreMock()
731731

732732
batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
733733
testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store)
@@ -1044,7 +1044,7 @@ func TestRestoringEmptyBatch(t *testing.T) {
10441044

10451045
store := loopdb.NewStoreMock(t)
10461046

1047-
batcherStore := NewStoreMock(store)
1047+
batcherStore := NewStoreMock()
10481048
_, err := batcherStore.InsertSweepBatch(ctx, &dbBatch{})
10491049
require.NoError(t, err)
10501050

@@ -1158,7 +1158,7 @@ func TestHandleSweepTwice(t *testing.T) {
11581158

11591159
store := newLoopStoreMock()
11601160

1161-
batcherStore := NewStoreMock(store)
1161+
batcherStore := NewStoreMock()
11621162

11631163
batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
11641164
testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store)
@@ -1314,7 +1314,7 @@ func TestRestoringPreservesConfTarget(t *testing.T) {
13141314

13151315
store := loopdb.NewStoreMock(t)
13161316

1317-
batcherStore := NewStoreMock(store)
1317+
batcherStore := NewStoreMock()
13181318

13191319
batcher := NewBatcher(lnd.WalletKit, lnd.ChainNotifier, lnd.Signer,
13201320
testMuSig2SignSweep, nil, lnd.ChainParams, batcherStore, store)

testcontext_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func newSwapClient(config *clientConfig) *Client {
7777

7878
lndServices := config.LndServices
7979

80-
batcherStore := sweepbatcher.NewStoreMock(config.Store)
80+
batcherStore := sweepbatcher.NewStoreMock()
8181

8282
batcher := sweepbatcher.NewBatcher(
8383
config.LndServices.WalletKit, config.LndServices.ChainNotifier,

0 commit comments

Comments
 (0)