Skip to content

Commit

Permalink
itest: add custom channel integration test
Browse files Browse the repository at this point in the history
Co-authored-by: Olaoluwa Osuntokun <[email protected]>
Co-authored-by: Gijs van Dam <[email protected]>
Co-authored-by: George Tsagkarelis <[email protected]>
  • Loading branch information
4 people committed Dec 6, 2024
1 parent bf46217 commit b2e1314
Show file tree
Hide file tree
Showing 11 changed files with 6,050 additions and 10 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c
github.com/btcsuite/btcwallet/walletdb v1.4.4
github.com/davecgh/go-spew v1.1.1
github.com/go-errors/errors v1.0.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0
github.com/improbable-eng/grpc-web v0.12.0
Expand Down Expand Up @@ -35,6 +36,7 @@ require (
github.com/urfave/cli v1.22.9
go.etcd.io/bbolt v1.3.11
golang.org/x/crypto v0.25.0
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
golang.org/x/net v0.27.0
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.65.0
Expand Down Expand Up @@ -73,7 +75,6 @@ require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/decred/dcrd/lru v1.1.2 // indirect
Expand Down Expand Up @@ -201,7 +202,6 @@ require (
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
Expand Down
30 changes: 29 additions & 1 deletion itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package itest
import (
"context"
"fmt"
"testing"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/lntest"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -172,9 +174,11 @@ func assertChannelClosed(ctx context.Context, t *harnessTest,
// block.
block := mineBlocks(t, net, 1, 1)[0]

closingTxid, err := net.WaitForChannelClose(closeUpdates)
closingUpdate, err := net.WaitForChannelClose(closeUpdates)
require.NoError(t.t, err, "error while waiting for channel close")

closingTxid, err := chainhash.NewHash(closingUpdate.ClosingTxid)
require.NoError(t.t, err)
assertTxInBlock(t, block, closingTxid)

// Finally, the transaction should no longer be in the waiting close
Expand Down Expand Up @@ -203,3 +207,27 @@ func assertChannelClosed(ctx context.Context, t *harnessTest,

return closingTxid
}

func assertSweepExists(t *testing.T, node *HarnessNode,
witnessType walletrpc.WitnessType) {

ctxb := context.Background()
err := wait.NoError(func() error {
pendingSweeps, err := node.WalletKitClient.PendingSweeps(
ctxb, &walletrpc.PendingSweepsRequest{},
)
if err != nil {
return err
}

for _, sweep := range pendingSweeps.PendingSweeps {
if sweep.WitnessType == witnessType {
return nil
}
}

return fmt.Errorf("failed to find second level sweep: %v",
toProtoJSON(t, pendingSweeps))
}, defaultTimeout)
require.NoError(t, err)
}
Loading

0 comments on commit b2e1314

Please sign in to comment.