@@ -169,13 +169,44 @@ func TestCommitSweepResolverNoDelay(t *testing.T) {
169
169
}
170
170
171
171
ctx := newCommitSweepResolverTestContext (t , & res )
172
+
173
+ // Replace our checkpoint with one which will push reports into a
174
+ // channel for us to consume. We replace this function on the resolver
175
+ // itself because it is created by the test context.
176
+ reportChan := make (chan * channeldb.ResolverReport )
177
+ ctx .resolver .Checkpoint = func (_ ContractResolver ,
178
+ reports ... * channeldb.ResolverReport ) error {
179
+
180
+ // Send all of our reports into the channel.
181
+ for _ , report := range reports {
182
+ reportChan <- report
183
+ }
184
+
185
+ return nil
186
+ }
187
+
172
188
ctx .resolve ()
173
189
174
- ctx .notifier .confChan <- & chainntnfs.TxConfirmation {}
190
+ spendTx := & wire.MsgTx {}
191
+ spendHash := spendTx .TxHash ()
192
+ ctx .notifier .confChan <- & chainntnfs.TxConfirmation {
193
+ Tx : spendTx ,
194
+ }
175
195
176
196
// No csv delay, so the input should be swept immediately.
177
197
<- ctx .sweeper .sweptInputs
178
198
199
+ amt := btcutil .Amount (res .SelfOutputSignDesc .Output .Value )
200
+ expectedReport := & channeldb.ResolverReport {
201
+ OutPoint : wire.OutPoint {},
202
+ Amount : amt ,
203
+ ResolverType : channeldb .ResolverTypeCommit ,
204
+ ResolverOutcome : channeldb .ResolverOutcomeClaimed ,
205
+ SpendTxID : & spendHash ,
206
+ }
207
+
208
+ assertResolverReport (t , reportChan , expectedReport )
209
+
179
210
ctx .waitForResult ()
180
211
}
181
212
@@ -203,6 +234,21 @@ func testCommitSweepResolverDelay(t *testing.T, sweepErr error) {
203
234
204
235
ctx := newCommitSweepResolverTestContext (t , & res )
205
236
237
+ // Replace our checkpoint with one which will push reports into a
238
+ // channel for us to consume. We replace this function on the resolver
239
+ // itself because it is created by the test context.
240
+ reportChan := make (chan * channeldb.ResolverReport )
241
+ ctx .resolver .Checkpoint = func (_ ContractResolver ,
242
+ reports ... * channeldb.ResolverReport ) error {
243
+
244
+ // Send all of our reports into the channel.
245
+ for _ , report := range reports {
246
+ reportChan <- report
247
+ }
248
+
249
+ return nil
250
+ }
251
+
206
252
// Setup whether we expect the sweeper to receive a sweep error in this
207
253
// test case.
208
254
ctx .sweeper .sweepErr = sweepErr
@@ -250,6 +296,22 @@ func testCommitSweepResolverDelay(t *testing.T, sweepErr error) {
250
296
251
297
<- ctx .sweeper .sweptInputs
252
298
299
+ // Set the resolution report outcome based on whether our sweep
300
+ // succeeded.
301
+ outcome := channeldb .ResolverOutcomeClaimed
302
+ if sweepErr != nil {
303
+ outcome = channeldb .ResolverOutcomeUnclaimed
304
+ }
305
+ sweepTx := ctx .sweeper .sweepTx .TxHash ()
306
+
307
+ assertResolverReport (t , reportChan , & channeldb.ResolverReport {
308
+ OutPoint : outpoint ,
309
+ ResolverType : channeldb .ResolverTypeCommit ,
310
+ ResolverOutcome : outcome ,
311
+ Amount : btcutil .Amount (amt ),
312
+ SpendTxID : & sweepTx ,
313
+ })
314
+
253
315
ctx .waitForResult ()
254
316
255
317
// If this test case generates a sweep error, we don't expect to be
0 commit comments