Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

itest: expect failure on direct rfq peer btc invoices #916

Closed
Prev Previous commit
Next Next commit
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>
  • Loading branch information
4 people committed Dec 16, 2024
commit da30b3d4b9a9a932a3bbd201e3dbd4b6e51ecc8c
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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
@@ -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
46 changes: 41 additions & 5 deletions itest/assertions.go
Original file line number Diff line number Diff line change
@@ -3,14 +3,18 @@ package itest
import (
"context"
"fmt"
"testing"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightninglabs/taproot-assets/taprpc"
"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"
"google.golang.org/protobuf/proto"
)

// shutdownAndAssert shuts down the given node and asserts that no errors
@@ -172,24 +176,25 @@ 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
// state as we've just mined a block that should include the closing
// transaction.
err = wait.Predicate(func() bool {
pendingChansRequest := &lnrpc.PendingChannelsRequest{}
pendingChanResp, err := node.PendingChannels(
ctx, pendingChansRequest,
resp, err := node.PendingChannels(
ctx, &lnrpc.PendingChannelsRequest{},
)
if err != nil {
return false
}

for _, pendingClose := range pendingChanResp.WaitingCloseChannels {
for _, pendingClose := range resp.WaitingCloseChannels {
if pendingClose.Channel.ChannelPoint == chanPointStr {
return false
}
@@ -203,3 +208,34 @@ 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)
}

func toProtoJSON(t *testing.T, resp proto.Message) string {
jsonBytes, err := taprpc.ProtoJSONMarshalOpts.Marshal(resp)
require.NoError(t, err)

return string(jsonBytes)
}
Loading