mirror of
https://github.com/lightninglabs/loop
synced 2024-11-09 19:10:47 +00:00
Revert "sweepbatcher/StoreMock: load LoopOut from loopdb"
This reverts commit d38b7c55a7
.
Batcher does not use this data anymore, since previous commit.
This commit is contained in:
parent
16132d1593
commit
4be69e186e
@ -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"
|
||||
@ -14,15 +13,13 @@ import (
|
||||
type StoreMock struct {
|
||||
batches map[int32]dbBatch
|
||||
sweeps map[lntypes.Hash]dbSweep
|
||||
swapStore LoopOutFetcher
|
||||
}
|
||||
|
||||
// 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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,22 +90,10 @@ func (s *StoreMock) FetchBatchSweeps(ctx context.Context,
|
||||
result := []*dbSweep{}
|
||||
for _, sweep := range s.sweeps {
|
||||
sweep := sweep
|
||||
if sweep.BatchID != id {
|
||||
continue
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
if sweep.BatchID == id {
|
||||
result = append(result, &sweep)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(result, func(i, j int) bool {
|
||||
return result[i].ID < result[j].ID
|
||||
|
@ -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…
Reference in New Issue
Block a user