Skip to content

Commit b5b1799

Browse files
committed
sweepbatcher: use method AddSweep in test
1 parent 951f981 commit b5b1799

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

sweepbatcher/sweep_batcher_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ func TestSweepBatcherBatchCreation(t *testing.T) {
9898
store.AssertLoopOutStored()
9999

100100
// Deliver sweep request to batcher.
101-
batcher.sweepReqs <- sweepReq1
101+
require.NoError(t, batcher.AddSweep(&sweepReq1))
102102

103103
// Since a batch was created we check that it registered for its primary
104104
// sweep's spend.
105105
<-lnd.RegisterSpendChannel
106106

107107
// Insert the same swap twice, this should be a noop.
108-
batcher.sweepReqs <- sweepReq1
108+
require.NoError(t, batcher.AddSweep(&sweepReq1))
109109

110110
// Once batcher receives sweep request it will eventually spin up a
111111
// batch.
@@ -137,7 +137,7 @@ func TestSweepBatcherBatchCreation(t *testing.T) {
137137
require.NoError(t, err)
138138
store.AssertLoopOutStored()
139139

140-
batcher.sweepReqs <- sweepReq2
140+
require.NoError(t, batcher.AddSweep(&sweepReq2))
141141

142142
// Batcher should not create a second batch as timeout distance is small
143143
// enough.
@@ -169,7 +169,7 @@ func TestSweepBatcherBatchCreation(t *testing.T) {
169169
require.NoError(t, err)
170170
store.AssertLoopOutStored()
171171

172-
batcher.sweepReqs <- sweepReq3
172+
require.NoError(t, batcher.AddSweep(&sweepReq3))
173173

174174
// Batcher should create a second batch as timeout distance is greater
175175
// than the threshold
@@ -251,7 +251,7 @@ func TestSweepBatcherSimpleLifecycle(t *testing.T) {
251251
store.AssertLoopOutStored()
252252

253253
// Deliver sweep request to batcher.
254-
batcher.sweepReqs <- sweepReq1
254+
require.NoError(t, batcher.AddSweep(&sweepReq1))
255255

256256
// Eventually request will be consumed and a new batch will spin up.
257257
require.Eventually(t, func() bool {
@@ -435,15 +435,15 @@ func TestSweepBatcherSweepReentry(t *testing.T) {
435435
store.AssertLoopOutStored()
436436

437437
// Feed the sweeps to the batcher.
438-
batcher.sweepReqs <- sweepReq1
438+
require.NoError(t, batcher.AddSweep(&sweepReq1))
439439

440440
// After inserting the primary (first) sweep, a spend monitor should be
441441
// registered.
442442
<-lnd.RegisterSpendChannel
443443

444-
batcher.sweepReqs <- sweepReq2
444+
require.NoError(t, batcher.AddSweep(&sweepReq2))
445445

446-
batcher.sweepReqs <- sweepReq3
446+
require.NoError(t, batcher.AddSweep(&sweepReq3))
447447

448448
// Batcher should create a batch for the sweeps.
449449
require.Eventually(t, func() bool {
@@ -593,7 +593,7 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) {
593593
store.AssertLoopOutStored()
594594

595595
// Deliver sweep request to batcher.
596-
batcher.sweepReqs <- sweepReq1
596+
require.NoError(t, batcher.AddSweep(&sweepReq1))
597597

598598
// Once batcher receives sweep request it will eventually spin up a
599599
// batch.
@@ -606,7 +606,7 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) {
606606
<-lnd.RegisterSpendChannel
607607

608608
// Insert the same swap twice, this should be a noop.
609-
batcher.sweepReqs <- sweepReq1
609+
require.NoError(t, batcher.AddSweep(&sweepReq1))
610610

611611
// Create a second sweep request that has a timeout distance less than
612612
// our configured threshold.
@@ -633,7 +633,7 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) {
633633
require.NoError(t, err)
634634
store.AssertLoopOutStored()
635635

636-
batcher.sweepReqs <- sweepReq2
636+
require.NoError(t, batcher.AddSweep(&sweepReq2))
637637

638638
// Batcher should create a second batch as first batch is a non wallet
639639
// addr batch.
@@ -670,7 +670,7 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) {
670670
require.NoError(t, err)
671671
store.AssertLoopOutStored()
672672

673-
batcher.sweepReqs <- sweepReq3
673+
require.NoError(t, batcher.AddSweep(&sweepReq3))
674674

675675
// Batcher should create a new batch as timeout distance is greater than
676676
// the threshold
@@ -879,7 +879,7 @@ func TestSweepBatcherComposite(t *testing.T) {
879879
store.AssertLoopOutStored()
880880

881881
// Deliver sweep request to batcher.
882-
batcher.sweepReqs <- sweepReq1
882+
require.NoError(t, batcher.AddSweep(&sweepReq1))
883883

884884
// Once batcher receives sweep request it will eventually spin up a
885885
// batch.
@@ -892,17 +892,17 @@ func TestSweepBatcherComposite(t *testing.T) {
892892
<-lnd.RegisterSpendChannel
893893

894894
// Insert the same swap twice, this should be a noop.
895-
batcher.sweepReqs <- sweepReq1
895+
require.NoError(t, batcher.AddSweep(&sweepReq1))
896896

897-
batcher.sweepReqs <- sweepReq2
897+
require.NoError(t, batcher.AddSweep(&sweepReq2))
898898

899899
// Batcher should not create a second batch as timeout distance is small
900900
// enough.
901901
require.Eventually(t, func() bool {
902902
return len(batcher.batches) == 1
903903
}, test.Timeout, eventuallyCheckFrequency)
904904

905-
batcher.sweepReqs <- sweepReq3
905+
require.NoError(t, batcher.AddSweep(&sweepReq3))
906906

907907
// Batcher should create a second batch as this sweep pays to a non
908908
// wallet address.
@@ -914,7 +914,7 @@ func TestSweepBatcherComposite(t *testing.T) {
914914
// sweep's spend.
915915
<-lnd.RegisterSpendChannel
916916

917-
batcher.sweepReqs <- sweepReq4
917+
require.NoError(t, batcher.AddSweep(&sweepReq4))
918918

919919
// Batcher should create a third batch as timeout distance is greater
920920
// than the threshold.
@@ -926,15 +926,15 @@ func TestSweepBatcherComposite(t *testing.T) {
926926
// sweep's spend.
927927
<-lnd.RegisterSpendChannel
928928

929-
batcher.sweepReqs <- sweepReq5
929+
require.NoError(t, batcher.AddSweep(&sweepReq5))
930930

931931
// Batcher should not create a fourth batch as timeout distance is small
932932
// enough for it to join the last batch.
933933
require.Eventually(t, func() bool {
934934
return len(batcher.batches) == 3
935935
}, test.Timeout, eventuallyCheckFrequency)
936936

937-
batcher.sweepReqs <- sweepReq6
937+
require.NoError(t, batcher.AddSweep(&sweepReq6))
938938

939939
// Batcher should create a fourth batch as this sweep pays to a non
940940
// wallet address.
@@ -1084,7 +1084,7 @@ func TestRestoringEmptyBatch(t *testing.T) {
10841084
store.AssertLoopOutStored()
10851085

10861086
// Deliver sweep request to batcher.
1087-
batcher.sweepReqs <- sweepReq
1087+
require.NoError(t, batcher.AddSweep(&sweepReq))
10881088

10891089
// Since a batch was created we check that it registered for its primary
10901090
// sweep's spend.

0 commit comments

Comments
 (0)