@@ -3,11 +3,13 @@ package itest
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "testing"
6
7
7
8
"github.com/btcsuite/btcd/chaincfg/chainhash"
8
9
"github.com/btcsuite/btcd/wire"
9
10
"github.com/lightningnetwork/lnd/channeldb"
10
11
"github.com/lightningnetwork/lnd/lnrpc"
12
+ "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
11
13
"github.com/lightningnetwork/lnd/lntest"
12
14
"github.com/lightningnetwork/lnd/lntest/wait"
13
15
"github.com/stretchr/testify/require"
@@ -172,9 +174,11 @@ func assertChannelClosed(ctx context.Context, t *harnessTest,
172
174
// block.
173
175
block := mineBlocks (t , net , 1 , 1 )[0 ]
174
176
175
- closingTxid , err := net .WaitForChannelClose (closeUpdates )
177
+ closingUpdate , err := net .WaitForChannelClose (closeUpdates )
176
178
require .NoError (t .t , err , "error while waiting for channel close" )
177
179
180
+ closingTxid , err := chainhash .NewHash (closingUpdate .ClosingTxid )
181
+ require .NoError (t .t , err )
178
182
assertTxInBlock (t , block , closingTxid )
179
183
180
184
// Finally, the transaction should no longer be in the waiting close
@@ -203,3 +207,27 @@ func assertChannelClosed(ctx context.Context, t *harnessTest,
203
207
204
208
return closingTxid
205
209
}
210
+
211
+ func assertSweepExists (t * testing.T , node * HarnessNode ,
212
+ witnessType walletrpc.WitnessType ) {
213
+
214
+ ctxb := context .Background ()
215
+ err := wait .NoError (func () error {
216
+ pendingSweeps , err := node .WalletKitClient .PendingSweeps (
217
+ ctxb , & walletrpc.PendingSweepsRequest {},
218
+ )
219
+ if err != nil {
220
+ return err
221
+ }
222
+
223
+ for _ , sweep := range pendingSweeps .PendingSweeps {
224
+ if sweep .WitnessType == witnessType {
225
+ return nil
226
+ }
227
+ }
228
+
229
+ return fmt .Errorf ("failed to find second level sweep: %v" ,
230
+ toProtoJSON (t , pendingSweeps ))
231
+ }, defaultTimeout )
232
+ require .NoError (t , err )
233
+ }
0 commit comments