@@ -3,11 +3,13 @@ package itest
33import (
44 "context"
55 "fmt"
6+ "testing"
67
78 "github.com/btcsuite/btcd/chaincfg/chainhash"
89 "github.com/btcsuite/btcd/wire"
910 "github.com/lightningnetwork/lnd/channeldb"
1011 "github.com/lightningnetwork/lnd/lnrpc"
12+ "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
1113 "github.com/lightningnetwork/lnd/lntest"
1214 "github.com/lightningnetwork/lnd/lntest/wait"
1315 "github.com/stretchr/testify/require"
@@ -172,9 +174,11 @@ func assertChannelClosed(ctx context.Context, t *harnessTest,
172174 // block.
173175 block := mineBlocks (t , net , 1 , 1 )[0 ]
174176
175- closingTxid , err := net .WaitForChannelClose (closeUpdates )
177+ closingUpdate , err := net .WaitForChannelClose (closeUpdates )
176178 require .NoError (t .t , err , "error while waiting for channel close" )
177179
180+ closingTxid , err := chainhash .NewHash (closingUpdate .ClosingTxid )
181+ require .NoError (t .t , err )
178182 assertTxInBlock (t , block , closingTxid )
179183
180184 // Finally, the transaction should no longer be in the waiting close
@@ -203,3 +207,27 @@ func assertChannelClosed(ctx context.Context, t *harnessTest,
203207
204208 return closingTxid
205209}
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