Skip to content

Commit d75f17d

Browse files
committed
sweepbatcher: simplify presigned/purging test
It doesn't need loopdb, so remove that code.
1 parent 8a07107 commit d75f17d

File tree

1 file changed

+7
-51
lines changed

1 file changed

+7
-51
lines changed

sweepbatcher/sweep_batcher_presigned_test.go

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ func testPresigned_presigned_and_regular_sweeps(t *testing.T, store testStore,
13541354
// to another online batch. In offline case they must are added to a new batch
13551355
// having valid presigned transactions.
13561356
func testPresigned_purging(t *testing.T, numSwaps, numConfirmedSwaps int,
1357-
store testStore, batcherStore testBatcherStore, online bool) {
1357+
batcherStore testBatcherStore, online bool) {
13581358

13591359
defer test.Guard(t)()
13601360

@@ -1420,33 +1420,13 @@ func testPresigned_purging(t *testing.T, numSwaps, numConfirmedSwaps int,
14201420
}
14211421
groups[i] = group
14221422

1423-
// Create a swap in DB.
1424-
swap := &loopdb.LoopOutContract{
1425-
SwapContract: loopdb.SwapContract{
1426-
CltvExpiry: 111,
1427-
AmountRequested: swapAmount,
1428-
ProtocolVersion: loopdb.ProtocolVersionMuSig2,
1429-
HtlcKeys: htlcKeys,
1430-
1431-
// Make preimage unique to pass SQL constraints.
1432-
Preimage: lntypes.Preimage{byte(i + 1)},
1433-
},
1434-
1435-
DestAddr: destAddr,
1436-
SwapInvoice: swapInvoice,
1437-
SweepConfTarget: 111,
1438-
}
1439-
err := store.CreateLoopOut(ctx, swapHash, swap)
1440-
require.NoError(t, err)
1441-
store.AssertLoopOutStored()
1442-
14431423
// Enable all the sweeps.
14441424
for _, op := range ops {
14451425
presignedHelper.SetOutpointOnline(op, true)
14461426
}
14471427

14481428
// An attempt to presign must succeed.
1449-
err = batcher.PresignSweepsGroup(
1429+
err := batcher.PresignSweepsGroup(
14501430
ctx, group, sweepTimeout, destAddr,
14511431
)
14521432
require.NoError(t, err)
@@ -1506,31 +1486,11 @@ func testPresigned_purging(t *testing.T, numSwaps, numConfirmedSwaps int,
15061486
},
15071487
}
15081488

1509-
// Create a swap in DB.
1510-
swap := &loopdb.LoopOutContract{
1511-
SwapContract: loopdb.SwapContract{
1512-
CltvExpiry: 111,
1513-
AmountRequested: amount,
1514-
ProtocolVersion: loopdb.ProtocolVersionMuSig2,
1515-
HtlcKeys: htlcKeys,
1516-
1517-
// Make preimage unique to pass SQL constraints.
1518-
Preimage: lntypes.Preimage{1, 2, 3},
1519-
},
1520-
1521-
DestAddr: destAddr,
1522-
SwapInvoice: swapInvoice,
1523-
SweepConfTarget: 111,
1524-
}
1525-
err := store.CreateLoopOut(ctx, swapHash, swap)
1526-
require.NoError(t, err)
1527-
store.AssertLoopOutStored()
1528-
15291489
// Enable the sweep.
15301490
presignedHelper.SetOutpointOnline(opx, true)
15311491

15321492
// An attempt to presign must succeed.
1533-
err = batcher.PresignSweepsGroup(
1493+
err := batcher.PresignSweepsGroup(
15341494
ctx, group, sweepTimeout, destAddr,
15351495
)
15361496
require.NoError(t, err)
@@ -1759,14 +1719,10 @@ func TestPresigned(t *testing.T) {
17591719
}
17601720

17611721
t.Run(name, func(t *testing.T) {
1762-
runTests(t, func(t *testing.T, store testStore,
1763-
batcherStore testBatcherStore) {
1764-
1765-
testPresigned_purging(
1766-
t, numSwaps, numConfirmedSwaps,
1767-
store, batcherStore, online,
1768-
)
1769-
})
1722+
testPresigned_purging(
1723+
t, numSwaps, numConfirmedSwaps,
1724+
NewStoreMock(), online,
1725+
)
17701726
})
17711727
}
17721728

0 commit comments

Comments
 (0)