Skip to content

Commit 29f0580

Browse files
guggeroRoasbeefgijswijsGeorgeTsagk
committed
itest: add custom channel integration test
Co-authored-by: Olaoluwa Osuntokun <laolu32@gmail.com> Co-authored-by: Gijs van Dam <gijs@lightning.engineering> Co-authored-by: George Tsagkarelis <george.tsagkarelis@gmail.com>
1 parent 7cbca11 commit 29f0580

11 files changed

+5830
-10
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
88
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c
99
github.com/btcsuite/btcwallet/walletdb v1.4.4
10+
github.com/davecgh/go-spew v1.1.1
1011
github.com/go-errors/errors v1.0.1
1112
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0
1213
github.com/improbable-eng/grpc-web v0.12.0
@@ -35,6 +36,7 @@ require (
3536
github.com/urfave/cli v1.22.9
3637
go.etcd.io/bbolt v1.3.11
3738
golang.org/x/crypto v0.25.0
39+
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
3840
golang.org/x/net v0.27.0
3941
golang.org/x/sync v0.8.0
4042
google.golang.org/grpc v1.65.0
@@ -73,7 +75,6 @@ require (
7375
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
7476
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
7577
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
76-
github.com/davecgh/go-spew v1.1.1 // indirect
7778
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
7879
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
7980
github.com/decred/dcrd/lru v1.1.2 // indirect
@@ -201,7 +202,6 @@ require (
201202
go.uber.org/mock v0.4.0 // indirect
202203
go.uber.org/multierr v1.6.0 // indirect
203204
go.uber.org/zap v1.23.0 // indirect
204-
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
205205
golang.org/x/mod v0.17.0 // indirect
206206
golang.org/x/sys v0.22.0 // indirect
207207
golang.org/x/term v0.22.0 // indirect

itest/assertions.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ package itest
33
import (
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

Comments
 (0)