itest+lntest: migrate lntemp to lntest
This commit performs the takeover that `lntemp` is now promoted to be `lntest`, and the scaffolding is now removed as all the refactoring is finished!
This commit is contained in:
76 files changed
+590
-584
No files matched your search
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
package itest
|
package itest
|
||||||
|
|
||||||
import "github.com/lightningnetwork/lnd/lntemp"
|
import "github.com/lightningnetwork/lnd/lntest"
|
||||||
|
|
||||||
var allTestCases = []*lntemp.TestCase{}
|
var allTestCases = []*lntest.TestCase{}
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
package itest
|
package itest
|
||||||
|
|
||||||
import "github.com/lightningnetwork/lnd/lntemp"
|
import "github.com/lightningnetwork/lnd/lntest"
|
||||||
|
|
||||||
var allTestCases = []*lntemp.TestCase{
|
var allTestCases = []*lntest.TestCase{
|
||||||
{
|
{
|
||||||
Name: "update channel status",
|
Name: "update channel status",
|
||||||
TestFunc: testUpdateChanStatus,
|
TestFunc: testUpdateChanStatus,
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testSendPaymentAMPInvoice tests that we can send an AMP payment to a
|
// testSendPaymentAMPInvoice tests that we can send an AMP payment to a
|
||||||
// specified AMP invoice using SendPaymentV2.
|
// specified AMP invoice using SendPaymentV2.
|
||||||
func testSendPaymentAMPInvoice(ht *lntemp.HarnessTest) {
|
func testSendPaymentAMPInvoice(ht *lntest.HarnessTest) {
|
||||||
succeed := ht.Run("native payaddr", func(t *testing.T) {
|
succeed := ht.Run("native payaddr", func(t *testing.T) {
|
||||||
tt := ht.Subtest(t)
|
tt := ht.Subtest(t)
|
||||||
testSendPaymentAMPInvoiceCase(tt, false)
|
testSendPaymentAMPInvoiceCase(tt, false)
|
||||||
@@ -36,7 +36,7 @@ func testSendPaymentAMPInvoice(ht *lntemp.HarnessTest) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSendPaymentAMPInvoiceCase(ht *lntemp.HarnessTest,
|
func testSendPaymentAMPInvoiceCase(ht *lntest.HarnessTest,
|
||||||
useExternalPayAddr bool) {
|
useExternalPayAddr bool) {
|
||||||
|
|
||||||
mts := newMppTestScenario(ht)
|
mts := newMppTestScenario(ht)
|
||||||
@@ -196,7 +196,7 @@ func testSendPaymentAMPInvoiceCase(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testSendPaymentAMPInvoiceRepeat tests that it's possible to pay an AMP
|
// testSendPaymentAMPInvoiceRepeat tests that it's possible to pay an AMP
|
||||||
// invoice multiple times by having the client generate a new setID each time.
|
// invoice multiple times by having the client generate a new setID each time.
|
||||||
func testSendPaymentAMPInvoiceRepeat(ht *lntemp.HarnessTest) {
|
func testSendPaymentAMPInvoiceRepeat(ht *lntest.HarnessTest) {
|
||||||
// In this basic test, we'll only need two nodes as we want to
|
// In this basic test, we'll only need two nodes as we want to
|
||||||
// primarily test the recurring payment feature. So we'll re-use the
|
// primarily test the recurring payment feature. So we'll re-use the
|
||||||
carol := ht.NewNode("Carol", nil)
|
carol := ht.NewNode("Carol", nil)
|
||||||
@@ -218,7 +218,7 @@ func testSendPaymentAMPInvoiceRepeat(ht *lntemp.HarnessTest) {
|
|||||||
// Establish a channel between Carol and Dave.
|
// Establish a channel between Carol and Dave.
|
||||||
chanAmt := btcutil.Amount(100_000)
|
chanAmt := btcutil.Amount(100_000)
|
||||||
ht.OpenChannel(
|
ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{Amt: chanAmt},
|
carol, dave, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create an AMP invoice of a trivial amount, that we'll pay repeatedly
|
// Create an AMP invoice of a trivial amount, that we'll pay repeatedly
|
||||||
@@ -353,7 +353,7 @@ func testSendPaymentAMPInvoiceRepeat(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testSendPaymentAMP tests that we can send an AMP payment to a specified
|
// testSendPaymentAMP tests that we can send an AMP payment to a specified
|
||||||
// destination using SendPaymentV2.
|
// destination using SendPaymentV2.
|
||||||
func testSendPaymentAMP(ht *lntemp.HarnessTest) {
|
func testSendPaymentAMP(ht *lntest.HarnessTest) {
|
||||||
mts := newMppTestScenario(ht)
|
mts := newMppTestScenario(ht)
|
||||||
const paymentAmt = btcutil.Amount(300000)
|
const paymentAmt = btcutil.Amount(300000)
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ func testSendPaymentAMP(ht *lntemp.HarnessTest) {
|
|||||||
mts.closeChannels()
|
mts.closeChannels()
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSendToRouteAMP(ht *lntemp.HarnessTest) {
|
func testSendToRouteAMP(ht *lntest.HarnessTest) {
|
||||||
mts := newMppTestScenario(ht)
|
mts := newMppTestScenario(ht)
|
||||||
const (
|
const (
|
||||||
paymentAmt = btcutil.Amount(300000)
|
paymentAmt = btcutil.Amount(300000)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -34,7 +34,7 @@ type (
|
|||||||
// that'll return the same node, but with its state restored via a
|
// that'll return the same node, but with its state restored via a
|
||||||
// custom method. We use this to abstract away _how_ a node is restored
|
// custom method. We use this to abstract away _how_ a node is restored
|
||||||
// from our assertions once the node has been fully restored itself.
|
// from our assertions once the node has been fully restored itself.
|
||||||
restoreMethodType func(ht *lntemp.HarnessTest,
|
restoreMethodType func(ht *lntest.HarnessTest,
|
||||||
oldNode *node.HarnessNode, backupFilePath string,
|
oldNode *node.HarnessNode, backupFilePath string,
|
||||||
password []byte, mnemonic []string) nodeRestorer
|
password []byte, mnemonic []string) nodeRestorer
|
||||||
)
|
)
|
||||||
@@ -50,12 +50,12 @@ type chanRestoreScenario struct {
|
|||||||
dave *node.HarnessNode
|
dave *node.HarnessNode
|
||||||
password []byte
|
password []byte
|
||||||
mnemonic []string
|
mnemonic []string
|
||||||
params lntemp.OpenChannelParams
|
params lntest.OpenChannelParams
|
||||||
}
|
}
|
||||||
|
|
||||||
// newChanRestoreScenario creates a new scenario that has two nodes, Carol and
|
// newChanRestoreScenario creates a new scenario that has two nodes, Carol and
|
||||||
// Dave, connected and funded.
|
// Dave, connected and funded.
|
||||||
func newChanRestoreScenario(ht *lntemp.HarnessTest, ct lnrpc.CommitmentType,
|
func newChanRestoreScenario(ht *lntest.HarnessTest, ct lnrpc.CommitmentType,
|
||||||
zeroConf bool) *chanRestoreScenario {
|
zeroConf bool) *chanRestoreScenario {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -70,7 +70,7 @@ func newChanRestoreScenario(ht *lntemp.HarnessTest, ct lnrpc.CommitmentType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ct != lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE {
|
if ct != lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE {
|
||||||
args := lntemp.NodeArgsForCommitType(ct)
|
args := lntest.NodeArgsForCommitType(ct)
|
||||||
nodeArgs = append(nodeArgs, args...)
|
nodeArgs = append(nodeArgs, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ func newChanRestoreScenario(ht *lntemp.HarnessTest, ct lnrpc.CommitmentType,
|
|||||||
|
|
||||||
// For the anchor output case we need two UTXOs for Carol so she can
|
// For the anchor output case we need two UTXOs for Carol so she can
|
||||||
// sweep both the local and remote anchor.
|
// sweep both the local and remote anchor.
|
||||||
if lntemp.CommitTypeHasAnchors(ct) {
|
if lntest.CommitTypeHasAnchors(ct) {
|
||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ func newChanRestoreScenario(ht *lntemp.HarnessTest, ct lnrpc.CommitmentType,
|
|||||||
dave: dave,
|
dave: dave,
|
||||||
mnemonic: mnemonic,
|
mnemonic: mnemonic,
|
||||||
password: password,
|
password: password,
|
||||||
params: lntemp.OpenChannelParams{
|
params: lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
ZeroConf: zeroConf,
|
ZeroConf: zeroConf,
|
||||||
@@ -123,7 +123,7 @@ func newChanRestoreScenario(ht *lntemp.HarnessTest, ct lnrpc.CommitmentType,
|
|||||||
|
|
||||||
// restoreDave will call the `nodeRestorer` and asserts Dave is restored by
|
// restoreDave will call the `nodeRestorer` and asserts Dave is restored by
|
||||||
// checking his wallet balance against zero.
|
// checking his wallet balance against zero.
|
||||||
func (c *chanRestoreScenario) restoreDave(ht *lntemp.HarnessTest,
|
func (c *chanRestoreScenario) restoreDave(ht *lntest.HarnessTest,
|
||||||
restoredNodeFunc nodeRestorer) *node.HarnessNode {
|
restoredNodeFunc nodeRestorer) *node.HarnessNode {
|
||||||
|
|
||||||
// Next, we'll make a new Dave and start the bulk of our recovery
|
// Next, we'll make a new Dave and start the bulk of our recovery
|
||||||
@@ -154,7 +154,7 @@ func (c *chanRestoreScenario) restoreDave(ht *lntemp.HarnessTest,
|
|||||||
// 4. validate pending channel state and check we cannot force close it.
|
// 4. validate pending channel state and check we cannot force close it.
|
||||||
// 5. validate Carol's UTXOs.
|
// 5. validate Carol's UTXOs.
|
||||||
// 6. assert DLP is executed.
|
// 6. assert DLP is executed.
|
||||||
func (c *chanRestoreScenario) testScenario(ht *lntemp.HarnessTest,
|
func (c *chanRestoreScenario) testScenario(ht *lntest.HarnessTest,
|
||||||
restoredNodeFunc nodeRestorer) {
|
restoredNodeFunc nodeRestorer) {
|
||||||
|
|
||||||
carol, dave := c.carol, c.dave
|
carol, dave := c.carol, c.dave
|
||||||
@@ -212,7 +212,7 @@ func (c *chanRestoreScenario) testScenario(ht *lntemp.HarnessTest,
|
|||||||
// let's start up Carol again.
|
// let's start up Carol again.
|
||||||
require.NoError(ht, restartCarol(), "restart carol failed")
|
require.NoError(ht, restartCarol(), "restart carol failed")
|
||||||
|
|
||||||
if lntemp.CommitTypeHasAnchors(c.params.CommitmentType) {
|
if lntest.CommitTypeHasAnchors(c.params.CommitmentType) {
|
||||||
ht.AssertNumUTXOs(carol, 2)
|
ht.AssertNumUTXOs(carol, 2)
|
||||||
} else {
|
} else {
|
||||||
ht.AssertNumUTXOs(carol, 1)
|
ht.AssertNumUTXOs(carol, 1)
|
||||||
@@ -232,7 +232,7 @@ func (c *chanRestoreScenario) testScenario(ht *lntemp.HarnessTest,
|
|||||||
// restoring from initial wallet creation. We'll also alternate between
|
// restoring from initial wallet creation. We'll also alternate between
|
||||||
// restoring form the on disk file, and restoring from the exported RPC command
|
// restoring form the on disk file, and restoring from the exported RPC command
|
||||||
// as well.
|
// as well.
|
||||||
func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
|
func testChannelBackupRestoreBasic(ht *lntest.HarnessTest) {
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
name string
|
name string
|
||||||
restoreMethod restoreMethodType
|
restoreMethod restoreMethodType
|
||||||
@@ -241,7 +241,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
|
|||||||
// was the initiator, of the non-advertised channel.
|
// was the initiator, of the non-advertised channel.
|
||||||
{
|
{
|
||||||
name: "restore from RPC backup",
|
name: "restore from RPC backup",
|
||||||
restoreMethod: func(st *lntemp.HarnessTest,
|
restoreMethod: func(st *lntest.HarnessTest,
|
||||||
oldNode *node.HarnessNode,
|
oldNode *node.HarnessNode,
|
||||||
backupFilePath string,
|
backupFilePath string,
|
||||||
password []byte,
|
password []byte,
|
||||||
@@ -269,7 +269,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
|
|||||||
// interface.
|
// interface.
|
||||||
{
|
{
|
||||||
name: "restore from backup file",
|
name: "restore from backup file",
|
||||||
restoreMethod: func(st *lntemp.HarnessTest,
|
restoreMethod: func(st *lntest.HarnessTest,
|
||||||
oldNode *node.HarnessNode,
|
oldNode *node.HarnessNode,
|
||||||
backupFilePath string,
|
backupFilePath string,
|
||||||
password []byte,
|
password []byte,
|
||||||
@@ -293,7 +293,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
|
|||||||
// prior mnemonic and new backup seed.
|
// prior mnemonic and new backup seed.
|
||||||
{
|
{
|
||||||
name: "restore during creation",
|
name: "restore during creation",
|
||||||
restoreMethod: func(st *lntemp.HarnessTest,
|
restoreMethod: func(st *lntest.HarnessTest,
|
||||||
oldNode *node.HarnessNode,
|
oldNode *node.HarnessNode,
|
||||||
backupFilePath string,
|
backupFilePath string,
|
||||||
password []byte,
|
password []byte,
|
||||||
@@ -325,7 +325,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
|
|||||||
// re-created, using the Unlock call.
|
// re-created, using the Unlock call.
|
||||||
{
|
{
|
||||||
name: "restore during unlock",
|
name: "restore during unlock",
|
||||||
restoreMethod: func(st *lntemp.HarnessTest,
|
restoreMethod: func(st *lntest.HarnessTest,
|
||||||
oldNode *node.HarnessNode,
|
oldNode *node.HarnessNode,
|
||||||
backupFilePath string,
|
backupFilePath string,
|
||||||
password []byte,
|
password []byte,
|
||||||
@@ -362,7 +362,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
|
|||||||
// make sure imports can be canceled and later resumed.
|
// make sure imports can be canceled and later resumed.
|
||||||
{
|
{
|
||||||
name: "restore from backup file twice",
|
name: "restore from backup file twice",
|
||||||
restoreMethod: func(st *lntemp.HarnessTest,
|
restoreMethod: func(st *lntest.HarnessTest,
|
||||||
oldNode *node.HarnessNode,
|
oldNode *node.HarnessNode,
|
||||||
backupFilePath string,
|
backupFilePath string,
|
||||||
password []byte,
|
password []byte,
|
||||||
@@ -420,7 +420,7 @@ func testChannelBackupRestoreBasic(ht *lntemp.HarnessTest) {
|
|||||||
// ensuring that after Dave restores his channel state according to the
|
// ensuring that after Dave restores his channel state according to the
|
||||||
// testCase, the DLP protocol is executed properly and both nodes are made
|
// testCase, the DLP protocol is executed properly and both nodes are made
|
||||||
// whole.
|
// whole.
|
||||||
func runChanRestoreScenarioBasic(ht *lntemp.HarnessTest,
|
func runChanRestoreScenarioBasic(ht *lntest.HarnessTest,
|
||||||
restoreMethod restoreMethodType) {
|
restoreMethod restoreMethodType) {
|
||||||
|
|
||||||
// Create a new retore scenario.
|
// Create a new retore scenario.
|
||||||
@@ -445,7 +445,7 @@ func runChanRestoreScenarioBasic(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testChannelBackupRestoreUnconfirmed tests that we're able to restore from
|
// testChannelBackupRestoreUnconfirmed tests that we're able to restore from
|
||||||
// disk file and the exported RPC command for unconfirmed channel.
|
// disk file and the exported RPC command for unconfirmed channel.
|
||||||
func testChannelBackupRestoreUnconfirmed(ht *lntemp.HarnessTest) {
|
func testChannelBackupRestoreUnconfirmed(ht *lntest.HarnessTest) {
|
||||||
// Use the channel backup file that contains an unconfirmed channel and
|
// Use the channel backup file that contains an unconfirmed channel and
|
||||||
// make sure recovery works as well.
|
// make sure recovery works as well.
|
||||||
ht.Run("restore unconfirmed channel file", func(t *testing.T) {
|
ht.Run("restore unconfirmed channel file", func(t *testing.T) {
|
||||||
@@ -463,7 +463,7 @@ func testChannelBackupRestoreUnconfirmed(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// runChanRestoreScenarioUnConfirmed checks that Dave is able to restore for an
|
// runChanRestoreScenarioUnConfirmed checks that Dave is able to restore for an
|
||||||
// unconfirmed channel.
|
// unconfirmed channel.
|
||||||
func runChanRestoreScenarioUnConfirmed(ht *lntemp.HarnessTest, useFile bool) {
|
func runChanRestoreScenarioUnConfirmed(ht *lntest.HarnessTest, useFile bool) {
|
||||||
// Create a new retore scenario.
|
// Create a new retore scenario.
|
||||||
crs := newChanRestoreScenario(
|
crs := newChanRestoreScenario(
|
||||||
ht, lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE, false,
|
ht, lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE, false,
|
||||||
@@ -527,7 +527,7 @@ func runChanRestoreScenarioUnConfirmed(ht *lntemp.HarnessTest, useFile bool) {
|
|||||||
// testChannelBackupRestoreCommitTypes tests that we're able to recover from,
|
// testChannelBackupRestoreCommitTypes tests that we're able to recover from,
|
||||||
// and initiate the DLP protocol for different channel commitment types and
|
// and initiate the DLP protocol for different channel commitment types and
|
||||||
// zero-conf channel.
|
// zero-conf channel.
|
||||||
func testChannelBackupRestoreCommitTypes(ht *lntemp.HarnessTest) {
|
func testChannelBackupRestoreCommitTypes(ht *lntest.HarnessTest) {
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
name string
|
name string
|
||||||
ct lnrpc.CommitmentType
|
ct lnrpc.CommitmentType
|
||||||
@@ -584,7 +584,7 @@ func testChannelBackupRestoreCommitTypes(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// runChanRestoreScenarioCommitTypes tests that the DLP is applied for
|
// runChanRestoreScenarioCommitTypes tests that the DLP is applied for
|
||||||
// different channel commitment types and zero-conf channel.
|
// different channel commitment types and zero-conf channel.
|
||||||
func runChanRestoreScenarioCommitTypes(ht *lntemp.HarnessTest,
|
func runChanRestoreScenarioCommitTypes(ht *lntest.HarnessTest,
|
||||||
ct lnrpc.CommitmentType, zeroConf bool) {
|
ct lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// Create a new retore scenario.
|
// Create a new retore scenario.
|
||||||
@@ -639,7 +639,7 @@ func runChanRestoreScenarioCommitTypes(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testChannelBackupRestoreLegacy checks a channel with the legacy revocation
|
// testChannelBackupRestoreLegacy checks a channel with the legacy revocation
|
||||||
// producer format and makes sure old SCBs can still be recovered.
|
// producer format and makes sure old SCBs can still be recovered.
|
||||||
func testChannelBackupRestoreLegacy(ht *lntemp.HarnessTest) {
|
func testChannelBackupRestoreLegacy(ht *lntest.HarnessTest) {
|
||||||
// Create a new retore scenario.
|
// Create a new retore scenario.
|
||||||
crs := newChanRestoreScenario(
|
crs := newChanRestoreScenario(
|
||||||
ht, lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE, false,
|
ht, lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE, false,
|
||||||
@@ -668,7 +668,7 @@ func testChannelBackupRestoreLegacy(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testChannelBackupRestoreForceClose checks that Dave can restore from force
|
// testChannelBackupRestoreForceClose checks that Dave can restore from force
|
||||||
// closed channels.
|
// closed channels.
|
||||||
func testChannelBackupRestoreForceClose(ht *lntemp.HarnessTest) {
|
func testChannelBackupRestoreForceClose(ht *lntest.HarnessTest) {
|
||||||
// Restore a channel that was force closed by dave just before going
|
// Restore a channel that was force closed by dave just before going
|
||||||
// offline.
|
// offline.
|
||||||
success := ht.Run("from backup file anchors", func(t *testing.T) {
|
success := ht.Run("from backup file anchors", func(t *testing.T) {
|
||||||
@@ -691,7 +691,7 @@ func testChannelBackupRestoreForceClose(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// runChanRestoreScenarioForceClose creates anchor-enabled force close channels
|
// runChanRestoreScenarioForceClose creates anchor-enabled force close channels
|
||||||
// and checks that Dave is able to restore from them.
|
// and checks that Dave is able to restore from them.
|
||||||
func runChanRestoreScenarioForceClose(ht *lntemp.HarnessTest, zeroConf bool) {
|
func runChanRestoreScenarioForceClose(ht *lntest.HarnessTest, zeroConf bool) {
|
||||||
crs := newChanRestoreScenario(
|
crs := newChanRestoreScenario(
|
||||||
ht, lnrpc.CommitmentType_ANCHORS, zeroConf,
|
ht, lnrpc.CommitmentType_ANCHORS, zeroConf,
|
||||||
)
|
)
|
||||||
@@ -792,7 +792,7 @@ func runChanRestoreScenarioForceClose(ht *lntemp.HarnessTest, zeroConf bool) {
|
|||||||
// testChannelBackupUpdates tests that both the streaming channel update RPC,
|
// testChannelBackupUpdates tests that both the streaming channel update RPC,
|
||||||
// and the on-disk channel.backup are updated each time a channel is
|
// and the on-disk channel.backup are updated each time a channel is
|
||||||
// opened/closed.
|
// opened/closed.
|
||||||
func testChannelBackupUpdates(ht *lntemp.HarnessTest) {
|
func testChannelBackupUpdates(ht *lntest.HarnessTest) {
|
||||||
alice := ht.Alice
|
alice := ht.Alice
|
||||||
|
|
||||||
// First, we'll make a temp directory that we'll use to store our
|
// First, we'll make a temp directory that we'll use to store our
|
||||||
@@ -850,7 +850,7 @@ func testChannelBackupUpdates(ht *lntemp.HarnessTest) {
|
|||||||
chanAmt := btcutil.Amount(1000000)
|
chanAmt := btcutil.Amount(1000000)
|
||||||
for i := 0; i < numChans; i++ {
|
for i := 0; i < numChans; i++ {
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
chanPoints = append(chanPoints, chanPoint)
|
chanPoints = append(chanPoints, chanPoint)
|
||||||
}
|
}
|
||||||
@@ -962,7 +962,7 @@ func testChannelBackupUpdates(ht *lntemp.HarnessTest) {
|
|||||||
// testExportChannelBackup tests that we're able to properly export either a
|
// testExportChannelBackup tests that we're able to properly export either a
|
||||||
// targeted channel's backup, or export backups of all the currents open
|
// targeted channel's backup, or export backups of all the currents open
|
||||||
// channels.
|
// channels.
|
||||||
func testExportChannelBackup(ht *lntemp.HarnessTest) {
|
func testExportChannelBackup(ht *lntest.HarnessTest) {
|
||||||
// First, we'll create our primary test node: Carol. We'll use Carol to
|
// First, we'll create our primary test node: Carol. We'll use Carol to
|
||||||
// open channels and also export backups that we'll examine throughout
|
// open channels and also export backups that we'll examine throughout
|
||||||
// the test.
|
// the test.
|
||||||
@@ -979,7 +979,7 @@ func testExportChannelBackup(ht *lntemp.HarnessTest) {
|
|||||||
chanAmt := btcutil.Amount(1000000)
|
chanAmt := btcutil.Amount(1000000)
|
||||||
for i := 0; i < numChans; i++ {
|
for i := 0; i < numChans; i++ {
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
chanPoints = append(chanPoints, chanPoint)
|
chanPoints = append(chanPoints, chanPoint)
|
||||||
}
|
}
|
||||||
@@ -1086,7 +1086,7 @@ func testExportChannelBackup(ht *lntemp.HarnessTest) {
|
|||||||
// relationship lost state, they will detect this during channel sync, and the
|
// relationship lost state, they will detect this during channel sync, and the
|
||||||
// up-to-date party will force close the channel, giving the outdated party the
|
// up-to-date party will force close the channel, giving the outdated party the
|
||||||
// opportunity to sweep its output.
|
// opportunity to sweep its output.
|
||||||
func testDataLossProtection(ht *lntemp.HarnessTest) {
|
func testDataLossProtection(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = funding.MaxBtcFundingAmount
|
chanAmt = funding.MaxBtcFundingAmount
|
||||||
paymentAmt = 10000
|
paymentAmt = 10000
|
||||||
@@ -1122,7 +1122,7 @@ func testDataLossProtection(ht *lntemp.HarnessTest) {
|
|||||||
// We'll first open up a channel between them with a 0.5 BTC
|
// We'll first open up a channel between them with a 0.5 BTC
|
||||||
// value.
|
// value.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
carol, node, lntemp.OpenChannelParams{
|
carol, node, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -1255,7 +1255,7 @@ func testDataLossProtection(ht *lntemp.HarnessTest) {
|
|||||||
// createLegacyRevocationChannel creates a single channel using the legacy
|
// createLegacyRevocationChannel creates a single channel using the legacy
|
||||||
// revocation producer format by using PSBT to signal a special pending channel
|
// revocation producer format by using PSBT to signal a special pending channel
|
||||||
// ID.
|
// ID.
|
||||||
func createLegacyRevocationChannel(ht *lntemp.HarnessTest,
|
func createLegacyRevocationChannel(ht *lntest.HarnessTest,
|
||||||
chanAmt, pushAmt btcutil.Amount, from, to *node.HarnessNode) {
|
chanAmt, pushAmt btcutil.Amount, from, to *node.HarnessNode) {
|
||||||
|
|
||||||
// We'll signal to the wallet that we also want to create a channel
|
// We'll signal to the wallet that we also want to create a channel
|
||||||
@@ -1277,7 +1277,7 @@ func createLegacyRevocationChannel(ht *lntemp.HarnessTest,
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
openChannelReq := lntemp.OpenChannelParams{
|
openChannelReq := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
FundingShim: shim,
|
FundingShim: shim,
|
||||||
@@ -1345,7 +1345,7 @@ func createLegacyRevocationChannel(ht *lntemp.HarnessTest,
|
|||||||
// chanRestoreViaRPC is a helper test method that returns a nodeRestorer
|
// chanRestoreViaRPC is a helper test method that returns a nodeRestorer
|
||||||
// instance which will restore the target node from a password+seed, then
|
// instance which will restore the target node from a password+seed, then
|
||||||
// trigger a SCB restore using the RPC interface.
|
// trigger a SCB restore using the RPC interface.
|
||||||
func chanRestoreViaRPC(ht *lntemp.HarnessTest, password []byte,
|
func chanRestoreViaRPC(ht *lntest.HarnessTest, password []byte,
|
||||||
mnemonic []string, multi []byte,
|
mnemonic []string, multi []byte,
|
||||||
oldNode *node.HarnessNode) nodeRestorer {
|
oldNode *node.HarnessNode) nodeRestorer {
|
||||||
|
|
||||||
@@ -1382,7 +1382,7 @@ func copyPorts(oldNode *node.HarnessNode) node.Option {
|
|||||||
//
|
//
|
||||||
// Note: this function is only used in this test file and has been made
|
// Note: this function is only used in this test file and has been made
|
||||||
// specifically for testChanRestoreScenario.
|
// specifically for testChanRestoreScenario.
|
||||||
func assertTimeLockSwept(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode,
|
func assertTimeLockSwept(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
|
||||||
carolStartingBalance, daveStartingBalance int64) {
|
carolStartingBalance, daveStartingBalance int64) {
|
||||||
|
|
||||||
// We expect Carol to sweep her funds and also the anchor tx.
|
// We expect Carol to sweep her funds and also the anchor tx.
|
||||||
@@ -1450,7 +1450,7 @@ func assertTimeLockSwept(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode,
|
|||||||
// funds immediately, and Carol sweeping her fund after her CSV delay is up. If
|
// funds immediately, and Carol sweeping her fund after her CSV delay is up. If
|
||||||
// the blankSlate value is true, then this means that Dave won't need to sweep
|
// the blankSlate value is true, then this means that Dave won't need to sweep
|
||||||
// on chain as he has no funds in the channel.
|
// on chain as he has no funds in the channel.
|
||||||
func assertDLPExecuted(ht *lntemp.HarnessTest,
|
func assertDLPExecuted(ht *lntest.HarnessTest,
|
||||||
carol *node.HarnessNode, carolStartingBalance int64,
|
carol *node.HarnessNode, carolStartingBalance int64,
|
||||||
dave *node.HarnessNode, daveStartingBalance int64,
|
dave *node.HarnessNode, daveStartingBalance int64,
|
||||||
commitType lnrpc.CommitmentType) {
|
commitType lnrpc.CommitmentType) {
|
||||||
@@ -1467,7 +1467,7 @@ func assertDLPExecuted(ht *lntemp.HarnessTest,
|
|||||||
// Upon reconnection, the nodes should detect that Dave is out of sync.
|
// Upon reconnection, the nodes should detect that Dave is out of sync.
|
||||||
// Carol should force close the channel using her latest commitment.
|
// Carol should force close the channel using her latest commitment.
|
||||||
expectedTxes := 1
|
expectedTxes := 1
|
||||||
if lntemp.CommitTypeHasAnchors(commitType) {
|
if lntest.CommitTypeHasAnchors(commitType) {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
}
|
}
|
||||||
ht.Miner.AssertNumTxsInMempool(expectedTxes)
|
ht.Miner.AssertNumTxsInMempool(expectedTxes)
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
// testChannelBalance creates a new channel between Alice and Bob, then checks
|
// testChannelBalance creates a new channel between Alice and Bob, then checks
|
||||||
// channel balance to be equal amount specified while creation of channel.
|
// channel balance to be equal amount specified while creation of channel.
|
||||||
func testChannelBalance(ht *lntemp.HarnessTest) {
|
func testChannelBalance(ht *lntest.HarnessTest) {
|
||||||
// Open a channel with 0.16 BTC between Alice and Bob, ensuring the
|
// Open a channel with 0.16 BTC between Alice and Bob, ensuring the
|
||||||
// channel has been opened properly.
|
// channel has been opened properly.
|
||||||
amount := funding.MaxBtcFundingAmount
|
amount := funding.MaxBtcFundingAmount
|
||||||
@@ -52,16 +52,16 @@ func testChannelBalance(ht *lntemp.HarnessTest) {
|
|||||||
ht.EnsureConnected(alice, bob)
|
ht.EnsureConnected(alice, bob)
|
||||||
|
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: amount},
|
alice, bob, lntest.OpenChannelParams{Amt: amount},
|
||||||
)
|
)
|
||||||
cType := ht.GetChannelCommitType(alice, chanPoint)
|
cType := ht.GetChannelCommitType(alice, chanPoint)
|
||||||
|
|
||||||
// As this is a single funder channel, Alice's balance should be
|
// As this is a single funder channel, Alice's balance should be
|
||||||
// exactly 0.5 BTC since now state transitions have taken place yet.
|
// exactly 0.5 BTC since now state transitions have taken place yet.
|
||||||
checkChannelBalance(alice, amount-lntemp.CalcStaticFee(cType, 0), 0)
|
checkChannelBalance(alice, amount-lntest.CalcStaticFee(cType, 0), 0)
|
||||||
|
|
||||||
// Ensure Bob currently has no available balance within the channel.
|
// Ensure Bob currently has no available balance within the channel.
|
||||||
checkChannelBalance(bob, 0, amount-lntemp.CalcStaticFee(cType, 0))
|
checkChannelBalance(bob, 0, amount-lntest.CalcStaticFee(cType, 0))
|
||||||
|
|
||||||
// Finally close the channel between Alice and Bob, asserting that the
|
// Finally close the channel between Alice and Bob, asserting that the
|
||||||
// channel has been properly closed on-chain.
|
// channel has been properly closed on-chain.
|
||||||
@@ -73,7 +73,7 @@ func testChannelBalance(ht *lntemp.HarnessTest) {
|
|||||||
// Alice will send Htlcs to Carol while she is in hodl mode. This will result
|
// Alice will send Htlcs to Carol while she is in hodl mode. This will result
|
||||||
// in a build of pending Htlcs. We expect the channels unsettled balance to
|
// in a build of pending Htlcs. We expect the channels unsettled balance to
|
||||||
// equal the sum of all the Pending Htlcs.
|
// equal the sum of all the Pending Htlcs.
|
||||||
func testChannelUnsettledBalance(ht *lntemp.HarnessTest) {
|
func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = btcutil.Amount(1000000)
|
const chanAmt = btcutil.Amount(1000000)
|
||||||
|
|
||||||
// Creates a helper closure to be used below which asserts the proper
|
// Creates a helper closure to be used below which asserts the proper
|
||||||
@@ -123,20 +123,20 @@ func testChannelUnsettledBalance(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Open a channel between Alice and Carol.
|
// Open a channel between Alice and Carol.
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
cType := ht.GetChannelCommitType(alice, chanPointAlice)
|
cType := ht.GetChannelCommitType(alice, chanPointAlice)
|
||||||
|
|
||||||
// Check alice's channel balance, which should have zero remote and zero
|
// Check alice's channel balance, which should have zero remote and zero
|
||||||
// pending balance.
|
// pending balance.
|
||||||
checkChannelBalance(
|
checkChannelBalance(
|
||||||
alice, chanAmt-lntemp.CalcStaticFee(cType, 0), 0, 0, 0,
|
alice, chanAmt-lntest.CalcStaticFee(cType, 0), 0, 0, 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check carol's channel balance, which should have zero local and zero
|
// Check carol's channel balance, which should have zero local and zero
|
||||||
// pending balance.
|
// pending balance.
|
||||||
checkChannelBalance(
|
checkChannelBalance(
|
||||||
carol, 0, chanAmt-lntemp.CalcStaticFee(cType, 0), 0, 0,
|
carol, 0, chanAmt-lntest.CalcStaticFee(cType, 0), 0, 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Channel should be ready for payments.
|
// Channel should be ready for payments.
|
||||||
@@ -199,7 +199,7 @@ func testChannelUnsettledBalance(ht *lntemp.HarnessTest) {
|
|||||||
// Check alice's channel balance, which should have a remote unsettled
|
// Check alice's channel balance, which should have a remote unsettled
|
||||||
// balance that equals to the amount of invoices * payAmt. The remote
|
// balance that equals to the amount of invoices * payAmt. The remote
|
||||||
// balance remains zero.
|
// balance remains zero.
|
||||||
fee := lntemp.CalcStaticFee(cType, 0)
|
fee := lntest.CalcStaticFee(cType, 0)
|
||||||
aliceLocal := chanAmt - fee - numInvoices*payAmt
|
aliceLocal := chanAmt - fee - numInvoices*payAmt
|
||||||
checkChannelBalance(alice, aliceLocal, 0, 0, numInvoices*payAmt)
|
checkChannelBalance(alice, aliceLocal, 0, 0, numInvoices*payAmt)
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
@@ -30,7 +30,7 @@ import (
|
|||||||
//
|
//
|
||||||
// Note that whether the deadline is used or not is implicitly checked by its
|
// Note that whether the deadline is used or not is implicitly checked by its
|
||||||
// corresponding fee rates.
|
// corresponding fee rates.
|
||||||
func testCommitmentTransactionDeadline(ht *lntemp.HarnessTest) {
|
func testCommitmentTransactionDeadline(ht *lntest.HarnessTest) {
|
||||||
// Get the default max fee rate used in sweeping the commitment
|
// Get the default max fee rate used in sweeping the commitment
|
||||||
// transaction.
|
// transaction.
|
||||||
defaultMax := lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte
|
defaultMax := lnwallet.DefaultAnchorsCommitMaxFeeRateSatPerVByte
|
||||||
@@ -72,7 +72,7 @@ func testCommitmentTransactionDeadline(ht *lntemp.HarnessTest) {
|
|||||||
setupNode := func(name string) *node.HarnessNode {
|
setupNode := func(name string) *node.HarnessNode {
|
||||||
// Create the node.
|
// Create the node.
|
||||||
args := []string{"--hodl.exit-settle"}
|
args := []string{"--hodl.exit-settle"}
|
||||||
args = append(args, lntemp.NodeArgsForCommitType(
|
args = append(args, lntest.NodeArgsForCommitType(
|
||||||
lnrpc.CommitmentType_ANCHORS)...,
|
lnrpc.CommitmentType_ANCHORS)...,
|
||||||
)
|
)
|
||||||
node := ht.NewNode(name, args)
|
node := ht.NewNode(name, args)
|
||||||
@@ -104,7 +104,7 @@ func testCommitmentTransactionDeadline(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Open a channel between Alice and Bob.
|
// Open a channel between Alice and Bob.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: 10e6,
|
Amt: 10e6,
|
||||||
PushAmt: 5e6,
|
PushAmt: 5e6,
|
||||||
},
|
},
|
||||||
@@ -194,7 +194,7 @@ func testCommitmentTransactionDeadline(ht *lntemp.HarnessTest) {
|
|||||||
// process.
|
// process.
|
||||||
//
|
//
|
||||||
// TODO(roasbeef): also add an unsettled HTLC before force closing.
|
// TODO(roasbeef): also add an unsettled HTLC before force closing.
|
||||||
func testChannelForceClosure(ht *lntemp.HarnessTest) {
|
func testChannelForceClosure(ht *lntest.HarnessTest) {
|
||||||
// We'll test the scenario for some of the commitment types, to ensure
|
// We'll test the scenario for some of the commitment types, to ensure
|
||||||
// outputs can be swept.
|
// outputs can be swept.
|
||||||
commitTypes := []lnrpc.CommitmentType{
|
commitTypes := []lnrpc.CommitmentType{
|
||||||
@@ -209,7 +209,7 @@ func testChannelForceClosure(ht *lntemp.HarnessTest) {
|
|||||||
success := ht.Run(testName, func(t *testing.T) {
|
success := ht.Run(testName, func(t *testing.T) {
|
||||||
st := ht.Subtest(t)
|
st := ht.Subtest(t)
|
||||||
|
|
||||||
args := lntemp.NodeArgsForCommitType(channelType)
|
args := lntest.NodeArgsForCommitType(channelType)
|
||||||
alice := st.NewNode("Alice", args)
|
alice := st.NewNode("Alice", args)
|
||||||
defer st.Shutdown(alice)
|
defer st.Shutdown(alice)
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ func testChannelForceClosure(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func channelForceClosureTest(ht *lntemp.HarnessTest,
|
func channelForceClosureTest(ht *lntest.HarnessTest,
|
||||||
alice, carol *node.HarnessNode, channelType lnrpc.CommitmentType) {
|
alice, carol *node.HarnessNode, channelType lnrpc.CommitmentType) {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -268,7 +268,7 @@ func channelForceClosureTest(ht *lntemp.HarnessTest,
|
|||||||
carolStartingBalance := carolBalResp.ConfirmedBalance
|
carolStartingBalance := carolBalResp.ConfirmedBalance
|
||||||
|
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
},
|
},
|
||||||
@@ -600,6 +600,8 @@ func channelForceClosureTest(ht *lntemp.HarnessTest,
|
|||||||
// Update current height
|
// Update current height
|
||||||
_, curHeight = ht.Miner.GetBestBlock()
|
_, curHeight = ht.Miner.GetBestBlock()
|
||||||
|
|
||||||
|
// checkForceClosedChannelNumHtlcs verifies that a force closed channel
|
||||||
|
// has the proper number of htlcs.
|
||||||
err = wait.NoError(func() error {
|
err = wait.NoError(func() error {
|
||||||
// Now that the commit output has been fully swept, check to
|
// Now that the commit output has been fully swept, check to
|
||||||
// see that the channel remains open for the pending htlc
|
// see that the channel remains open for the pending htlc
|
||||||
@@ -986,7 +988,7 @@ func padCLTV(cltv uint32) uint32 {
|
|||||||
// testFailingChannel tests that we will fail the channel by force closing it
|
// testFailingChannel tests that we will fail the channel by force closing it
|
||||||
// in the case where a counterparty tries to settle an HTLC with the wrong
|
// in the case where a counterparty tries to settle an HTLC with the wrong
|
||||||
// preimage.
|
// preimage.
|
||||||
func testFailingChannel(ht *lntemp.HarnessTest) {
|
func testFailingChannel(ht *lntest.HarnessTest) {
|
||||||
const paymentAmt = 10000
|
const paymentAmt = 10000
|
||||||
|
|
||||||
chanAmt := lnd.MaxFundingAmount
|
chanAmt := lnd.MaxFundingAmount
|
||||||
@@ -999,7 +1001,7 @@ func testFailingChannel(ht *lntemp.HarnessTest) {
|
|||||||
ht.ConnectNodes(alice, carol)
|
ht.ConnectNodes(alice, carol)
|
||||||
|
|
||||||
// Let Alice connect and open a channel to Carol,
|
// Let Alice connect and open a channel to Carol,
|
||||||
ht.OpenChannel(alice, carol, lntemp.OpenChannelParams{Amt: chanAmt})
|
ht.OpenChannel(alice, carol, lntest.OpenChannelParams{Amt: chanAmt})
|
||||||
|
|
||||||
// With the channel open, we'll create a invoice for Carol that Alice
|
// With the channel open, we'll create a invoice for Carol that Alice
|
||||||
// will attempt to pay.
|
// will attempt to pay.
|
||||||
@@ -1058,7 +1060,7 @@ func testFailingChannel(ht *lntemp.HarnessTest) {
|
|||||||
// type matches a set of expected resolutions.
|
// type matches a set of expected resolutions.
|
||||||
//
|
//
|
||||||
// NOTE: only used in current test file.
|
// NOTE: only used in current test file.
|
||||||
func assertReports(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func assertReports(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
chanPoint *lnrpc.ChannelPoint, expected map[string]*lnrpc.Resolution) {
|
chanPoint *lnrpc.ChannelPoint, expected map[string]*lnrpc.Resolution) {
|
||||||
|
|
||||||
op := ht.OutPointFromChannelPoint(chanPoint)
|
op := ht.OutPointFromChannelPoint(chanPoint)
|
||||||
@@ -1092,7 +1094,7 @@ func assertReports(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
|||||||
// maturity height are as expected.
|
// maturity height are as expected.
|
||||||
//
|
//
|
||||||
// NOTE: only used in current test file.
|
// NOTE: only used in current test file.
|
||||||
func checkCommitmentMaturity(forceClose lntemp.PendingForceClose,
|
func checkCommitmentMaturity(forceClose lntest.PendingForceClose,
|
||||||
maturityHeight uint32, blocksTilMaturity int32) error {
|
maturityHeight uint32, blocksTilMaturity int32) error {
|
||||||
|
|
||||||
if forceClose.MaturityHeight != maturityHeight {
|
if forceClose.MaturityHeight != maturityHeight {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/peersrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/peersrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -40,7 +40,7 @@ import (
|
|||||||
// take more than 5 seconds to finish, the channel will be marked as disabled,
|
// take more than 5 seconds to finish, the channel will be marked as disabled,
|
||||||
// thus a following operation will fail if it relies on the channel being
|
// thus a following operation will fail if it relies on the channel being
|
||||||
// enabled.
|
// enabled.
|
||||||
func testUpdateChanStatus(ht *lntemp.HarnessTest) {
|
func testUpdateChanStatus(ht *lntest.HarnessTest) {
|
||||||
// Create two fresh nodes and open a channel between them.
|
// Create two fresh nodes and open a channel between them.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
args := []string{
|
args := []string{
|
||||||
@@ -57,7 +57,7 @@ func testUpdateChanStatus(ht *lntemp.HarnessTest) {
|
|||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanAmt := btcutil.Amount(100000)
|
chanAmt := btcutil.Amount(100000)
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
defer ht.CloseChannel(alice, chanPoint)
|
defer ht.CloseChannel(alice, chanPoint)
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ func testUpdateChanStatus(ht *lntemp.HarnessTest) {
|
|||||||
FeeRateMilliMsat: int64(chainreg.DefaultBitcoinFeeRate),
|
FeeRateMilliMsat: int64(chainreg.DefaultBitcoinFeeRate),
|
||||||
TimeLockDelta: chainreg.DefaultBitcoinTimeLockDelta,
|
TimeLockDelta: chainreg.DefaultBitcoinTimeLockDelta,
|
||||||
MinHtlc: 1000, // default value
|
MinHtlc: 1000, // default value
|
||||||
MaxHtlcMsat: lntemp.CalculateMaxHtlc(chanAmt),
|
MaxHtlcMsat: lntest.CalculateMaxHtlc(chanAmt),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manually disable the channel and ensure that a "Disabled = true"
|
// Manually disable the channel and ensure that a "Disabled = true"
|
||||||
@@ -217,14 +217,14 @@ func testUpdateChanStatus(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testUnannouncedChannels checks unannounced channels are not returned by
|
// testUnannouncedChannels checks unannounced channels are not returned by
|
||||||
// describeGraph RPC request unless explicitly asked for.
|
// describeGraph RPC request unless explicitly asked for.
|
||||||
func testUnannouncedChannels(ht *lntemp.HarnessTest) {
|
func testUnannouncedChannels(ht *lntest.HarnessTest) {
|
||||||
amount := funding.MaxBtcFundingAmount
|
amount := funding.MaxBtcFundingAmount
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
// Open a channel between Alice and Bob, ensuring the
|
// Open a channel between Alice and Bob, ensuring the
|
||||||
// channel has been opened properly.
|
// channel has been opened properly.
|
||||||
chanOpenUpdate := ht.OpenChannelAssertStream(
|
chanOpenUpdate := ht.OpenChannelAssertStream(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: amount},
|
alice, bob, lntest.OpenChannelParams{Amt: amount},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mine 2 blocks, and check that the channel is opened but not yet
|
// Mine 2 blocks, and check that the channel is opened but not yet
|
||||||
@@ -252,7 +252,7 @@ func testUnannouncedChannels(ht *lntemp.HarnessTest) {
|
|||||||
ht.CloseChannel(alice, fundingChanPoint)
|
ht.CloseChannel(alice, fundingChanPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGraphTopologyNotifications(ht *lntemp.HarnessTest) {
|
func testGraphTopologyNotifications(ht *lntest.HarnessTest) {
|
||||||
ht.Run("pinned", func(t *testing.T) {
|
ht.Run("pinned", func(t *testing.T) {
|
||||||
subT := ht.Subtest(t)
|
subT := ht.Subtest(t)
|
||||||
testGraphTopologyNtfns(subT, true)
|
testGraphTopologyNtfns(subT, true)
|
||||||
@@ -263,7 +263,7 @@ func testGraphTopologyNotifications(ht *lntemp.HarnessTest) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGraphTopologyNtfns(ht *lntemp.HarnessTest, pinned bool) {
|
func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
|
||||||
const chanAmt = funding.MaxBtcFundingAmount
|
const chanAmt = funding.MaxBtcFundingAmount
|
||||||
|
|
||||||
// Spin up Bob first, since we will need to grab his pubkey when
|
// Spin up Bob first, since we will need to grab his pubkey when
|
||||||
@@ -305,7 +305,7 @@ func testGraphTopologyNtfns(ht *lntemp.HarnessTest, pinned bool) {
|
|||||||
|
|
||||||
// Open a new channel between Alice and Bob.
|
// Open a new channel between Alice and Bob.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// The channel opening above should have triggered a few notifications
|
// The channel opening above should have triggered a few notifications
|
||||||
@@ -343,7 +343,7 @@ func testGraphTopologyNtfns(ht *lntemp.HarnessTest, pinned bool) {
|
|||||||
carol := ht.NewNode("Carol", nil)
|
carol := ht.NewNode("Carol", nil)
|
||||||
ht.ConnectNodes(bob, carol)
|
ht.ConnectNodes(bob, carol)
|
||||||
chanPoint = ht.OpenChannel(
|
chanPoint = ht.OpenChannel(
|
||||||
bob, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
bob, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reconnect Alice and Bob. This should result in the nodes syncing up
|
// Reconnect Alice and Bob. This should result in the nodes syncing up
|
||||||
@@ -366,7 +366,7 @@ func testGraphTopologyNtfns(ht *lntemp.HarnessTest, pinned bool) {
|
|||||||
// testNodeAnnouncement ensures that when a node is started with one or more
|
// testNodeAnnouncement ensures that when a node is started with one or more
|
||||||
// external IP addresses specified on the command line, that those addresses
|
// external IP addresses specified on the command line, that those addresses
|
||||||
// announced to the network and reported in the network graph.
|
// announced to the network and reported in the network graph.
|
||||||
func testNodeAnnouncement(ht *lntemp.HarnessTest) {
|
func testNodeAnnouncement(ht *lntest.HarnessTest) {
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
advertisedAddrs := []string{
|
advertisedAddrs := []string{
|
||||||
@@ -392,7 +392,7 @@ func testNodeAnnouncement(ht *lntemp.HarnessTest) {
|
|||||||
// ensures that Alice receives the node announcement from Bob as part of
|
// ensures that Alice receives the node announcement from Bob as part of
|
||||||
// the announcement broadcast.
|
// the announcement broadcast.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
bob, dave, lntemp.OpenChannelParams{Amt: 1000000},
|
bob, dave, lntest.OpenChannelParams{Amt: 1000000},
|
||||||
)
|
)
|
||||||
|
|
||||||
assertAddrs := func(addrsFound []string, targetAddrs ...string) {
|
assertAddrs := func(addrsFound []string, targetAddrs ...string) {
|
||||||
@@ -421,7 +421,7 @@ func testNodeAnnouncement(ht *lntemp.HarnessTest) {
|
|||||||
// testUpdateNodeAnnouncement ensures that the RPC endpoint validates
|
// testUpdateNodeAnnouncement ensures that the RPC endpoint validates
|
||||||
// the requests correctly and that the new node announcement is brodcasted
|
// the requests correctly and that the new node announcement is brodcasted
|
||||||
// with the right information after updating our node.
|
// with the right information after updating our node.
|
||||||
func testUpdateNodeAnnouncement(ht *lntemp.HarnessTest) {
|
func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) {
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
var lndArgs []string
|
var lndArgs []string
|
||||||
@@ -500,7 +500,7 @@ func testUpdateNodeAnnouncement(ht *lntemp.HarnessTest) {
|
|||||||
// ensures that Alice receives the node announcement from Bob as part of
|
// ensures that Alice receives the node announcement from Bob as part of
|
||||||
// the announcement broadcast.
|
// the announcement broadcast.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
bob, dave, lntemp.OpenChannelParams{
|
bob, dave, lntest.OpenChannelParams{
|
||||||
Amt: 1000000,
|
Amt: 1000000,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -637,7 +637,7 @@ func testUpdateNodeAnnouncement(ht *lntemp.HarnessTest) {
|
|||||||
// assertSyncType asserts that the peer has an expected syncType.
|
// assertSyncType asserts that the peer has an expected syncType.
|
||||||
//
|
//
|
||||||
// NOTE: only made for tests in this file.
|
// NOTE: only made for tests in this file.
|
||||||
func assertSyncType(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func assertSyncType(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
peer string, syncType lnrpc.Peer_SyncType) {
|
peer string, syncType lnrpc.Peer_SyncType) {
|
||||||
|
|
||||||
resp := hn.RPC.ListPeers()
|
resp := hn.RPC.ListPeers()
|
||||||
@@ -693,7 +693,7 @@ func compareNodeAnns(n1, n2 *lnrpc.NodeUpdate) error {
|
|||||||
// the response expected values.
|
// the response expected values.
|
||||||
//
|
//
|
||||||
// NOTE: only used for tests in this file.
|
// NOTE: only used for tests in this file.
|
||||||
func assertUpdateNodeAnnouncementResponse(ht *lntemp.HarnessTest,
|
func assertUpdateNodeAnnouncementResponse(ht *lntest.HarnessTest,
|
||||||
response *peersrpc.NodeAnnouncementUpdateResponse,
|
response *peersrpc.NodeAnnouncementUpdateResponse,
|
||||||
expectedOps map[string]int) {
|
expectedOps map[string]int) {
|
||||||
|
|
||||||
|
|||||||
@@ -10,22 +10,22 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testUpdateChannelPolicy tests that policy updates made to a channel
|
// testUpdateChannelPolicy tests that policy updates made to a channel
|
||||||
// gets propagated to other nodes in the network.
|
// gets propagated to other nodes in the network.
|
||||||
func testUpdateChannelPolicy(ht *lntemp.HarnessTest) {
|
func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
defaultFeeBase = 1000
|
defaultFeeBase = 1000
|
||||||
defaultFeeRate = 1
|
defaultFeeRate = 1
|
||||||
defaultTimeLockDelta = chainreg.DefaultBitcoinTimeLockDelta
|
defaultTimeLockDelta = chainreg.DefaultBitcoinTimeLockDelta
|
||||||
defaultMinHtlc = 1000
|
defaultMinHtlc = 1000
|
||||||
)
|
)
|
||||||
defaultMaxHtlc := lntemp.CalculateMaxHtlc(funding.MaxBtcFundingAmount)
|
defaultMaxHtlc := lntest.CalculateMaxHtlc(funding.MaxBtcFundingAmount)
|
||||||
|
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := chanAmt / 2
|
pushAmt := chanAmt / 2
|
||||||
@@ -34,7 +34,7 @@ func testUpdateChannelPolicy(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Create a channel Alice->Bob.
|
// Create a channel Alice->Bob.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
},
|
},
|
||||||
@@ -87,7 +87,7 @@ func testUpdateChannelPolicy(ht *lntemp.HarnessTest) {
|
|||||||
// part of his ChannelUpdate.
|
// part of his ChannelUpdate.
|
||||||
const customMinHtlc = 5000
|
const customMinHtlc = 5000
|
||||||
chanPoint2 := ht.OpenChannel(
|
chanPoint2 := ht.OpenChannel(
|
||||||
carol, bob, lntemp.OpenChannelParams{
|
carol, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
MinHtlc: customMinHtlc,
|
MinHtlc: customMinHtlc,
|
||||||
@@ -283,7 +283,7 @@ func testUpdateChannelPolicy(ht *lntemp.HarnessTest) {
|
|||||||
// We'll now open a channel from Alice directly to Carol.
|
// We'll now open a channel from Alice directly to Carol.
|
||||||
ht.ConnectNodes(alice, carol)
|
ht.ConnectNodes(alice, carol)
|
||||||
chanPoint3 := ht.OpenChannel(
|
chanPoint3 := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
},
|
},
|
||||||
@@ -424,7 +424,7 @@ func testUpdateChannelPolicy(ht *lntemp.HarnessTest) {
|
|||||||
// chan-disable-timeout flags here. For instance, if some operations take more
|
// chan-disable-timeout flags here. For instance, if some operations take more
|
||||||
// than 6 seconds to finish, the channel will be marked as disabled, thus a
|
// than 6 seconds to finish, the channel will be marked as disabled, thus a
|
||||||
// following operation will fail if it relies on the channel being enabled.
|
// following operation will fail if it relies on the channel being enabled.
|
||||||
func testSendUpdateDisableChannel(ht *lntemp.HarnessTest) {
|
func testSendUpdateDisableChannel(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = 100000
|
const chanAmt = 100000
|
||||||
|
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
@@ -467,8 +467,8 @@ func testSendUpdateDisableChannel(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// We now proceed to open channels: Alice=>Bob, Alice=>Carol and
|
// We now proceed to open channels: Alice=>Bob, Alice=>Carol and
|
||||||
// Eve=>Carol.
|
// Eve=>Carol.
|
||||||
p := lntemp.OpenChannelParams{Amt: chanAmt}
|
p := lntest.OpenChannelParams{Amt: chanAmt}
|
||||||
reqs := []*lntemp.OpenChannelRequest{
|
reqs := []*lntest.OpenChannelRequest{
|
||||||
{Local: alice, Remote: bob, Param: p},
|
{Local: alice, Remote: bob, Param: p},
|
||||||
{Local: alice, Remote: carol, Param: p},
|
{Local: alice, Remote: carol, Param: p},
|
||||||
{Local: eve, Remote: carol, Param: p},
|
{Local: eve, Remote: carol, Param: p},
|
||||||
@@ -513,7 +513,7 @@ func testSendUpdateDisableChannel(ht *lntemp.HarnessTest) {
|
|||||||
FeeRateMilliMsat: int64(chainreg.DefaultBitcoinFeeRate),
|
FeeRateMilliMsat: int64(chainreg.DefaultBitcoinFeeRate),
|
||||||
TimeLockDelta: chainreg.DefaultBitcoinTimeLockDelta,
|
TimeLockDelta: chainreg.DefaultBitcoinTimeLockDelta,
|
||||||
MinHtlc: 1000, // default value
|
MinHtlc: 1000, // default value
|
||||||
MaxHtlcMsat: lntemp.CalculateMaxHtlc(chanAmt),
|
MaxHtlcMsat: lntest.CalculateMaxHtlc(chanAmt),
|
||||||
Disabled: true,
|
Disabled: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,7 +655,7 @@ func testSendUpdateDisableChannel(ht *lntemp.HarnessTest) {
|
|||||||
// Bob will update the base fee via UpdateChannelPolicy, we will test that
|
// Bob will update the base fee via UpdateChannelPolicy, we will test that
|
||||||
// Alice will not fail the payment and send it using the updated channel
|
// Alice will not fail the payment and send it using the updated channel
|
||||||
// policy.
|
// policy.
|
||||||
func testUpdateChannelPolicyForPrivateChannel(ht *lntemp.HarnessTest) {
|
func testUpdateChannelPolicyForPrivateChannel(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = btcutil.Amount(100000)
|
chanAmt = btcutil.Amount(100000)
|
||||||
paymentAmt = 20000
|
paymentAmt = 20000
|
||||||
@@ -668,7 +668,7 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Open a channel with 100k satoshis between Alice and Bob.
|
// Open a channel with 100k satoshis between Alice and Bob.
|
||||||
chanPointAliceBob := ht.OpenChannel(
|
chanPointAliceBob := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -681,7 +681,7 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Open a channel with 100k satoshis between Bob and Carol.
|
// Open a channel with 100k satoshis between Bob and Carol.
|
||||||
chanPointBobCarol := ht.OpenChannel(
|
chanPointBobCarol := ht.OpenChannel(
|
||||||
bob, carol, lntemp.OpenChannelParams{
|
bob, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: true,
|
Private: true,
|
||||||
},
|
},
|
||||||
@@ -755,14 +755,14 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntemp.HarnessTest) {
|
|||||||
// testUpdateChannelPolicyFeeRateAccuracy tests that updating the channel policy
|
// testUpdateChannelPolicyFeeRateAccuracy tests that updating the channel policy
|
||||||
// rounds fee rate values correctly as well as setting fee rate with ppm works
|
// rounds fee rate values correctly as well as setting fee rate with ppm works
|
||||||
// as expected.
|
// as expected.
|
||||||
func testUpdateChannelPolicyFeeRateAccuracy(ht *lntemp.HarnessTest) {
|
func testUpdateChannelPolicyFeeRateAccuracy(ht *lntest.HarnessTest) {
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := chanAmt / 2
|
pushAmt := chanAmt / 2
|
||||||
|
|
||||||
// Create a channel Alice -> Bob.
|
// Create a channel Alice -> Bob.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
},
|
},
|
||||||
@@ -826,7 +826,7 @@ func testUpdateChannelPolicyFeeRateAccuracy(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// assertNodesPolicyUpdate checks that a given policy update has been received
|
// assertNodesPolicyUpdate checks that a given policy update has been received
|
||||||
// by a list of given nodes.
|
// by a list of given nodes.
|
||||||
func assertNodesPolicyUpdate(ht *lntemp.HarnessTest, nodes []*node.HarnessNode,
|
func assertNodesPolicyUpdate(ht *lntest.HarnessTest, nodes []*node.HarnessNode,
|
||||||
advertisingNode *node.HarnessNode, policy *lnrpc.RoutingPolicy,
|
advertisingNode *node.HarnessNode, policy *lnrpc.RoutingPolicy,
|
||||||
chanPoint *lnrpc.ChannelPoint) {
|
chanPoint *lnrpc.ChannelPoint) {
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
// testCustomMessage tests sending and receiving of overridden custom message
|
// testCustomMessage tests sending and receiving of overridden custom message
|
||||||
// types (within the message type range usually reserved for protocol messages)
|
// types (within the message type range usually reserved for protocol messages)
|
||||||
// via the send and subscribe custom message APIs.
|
// via the send and subscribe custom message APIs.
|
||||||
func testCustomMessage(ht *lntemp.HarnessTest) {
|
func testCustomMessage(ht *lntest.HarnessTest) {
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -82,7 +82,7 @@ func testCustomMessage(ht *lntemp.HarnessTest) {
|
|||||||
require.Equal(ht, bob.PubKey[:], msg.Peer, "first msg "+
|
require.Equal(ht, bob.PubKey[:], msg.Peer, "first msg "+
|
||||||
"peer wrong")
|
"peer wrong")
|
||||||
|
|
||||||
case <-time.After(defaultTimeout):
|
case <-time.After(lntest.DefaultTimeout):
|
||||||
ht.Fatalf("alice did not receive first custom message: %v",
|
ht.Fatalf("alice did not receive first custom message: %v",
|
||||||
msgType)
|
msgType)
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ func testCustomMessage(ht *lntemp.HarnessTest) {
|
|||||||
require.Equal(ht, bob.PubKey[:], msg.Peer, "second "+
|
require.Equal(ht, bob.PubKey[:], msg.Peer, "second "+
|
||||||
"message peer")
|
"message peer")
|
||||||
|
|
||||||
case <-time.After(defaultTimeout):
|
case <-time.After(lntest.DefaultTimeout):
|
||||||
ht.Fatalf("alice did not receive second custom message")
|
ht.Fatalf("alice did not receive second custom message")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,12 +12,12 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/kvdb"
|
"github.com/lightningnetwork/lnd/kvdb"
|
||||||
"github.com/lightningnetwork/lnd/lncfg"
|
"github.com/lightningnetwork/lnd/lncfg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func assertLeader(ht *lntemp.HarnessTest, observer cluster.LeaderElector,
|
func assertLeader(ht *lntest.HarnessTest, observer cluster.LeaderElector,
|
||||||
expected string) {
|
expected string) {
|
||||||
|
|
||||||
leader, err := observer.Leader(ht.Context())
|
leader, err := observer.Leader(ht.Context())
|
||||||
@@ -29,7 +29,7 @@ func assertLeader(ht *lntemp.HarnessTest, observer cluster.LeaderElector,
|
|||||||
// testEtcdFailover tests that in a cluster setup where two LND nodes form a
|
// testEtcdFailover tests that in a cluster setup where two LND nodes form a
|
||||||
// single cluster (sharing the same identity) one can hand over the leader role
|
// single cluster (sharing the same identity) one can hand over the leader role
|
||||||
// to the other (failing over after graceful shutdown or forceful abort).
|
// to the other (failing over after graceful shutdown or forceful abort).
|
||||||
func testEtcdFailover(ht *lntemp.HarnessTest) {
|
func testEtcdFailover(ht *lntest.HarnessTest) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
kill bool
|
kill bool
|
||||||
@@ -54,7 +54,7 @@ func testEtcdFailover(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEtcdFailoverCase(ht *lntemp.HarnessTest, kill bool) {
|
func testEtcdFailoverCase(ht *lntest.HarnessTest, kill bool) {
|
||||||
etcdCfg, cleanup, err := kvdb.StartEtcdTestBackend(
|
etcdCfg, cleanup, err := kvdb.StartEtcdTestBackend(
|
||||||
ht.T.TempDir(), uint16(node.NextAvailablePort()),
|
ht.T.TempDir(), uint16(node.NextAvailablePort()),
|
||||||
uint16(node.NextAvailablePort()), "",
|
uint16(node.NextAvailablePort()), "",
|
||||||
@@ -91,7 +91,7 @@ func testEtcdFailoverCase(ht *lntemp.HarnessTest, kill bool) {
|
|||||||
// Open a channel with 100k satoshis between Carol and Alice with Alice
|
// Open a channel with 100k satoshis between Carol and Alice with Alice
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanAmt := btcutil.Amount(100_000)
|
chanAmt := btcutil.Amount(100_000)
|
||||||
ht.OpenChannel(alice, carol1, lntemp.OpenChannelParams{Amt: chanAmt})
|
ht.OpenChannel(alice, carol1, lntest.OpenChannelParams{Amt: chanAmt})
|
||||||
|
|
||||||
// At this point Carol-1 is the elected leader, while Carol-2 will wait
|
// At this point Carol-1 is the elected leader, while Carol-2 will wait
|
||||||
// to become the leader when Carol-1 stops.
|
// to become the leader when Carol-1 stops.
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
@@ -34,7 +34,7 @@ type interceptorTestCase struct {
|
|||||||
|
|
||||||
// testForwardInterceptorDedupHtlc tests that upon reconnection, duplicate
|
// testForwardInterceptorDedupHtlc tests that upon reconnection, duplicate
|
||||||
// HTLCs aren't re-notified using the HTLC interceptor API.
|
// HTLCs aren't re-notified using the HTLC interceptor API.
|
||||||
func testForwardInterceptorDedupHtlc(ht *lntemp.HarnessTest) {
|
func testForwardInterceptorDedupHtlc(ht *lntest.HarnessTest) {
|
||||||
// Initialize the test context with 3 connected nodes.
|
// Initialize the test context with 3 connected nodes.
|
||||||
ts := newInterceptorTestScenario(ht)
|
ts := newInterceptorTestScenario(ht)
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ func testForwardInterceptorDedupHtlc(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Open and wait for channels.
|
// Open and wait for channels.
|
||||||
const chanAmt = btcutil.Amount(300000)
|
const chanAmt = btcutil.Amount(300000)
|
||||||
p := lntemp.OpenChannelParams{Amt: chanAmt}
|
p := lntest.OpenChannelParams{Amt: chanAmt}
|
||||||
reqs := []*lntemp.OpenChannelRequest{
|
reqs := []*lntest.OpenChannelRequest{
|
||||||
{Local: alice, Remote: bob, Param: p},
|
{Local: alice, Remote: bob, Param: p},
|
||||||
{Local: bob, Remote: carol, Param: p},
|
{Local: bob, Remote: carol, Param: p},
|
||||||
}
|
}
|
||||||
@@ -185,15 +185,15 @@ func testForwardInterceptorDedupHtlc(ht *lntemp.HarnessTest) {
|
|||||||
// 3. Intercepted held htlcs result in no payment (invoice is not settled).
|
// 3. Intercepted held htlcs result in no payment (invoice is not settled).
|
||||||
// 4. When Interceptor disconnects it resumes all held htlcs, which result in
|
// 4. When Interceptor disconnects it resumes all held htlcs, which result in
|
||||||
// valid payment (invoice is settled).
|
// valid payment (invoice is settled).
|
||||||
func testForwardInterceptorBasic(ht *lntemp.HarnessTest) {
|
func testForwardInterceptorBasic(ht *lntest.HarnessTest) {
|
||||||
ts := newInterceptorTestScenario(ht)
|
ts := newInterceptorTestScenario(ht)
|
||||||
|
|
||||||
alice, bob, carol := ts.alice, ts.bob, ts.carol
|
alice, bob, carol := ts.alice, ts.bob, ts.carol
|
||||||
|
|
||||||
// Open and wait for channels.
|
// Open and wait for channels.
|
||||||
const chanAmt = btcutil.Amount(300000)
|
const chanAmt = btcutil.Amount(300000)
|
||||||
p := lntemp.OpenChannelParams{Amt: chanAmt}
|
p := lntest.OpenChannelParams{Amt: chanAmt}
|
||||||
reqs := []*lntemp.OpenChannelRequest{
|
reqs := []*lntest.OpenChannelRequest{
|
||||||
{Local: alice, Remote: bob, Param: p},
|
{Local: alice, Remote: bob, Param: p},
|
||||||
{Local: bob, Remote: carol, Param: p},
|
{Local: bob, Remote: carol, Param: p},
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ func testForwardInterceptorBasic(ht *lntemp.HarnessTest) {
|
|||||||
// interceptorTestScenario is a helper struct to hold the test context and
|
// interceptorTestScenario is a helper struct to hold the test context and
|
||||||
// provide the needed functionality.
|
// provide the needed functionality.
|
||||||
type interceptorTestScenario struct {
|
type interceptorTestScenario struct {
|
||||||
ht *lntemp.HarnessTest
|
ht *lntest.HarnessTest
|
||||||
alice, bob, carol *node.HarnessNode
|
alice, bob, carol *node.HarnessNode
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ type interceptorTestScenario struct {
|
|||||||
//
|
//
|
||||||
// Among them, Alice and Bob are standby nodes and Carol is a new node.
|
// Among them, Alice and Bob are standby nodes and Carol is a new node.
|
||||||
func newInterceptorTestScenario(
|
func newInterceptorTestScenario(
|
||||||
ht *lntemp.HarnessTest) *interceptorTestScenario {
|
ht *lntest.HarnessTest) *interceptorTestScenario {
|
||||||
|
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
carol := ht.NewNode("carol", nil)
|
carol := ht.NewNode("carol", nil)
|
||||||
|
|||||||
+29
-24
@@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/labels"
|
"github.com/lightningnetwork/lnd/labels"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
// Bob, then immediately closes the channel after asserting some expected post
|
// Bob, then immediately closes the channel after asserting some expected post
|
||||||
// conditions. Finally, the chain itself is checked to ensure the closing
|
// conditions. Finally, the chain itself is checked to ensure the closing
|
||||||
// transaction was mined.
|
// transaction was mined.
|
||||||
func testBasicChannelFunding(ht *lntemp.HarnessTest) {
|
func testBasicChannelFunding(ht *lntest.HarnessTest) {
|
||||||
// Run through the test with combinations of all the different
|
// Run through the test with combinations of all the different
|
||||||
// commitment types.
|
// commitment types.
|
||||||
allTypes := []lnrpc.CommitmentType{
|
allTypes := []lnrpc.CommitmentType{
|
||||||
@@ -35,20 +35,20 @@ func testBasicChannelFunding(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testFunding is a function closure that takes Carol and Dave's
|
// testFunding is a function closure that takes Carol and Dave's
|
||||||
// commitment types and test the funding flow.
|
// commitment types and test the funding flow.
|
||||||
testFunding := func(ht *lntemp.HarnessTest, carolCommitType,
|
testFunding := func(ht *lntest.HarnessTest, carolCommitType,
|
||||||
daveCommitType lnrpc.CommitmentType) {
|
daveCommitType lnrpc.CommitmentType) {
|
||||||
|
|
||||||
// Based on the current tweak variable for Carol, we'll
|
// Based on the current tweak variable for Carol, we'll
|
||||||
// preferentially signal the legacy commitment format. We do
|
// preferentially signal the legacy commitment format. We do
|
||||||
// the same for Dave shortly below.
|
// the same for Dave shortly below.
|
||||||
carolArgs := lntemp.NodeArgsForCommitType(carolCommitType)
|
carolArgs := lntest.NodeArgsForCommitType(carolCommitType)
|
||||||
carol := ht.NewNode("Carol", carolArgs)
|
carol := ht.NewNode("Carol", carolArgs)
|
||||||
|
|
||||||
// Each time, we'll send Carol a new set of coins in order to
|
// Each time, we'll send Carol a new set of coins in order to
|
||||||
// fund the channel.
|
// fund the channel.
|
||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||||
|
|
||||||
daveArgs := lntemp.NodeArgsForCommitType(daveCommitType)
|
daveArgs := lntest.NodeArgsForCommitType(daveCommitType)
|
||||||
dave := ht.NewNode("Dave", daveArgs)
|
dave := ht.NewNode("Dave", daveArgs)
|
||||||
|
|
||||||
// Before we start the test, we'll ensure both sides are
|
// Before we start the test, we'll ensure both sides are
|
||||||
@@ -140,7 +140,7 @@ test:
|
|||||||
// test. Given two nodes: Alice and Bob, it'll assert proper channel creation,
|
// test. Given two nodes: Alice and Bob, it'll assert proper channel creation,
|
||||||
// then return a function closure that should be called to assert proper
|
// then return a function closure that should be called to assert proper
|
||||||
// channel closure.
|
// channel closure.
|
||||||
func basicChannelFundingTest(ht *lntemp.HarnessTest,
|
func basicChannelFundingTest(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode,
|
alice, bob *node.HarnessNode,
|
||||||
fundingShim *lnrpc.FundingShim) (*lnrpc.Channel,
|
fundingShim *lnrpc.FundingShim) (*lnrpc.Channel,
|
||||||
*lnrpc.Channel, func()) {
|
*lnrpc.Channel, func()) {
|
||||||
@@ -181,7 +181,7 @@ func basicChannelFundingTest(ht *lntemp.HarnessTest,
|
|||||||
// assertions will be executed to ensure the funding process completed
|
// assertions will be executed to ensure the funding process completed
|
||||||
// successfully.
|
// successfully.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
FundingShim: fundingShim,
|
FundingShim: fundingShim,
|
||||||
@@ -193,7 +193,7 @@ func basicChannelFundingTest(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// With the channel open, ensure that the amount specified above has
|
// With the channel open, ensure that the amount specified above has
|
||||||
// properly been pushed to Bob.
|
// properly been pushed to Bob.
|
||||||
aliceLocalBalance := chanAmt - pushAmt - lntemp.CalcStaticFee(cType, 0)
|
aliceLocalBalance := chanAmt - pushAmt - lntest.CalcStaticFee(cType, 0)
|
||||||
checkChannelBalance(
|
checkChannelBalance(
|
||||||
alice, aliceChannelBalance, aliceLocalBalance, pushAmt,
|
alice, aliceChannelBalance, aliceLocalBalance, pushAmt,
|
||||||
)
|
)
|
||||||
@@ -216,7 +216,7 @@ func basicChannelFundingTest(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testUnconfirmedChannelFunding tests that our unconfirmed change outputs can
|
// testUnconfirmedChannelFunding tests that our unconfirmed change outputs can
|
||||||
// be used to fund channels.
|
// be used to fund channels.
|
||||||
func testUnconfirmedChannelFunding(ht *lntemp.HarnessTest) {
|
func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = funding.MaxBtcFundingAmount
|
chanAmt = funding.MaxBtcFundingAmount
|
||||||
pushAmt = btcutil.Amount(100000)
|
pushAmt = btcutil.Amount(100000)
|
||||||
@@ -236,7 +236,7 @@ func testUnconfirmedChannelFunding(ht *lntemp.HarnessTest) {
|
|||||||
ht.ConnectNodes(carol, alice)
|
ht.ConnectNodes(carol, alice)
|
||||||
|
|
||||||
chanOpenUpdate := ht.OpenChannelAssertStream(
|
chanOpenUpdate := ht.OpenChannelAssertStream(
|
||||||
carol, alice, lntemp.OpenChannelParams{
|
carol, alice, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
SpendUnconfirmed: true,
|
SpendUnconfirmed: true,
|
||||||
@@ -289,7 +289,7 @@ func testUnconfirmedChannelFunding(ht *lntemp.HarnessTest) {
|
|||||||
// Note that atm we haven't obtained the chanPoint yet, so we use the
|
// Note that atm we haven't obtained the chanPoint yet, so we use the
|
||||||
// type directly.
|
// type directly.
|
||||||
cType := lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
cType := lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
||||||
carolLocalBalance := chanAmt - pushAmt - lntemp.CalcStaticFee(cType, 0)
|
carolLocalBalance := chanAmt - pushAmt - lntest.CalcStaticFee(cType, 0)
|
||||||
checkChannelBalance(carol, 0, 0, carolLocalBalance, pushAmt)
|
checkChannelBalance(carol, 0, 0, carolLocalBalance, pushAmt)
|
||||||
|
|
||||||
// For Alice, her local/remote balances should be zero, and the
|
// For Alice, her local/remote balances should be zero, and the
|
||||||
@@ -329,7 +329,12 @@ func testUnconfirmedChannelFunding(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testChannelFundingInputTypes tests that any type of supported input type can
|
// testChannelFundingInputTypes tests that any type of supported input type can
|
||||||
// be used to fund channels.
|
// be used to fund channels.
|
||||||
func testChannelFundingInputTypes(ht *lntemp.HarnessTest) {
|
func testChannelFundingInputTypes(ht *lntest.HarnessTest) {
|
||||||
|
const (
|
||||||
|
chanAmt = funding.MaxBtcFundingAmount
|
||||||
|
burnAddr = "bcrt1qxsnqpdc842lu8c0xlllgvejt6rhy49u6fmpgyz"
|
||||||
|
)
|
||||||
|
|
||||||
// We'll start off by creating a node for Carol.
|
// We'll start off by creating a node for Carol.
|
||||||
carol := ht.NewNode("Carol", nil)
|
carol := ht.NewNode("Carol", nil)
|
||||||
|
|
||||||
@@ -342,7 +347,7 @@ func testChannelFundingInputTypes(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// runChannelFundingInputTypes tests that any type of supported input type can
|
// runChannelFundingInputTypes tests that any type of supported input type can
|
||||||
// be used to fund channels.
|
// be used to fund channels.
|
||||||
func runChannelFundingInputTypes(ht *lntemp.HarnessTest, alice,
|
func runChannelFundingInputTypes(ht *lntest.HarnessTest, alice,
|
||||||
carol *node.HarnessNode) {
|
carol *node.HarnessNode) {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -411,7 +416,7 @@ func runChannelFundingInputTypes(ht *lntemp.HarnessTest, alice,
|
|||||||
funder((chanAmt*11)/10, carol)
|
funder((chanAmt*11)/10, carol)
|
||||||
|
|
||||||
chanOpenUpdate := ht.OpenChannelAssertStream(
|
chanOpenUpdate := ht.OpenChannelAssertStream(
|
||||||
carol, alice, lntemp.OpenChannelParams{
|
carol, alice, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -423,7 +428,7 @@ func runChannelFundingInputTypes(ht *lntemp.HarnessTest, alice,
|
|||||||
// Note that atm we haven't obtained the chanPoint yet, so we
|
// Note that atm we haven't obtained the chanPoint yet, so we
|
||||||
// use the type directly.
|
// use the type directly.
|
||||||
cType := lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
cType := lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
||||||
carolLocalBalance := chanAmt - lntemp.CalcStaticFee(cType, 0)
|
carolLocalBalance := chanAmt - lntest.CalcStaticFee(cType, 0)
|
||||||
checkChannelBalance(carol, 0, 0, carolLocalBalance, 0)
|
checkChannelBalance(carol, 0, 0, carolLocalBalance, 0)
|
||||||
|
|
||||||
// For Alice, her local/remote balances should be zero, and the
|
// For Alice, her local/remote balances should be zero, and the
|
||||||
@@ -463,7 +468,7 @@ func runChannelFundingInputTypes(ht *lntemp.HarnessTest, alice,
|
|||||||
|
|
||||||
// sendAllCoinsConfirm sends all coins of the node's wallet to the given address
|
// sendAllCoinsConfirm sends all coins of the node's wallet to the given address
|
||||||
// and awaits one confirmation.
|
// and awaits one confirmation.
|
||||||
func sendAllCoinsConfirm(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
func sendAllCoinsConfirm(ht *lntest.HarnessTest, node *node.HarnessNode,
|
||||||
addr string) {
|
addr string) {
|
||||||
|
|
||||||
sweepReq := &lnrpc.SendCoinsRequest{
|
sweepReq := &lnrpc.SendCoinsRequest{
|
||||||
@@ -477,7 +482,7 @@ func sendAllCoinsConfirm(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
|||||||
// testExternalFundingChanPoint tests that we're able to carry out a normal
|
// testExternalFundingChanPoint tests that we're able to carry out a normal
|
||||||
// channel funding workflow given a channel point that was constructed outside
|
// channel funding workflow given a channel point that was constructed outside
|
||||||
// the main daemon.
|
// the main daemon.
|
||||||
func testExternalFundingChanPoint(ht *lntemp.HarnessTest) {
|
func testExternalFundingChanPoint(ht *lntest.HarnessTest) {
|
||||||
// First, we'll create two new nodes that we'll use to open channel
|
// First, we'll create two new nodes that we'll use to open channel
|
||||||
// between for this test.
|
// between for this test.
|
||||||
carol := ht.NewNode("carol", nil)
|
carol := ht.NewNode("carol", nil)
|
||||||
@@ -500,7 +505,7 @@ func testExternalFundingChanPoint(ht *lntemp.HarnessTest) {
|
|||||||
ht, carol, dave, chanSize, thawHeight, false,
|
ht, carol, dave, chanSize, thawHeight, false,
|
||||||
)
|
)
|
||||||
ht.OpenChannelAssertPending(
|
ht.OpenChannelAssertPending(
|
||||||
carol, dave, lntemp.OpenChannelParams{
|
carol, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanSize,
|
Amt: chanSize,
|
||||||
FundingShim: fundingShim1,
|
FundingShim: fundingShim1,
|
||||||
},
|
},
|
||||||
@@ -591,7 +596,7 @@ func testExternalFundingChanPoint(ht *lntemp.HarnessTest) {
|
|||||||
// representation of channels if the system is restarted or disconnected.
|
// representation of channels if the system is restarted or disconnected.
|
||||||
// testFundingPersistence mirrors testBasicChannelFunding, but adds restarts
|
// testFundingPersistence mirrors testBasicChannelFunding, but adds restarts
|
||||||
// and checks for the state of channels with unconfirmed funding transactions.
|
// and checks for the state of channels with unconfirmed funding transactions.
|
||||||
func testChannelFundingPersistence(ht *lntemp.HarnessTest) {
|
func testChannelFundingPersistence(ht *lntest.HarnessTest) {
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := btcutil.Amount(0)
|
pushAmt := btcutil.Amount(0)
|
||||||
|
|
||||||
@@ -609,7 +614,7 @@ func testChannelFundingPersistence(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Create a new channel that requires 5 confs before it's considered
|
// Create a new channel that requires 5 confs before it's considered
|
||||||
// open, then broadcast the funding transaction
|
// open, then broadcast the funding transaction
|
||||||
param := lntemp.OpenChannelParams{
|
param := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
}
|
}
|
||||||
@@ -676,7 +681,7 @@ func testChannelFundingPersistence(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// The channel should be listed in the peer information returned by
|
// The channel should be listed in the peer information returned by
|
||||||
// both peers.
|
// both peers.
|
||||||
chanPoint := lntemp.ChanPointFromPendingUpdate(update)
|
chanPoint := lntest.ChanPointFromPendingUpdate(update)
|
||||||
|
|
||||||
// Re-lookup our transaction in the block that it confirmed in.
|
// Re-lookup our transaction in the block that it confirmed in.
|
||||||
tx = ht.AssertTxAtHeight(alice, height, fundingTxID)
|
tx = ht.AssertTxAtHeight(alice, height, fundingTxID)
|
||||||
@@ -699,7 +704,7 @@ func testChannelFundingPersistence(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testBatchChanFunding makes sure multiple channels can be opened in one batch
|
// testBatchChanFunding makes sure multiple channels can be opened in one batch
|
||||||
// transaction in an atomic way.
|
// transaction in an atomic way.
|
||||||
func testBatchChanFunding(ht *lntemp.HarnessTest) {
|
func testBatchChanFunding(ht *lntest.HarnessTest) {
|
||||||
// First, we'll create two new nodes that we'll use to open channels
|
// First, we'll create two new nodes that we'll use to open channels
|
||||||
// to during this test. Carol has a high minimum funding amount that
|
// to during this test. Carol has a high minimum funding amount that
|
||||||
// we'll use to trigger an error during the batch channel open.
|
// we'll use to trigger an error during the batch channel open.
|
||||||
@@ -793,7 +798,7 @@ func testBatchChanFunding(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// deriveFundingShim creates a channel funding shim by deriving the necessary
|
// deriveFundingShim creates a channel funding shim by deriving the necessary
|
||||||
// keys on both sides.
|
// keys on both sides.
|
||||||
func deriveFundingShim(ht *lntemp.HarnessTest,
|
func deriveFundingShim(ht *lntest.HarnessTest,
|
||||||
carol, dave *node.HarnessNode, chanSize btcutil.Amount,
|
carol, dave *node.HarnessNode, chanSize btcutil.Amount,
|
||||||
thawHeight uint32, publish bool) (*lnrpc.FundingShim,
|
thawHeight uint32, publish bool) (*lnrpc.FundingShim,
|
||||||
*lnrpc.ChannelPoint, *chainhash.Hash) {
|
*lnrpc.ChannelPoint, *chainhash.Hash) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -15,11 +15,11 @@ import (
|
|||||||
|
|
||||||
// testHoldInvoiceForceClose tests cancellation of accepted hold invoices which
|
// testHoldInvoiceForceClose tests cancellation of accepted hold invoices which
|
||||||
// would otherwise trigger force closes when they expire.
|
// would otherwise trigger force closes when they expire.
|
||||||
func testHoldInvoiceForceClose(ht *lntemp.HarnessTest) {
|
func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
|
||||||
// Open a channel between alice and bob.
|
// Open a channel between alice and bob.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: 300000},
|
alice, bob, lntest.OpenChannelParams{Amt: 300000},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a non-dust hold invoice for bob.
|
// Create a non-dust hold invoice for bob.
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
// testHoldInvoicePersistence tests that a sender to a hold-invoice, can be
|
// testHoldInvoicePersistence tests that a sender to a hold-invoice, can be
|
||||||
// restarted before the payment gets settled, and still be able to receive the
|
// restarted before the payment gets settled, and still be able to receive the
|
||||||
// preimage.
|
// preimage.
|
||||||
func testHoldInvoicePersistence(ht *lntemp.HarnessTest) {
|
func testHoldInvoicePersistence(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = btcutil.Amount(1000000)
|
chanAmt = btcutil.Amount(1000000)
|
||||||
numPayments = 10
|
numPayments = 10
|
||||||
@@ -34,7 +34,7 @@ func testHoldInvoicePersistence(ht *lntemp.HarnessTest) {
|
|||||||
// Open a channel between Alice and Carol which is private so that we
|
// Open a channel between Alice and Carol which is private so that we
|
||||||
// cover the addition of hop hints for hold invoices.
|
// cover the addition of hop hints for hold invoices.
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: true,
|
Private: true,
|
||||||
},
|
},
|
||||||
@@ -45,7 +45,7 @@ func testHoldInvoicePersistence(ht *lntemp.HarnessTest) {
|
|||||||
// has at least one public channel in the graph. We open a public
|
// has at least one public channel in the graph. We open a public
|
||||||
// channel from Alice -> Bob and wait for Carol to see it.
|
// channel from Alice -> Bob and wait for Carol to see it.
|
||||||
chanPointBob := ht.OpenChannel(
|
chanPointBob := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
// enabled on the gRPC interface, no requests with missing or invalid
|
// enabled on the gRPC interface, no requests with missing or invalid
|
||||||
// macaroons are allowed. Further, the specific access rights (read/write,
|
// macaroons are allowed. Further, the specific access rights (read/write,
|
||||||
// entity based) and first-party caveats are tested as well.
|
// entity based) and first-party caveats are tested as well.
|
||||||
func testMacaroonAuthentication(ht *lntemp.HarnessTest) {
|
func testMacaroonAuthentication(ht *lntest.HarnessTest) {
|
||||||
var (
|
var (
|
||||||
infoReq = &lnrpc.GetInfoRequest{}
|
infoReq = &lnrpc.GetInfoRequest{}
|
||||||
newAddrReq = &lnrpc.NewAddressRequest{
|
newAddrReq = &lnrpc.NewAddressRequest{
|
||||||
@@ -294,7 +294,7 @@ func testMacaroonAuthentication(ht *lntemp.HarnessTest) {
|
|||||||
// testBakeMacaroon checks that when creating macaroons, the permissions param
|
// testBakeMacaroon checks that when creating macaroons, the permissions param
|
||||||
// in the request must be set correctly, and the baked macaroon has the intended
|
// in the request must be set correctly, and the baked macaroon has the intended
|
||||||
// permissions.
|
// permissions.
|
||||||
func testBakeMacaroon(ht *lntemp.HarnessTest) {
|
func testBakeMacaroon(ht *lntest.HarnessTest) {
|
||||||
var testNode = ht.Alice
|
var testNode = ht.Alice
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@@ -518,7 +518,7 @@ func testBakeMacaroon(ht *lntemp.HarnessTest) {
|
|||||||
// specified ID and invalidates all macaroons derived from the key with that ID.
|
// specified ID and invalidates all macaroons derived from the key with that ID.
|
||||||
// Also, it checks deleting the reserved marcaroon ID, DefaultRootKeyID or is
|
// Also, it checks deleting the reserved marcaroon ID, DefaultRootKeyID or is
|
||||||
// forbidden.
|
// forbidden.
|
||||||
func testDeleteMacaroonID(ht *lntemp.HarnessTest) {
|
func testDeleteMacaroonID(ht *lntest.HarnessTest) {
|
||||||
var (
|
var (
|
||||||
ctxb = ht.Context()
|
ctxb = ht.Context()
|
||||||
testNode = ht.Alice
|
testNode = ht.Alice
|
||||||
@@ -610,7 +610,7 @@ func testDeleteMacaroonID(ht *lntemp.HarnessTest) {
|
|||||||
// does not write any macaroon files to the daemon's file system and returns
|
// does not write any macaroon files to the daemon's file system and returns
|
||||||
// the admin macaroon in the response. It then checks that the password
|
// the admin macaroon in the response. It then checks that the password
|
||||||
// change of the wallet can also happen stateless.
|
// change of the wallet can also happen stateless.
|
||||||
func testStatelessInit(ht *lntemp.HarnessTest) {
|
func testStatelessInit(ht *lntest.HarnessTest) {
|
||||||
var (
|
var (
|
||||||
initPw = []byte("stateless")
|
initPw = []byte("stateless")
|
||||||
newPw = []byte("stateless-new")
|
newPw = []byte("stateless-new")
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testMaxChannelSize tests that lnd handles --maxchansize parameter correctly.
|
// testMaxChannelSize tests that lnd handles --maxchansize parameter correctly.
|
||||||
// Wumbo nodes should enforce a default soft limit of 10 BTC by default. This
|
// Wumbo nodes should enforce a default soft limit of 10 BTC by default. This
|
||||||
// limit can be adjusted with --maxchansize config option.
|
// limit can be adjusted with --maxchansize config option.
|
||||||
func testMaxChannelSize(ht *lntemp.HarnessTest) {
|
func testMaxChannelSize(ht *lntest.HarnessTest) {
|
||||||
// We'll make two new nodes, both wumbo but with the default limit on
|
// We'll make two new nodes, both wumbo but with the default limit on
|
||||||
// maximum channel size (10 BTC)
|
// maximum channel size (10 BTC)
|
||||||
wumboNode := ht.NewNode(
|
wumboNode := ht.NewNode(
|
||||||
@@ -39,7 +39,7 @@ func testMaxChannelSize(ht *lntemp.HarnessTest) {
|
|||||||
)
|
)
|
||||||
ht.OpenChannelAssertErr(
|
ht.OpenChannelAssertErr(
|
||||||
wumboNode, wumboNode2,
|
wumboNode, wumboNode2,
|
||||||
lntemp.OpenChannelParams{Amt: chanAmt}, expectedErr,
|
lntest.OpenChannelParams{Amt: chanAmt}, expectedErr,
|
||||||
)
|
)
|
||||||
|
|
||||||
// We'll now make another wumbo node with appropriate maximum channel
|
// We'll now make another wumbo node with appropriate maximum channel
|
||||||
@@ -57,7 +57,7 @@ func testMaxChannelSize(ht *lntemp.HarnessTest) {
|
|||||||
// Creating a wumbo channel between these two nodes should succeed.
|
// Creating a wumbo channel between these two nodes should succeed.
|
||||||
ht.EnsureConnected(wumboNode, wumboNode3)
|
ht.EnsureConnected(wumboNode, wumboNode3)
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
wumboNode, wumboNode3, lntemp.OpenChannelParams{Amt: chanAmt},
|
wumboNode, wumboNode3, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
ht.CloseChannel(wumboNode, chanPoint)
|
ht.CloseChannel(wumboNode, chanPoint)
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -14,14 +14,14 @@ import (
|
|||||||
// channel where we have already reached the limit of the number of htlcs that
|
// channel where we have already reached the limit of the number of htlcs that
|
||||||
// we may add to the remote party's commitment. This test asserts that we do
|
// we may add to the remote party's commitment. This test asserts that we do
|
||||||
// not attempt to use the full channel at all in our pathfinding.
|
// not attempt to use the full channel at all in our pathfinding.
|
||||||
func testMaxHtlcPathfind(ht *lntemp.HarnessTest) {
|
func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
|
||||||
// Setup a channel between Alice and Bob where Alice will only allow
|
// Setup a channel between Alice and Bob where Alice will only allow
|
||||||
// Bob to add a maximum of 5 htlcs to her commitment.
|
// Bob to add a maximum of 5 htlcs to her commitment.
|
||||||
maxHtlcs := 5
|
maxHtlcs := 5
|
||||||
|
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: 1000000,
|
Amt: 1000000,
|
||||||
PushAmt: 800000,
|
PushAmt: 800000,
|
||||||
RemoteMaxHtlcs: uint16(maxHtlcs),
|
RemoteMaxHtlcs: uint16(maxHtlcs),
|
||||||
@@ -84,7 +84,7 @@ type holdSubscription struct {
|
|||||||
|
|
||||||
// cancel updates a hold invoice to cancel from the recipient and consumes
|
// cancel updates a hold invoice to cancel from the recipient and consumes
|
||||||
// updates from the payer until it has reached a final, failed state.
|
// updates from the payer until it has reached a final, failed state.
|
||||||
func (h *holdSubscription) cancel(ht *lntemp.HarnessTest) {
|
func (h *holdSubscription) cancel(ht *lntest.HarnessTest) {
|
||||||
h.recipient.RPC.CancelInvoice(h.hash[:])
|
h.recipient.RPC.CancelInvoice(h.hash[:])
|
||||||
|
|
||||||
invUpdate := ht.ReceiveSingleInvoice(h.invSubscription)
|
invUpdate := ht.ReceiveSingleInvoice(h.invSubscription)
|
||||||
@@ -110,7 +110,7 @@ func (h *holdSubscription) cancel(ht *lntemp.HarnessTest) {
|
|||||||
// acceptHoldInvoice adds a hold invoice to the recipient node, pays it from
|
// acceptHoldInvoice adds a hold invoice to the recipient node, pays it from
|
||||||
// the sender and asserts that we have reached the accepted state where htlcs
|
// the sender and asserts that we have reached the accepted state where htlcs
|
||||||
// are locked in for the payment.
|
// are locked in for the payment.
|
||||||
func acceptHoldInvoice(ht *lntemp.HarnessTest, idx int, sender,
|
func acceptHoldInvoice(ht *lntest.HarnessTest, idx int, sender,
|
||||||
receiver *node.HarnessNode) *holdSubscription {
|
receiver *node.HarnessNode) *holdSubscription {
|
||||||
|
|
||||||
hash := [lntypes.HashSize]byte{byte(idx + 1)}
|
hash := [lntypes.HashSize]byte{byte(idx + 1)}
|
||||||
|
|||||||
+29
-29
@@ -15,8 +15,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
// disconnect at any point.
|
// disconnect at any point.
|
||||||
//
|
//
|
||||||
// TODO(yy): move to lnd_network_test.
|
// TODO(yy): move to lnd_network_test.
|
||||||
func testDisconnectingTargetPeer(ht *lntemp.HarnessTest) {
|
func testDisconnectingTargetPeer(ht *lntest.HarnessTest) {
|
||||||
// We'll start both nodes with a high backoff so that they don't
|
// We'll start both nodes with a high backoff so that they don't
|
||||||
// reconnect automatically during our test.
|
// reconnect automatically during our test.
|
||||||
args := []string{
|
args := []string{
|
||||||
@@ -49,7 +49,7 @@ func testDisconnectingTargetPeer(ht *lntemp.HarnessTest) {
|
|||||||
// Create a new channel that requires 1 confs before it's considered
|
// Create a new channel that requires 1 confs before it's considered
|
||||||
// open, then broadcast the funding transaction
|
// open, then broadcast the funding transaction
|
||||||
const numConfs = 1
|
const numConfs = 1
|
||||||
p := lntemp.OpenChannelParams{
|
p := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ func testDisconnectingTargetPeer(ht *lntemp.HarnessTest) {
|
|||||||
// configuration arguments to force Carol to replay the same sphinx packet
|
// configuration arguments to force Carol to replay the same sphinx packet
|
||||||
// after reconnecting to Dave, and compare the returned failure message with
|
// after reconnecting to Dave, and compare the returned failure message with
|
||||||
// what we expect for replayed onion packets.
|
// what we expect for replayed onion packets.
|
||||||
func testSphinxReplayPersistence(ht *lntemp.HarnessTest) {
|
func testSphinxReplayPersistence(ht *lntest.HarnessTest) {
|
||||||
// Open a channel with 100k satoshis between Carol and Dave with Carol
|
// Open a channel with 100k satoshis between Carol and Dave with Carol
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanAmt := btcutil.Amount(100000)
|
chanAmt := btcutil.Amount(100000)
|
||||||
@@ -135,7 +135,7 @@ func testSphinxReplayPersistence(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
ht.ConnectNodes(carol, dave)
|
ht.ConnectNodes(carol, dave)
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{
|
carol, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -150,7 +150,7 @@ func testSphinxReplayPersistence(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
ht.ConnectNodes(fred, carol)
|
ht.ConnectNodes(fred, carol)
|
||||||
chanPointFC := ht.OpenChannel(
|
chanPointFC := ht.OpenChannel(
|
||||||
fred, carol, lntemp.OpenChannelParams{
|
fred, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -232,7 +232,7 @@ func testSphinxReplayPersistence(ht *lntemp.HarnessTest) {
|
|||||||
// tests the values in all ChannelConstraints are returned as expected. Once
|
// tests the values in all ChannelConstraints are returned as expected. Once
|
||||||
// ListChannels becomes mature, a test against all fields in ListChannels
|
// ListChannels becomes mature, a test against all fields in ListChannels
|
||||||
// should be performed.
|
// should be performed.
|
||||||
func testListChannels(ht *lntemp.HarnessTest) {
|
func testListChannels(ht *lntest.HarnessTest) {
|
||||||
const aliceRemoteMaxHtlcs = 50
|
const aliceRemoteMaxHtlcs = 50
|
||||||
const bobRemoteMaxHtlcs = 100
|
const bobRemoteMaxHtlcs = 100
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ func testListChannels(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
chanAmt := btcutil.Amount(100000)
|
chanAmt := btcutil.Amount(100000)
|
||||||
pushAmt := btcutil.Amount(1000)
|
pushAmt := btcutil.Amount(1000)
|
||||||
p := lntemp.OpenChannelParams{
|
p := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
MinHtlc: customizedMinHtlc,
|
MinHtlc: customizedMinHtlc,
|
||||||
@@ -337,7 +337,7 @@ func testListChannels(ht *lntemp.HarnessTest) {
|
|||||||
// testMaxPendingChannels checks that error is returned from remote peer if
|
// testMaxPendingChannels checks that error is returned from remote peer if
|
||||||
// max pending channel number was exceeded and that '--maxpendingchannels' flag
|
// max pending channel number was exceeded and that '--maxpendingchannels' flag
|
||||||
// exists and works properly.
|
// exists and works properly.
|
||||||
func testMaxPendingChannels(ht *lntemp.HarnessTest) {
|
func testMaxPendingChannels(ht *lntest.HarnessTest) {
|
||||||
maxPendingChannels := lncfg.DefaultMaxPendingChannels + 1
|
maxPendingChannels := lncfg.DefaultMaxPendingChannels + 1
|
||||||
amount := funding.MaxBtcFundingAmount
|
amount := funding.MaxBtcFundingAmount
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ func testMaxPendingChannels(ht *lntemp.HarnessTest) {
|
|||||||
)
|
)
|
||||||
for i := 0; i < maxPendingChannels; i++ {
|
for i := 0; i < maxPendingChannels; i++ {
|
||||||
stream := ht.OpenChannelAssertStream(
|
stream := ht.OpenChannelAssertStream(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: amount,
|
Amt: amount,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -372,7 +372,7 @@ func testMaxPendingChannels(ht *lntemp.HarnessTest) {
|
|||||||
// Carol exhausted available amount of pending channels, next open
|
// Carol exhausted available amount of pending channels, next open
|
||||||
// channel request should cause ErrorGeneric to be sent back to Alice.
|
// channel request should cause ErrorGeneric to be sent back to Alice.
|
||||||
ht.OpenChannelAssertErr(
|
ht.OpenChannelAssertErr(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: amount,
|
Amt: amount,
|
||||||
}, lnwire.ErrMaxPendingChannels,
|
}, lnwire.ErrMaxPendingChannels,
|
||||||
)
|
)
|
||||||
@@ -415,7 +415,7 @@ func testMaxPendingChannels(ht *lntemp.HarnessTest) {
|
|||||||
// testGarbageCollectLinkNodes tests that we properly garbage collect link
|
// testGarbageCollectLinkNodes tests that we properly garbage collect link
|
||||||
// nodes from the database and the set of persistent connections within the
|
// nodes from the database and the set of persistent connections within the
|
||||||
// server.
|
// server.
|
||||||
func testGarbageCollectLinkNodes(ht *lntemp.HarnessTest) {
|
func testGarbageCollectLinkNodes(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = 1000000
|
const chanAmt = 1000000
|
||||||
|
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
@@ -423,7 +423,7 @@ func testGarbageCollectLinkNodes(ht *lntemp.HarnessTest) {
|
|||||||
// Open a channel between Alice and Bob which will later be
|
// Open a channel between Alice and Bob which will later be
|
||||||
// cooperatively closed.
|
// cooperatively closed.
|
||||||
coopChanPoint := ht.OpenChannel(
|
coopChanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -435,7 +435,7 @@ func testGarbageCollectLinkNodes(ht *lntemp.HarnessTest) {
|
|||||||
// Open a channel between Alice and Carol which will later be force
|
// Open a channel between Alice and Carol which will later be force
|
||||||
// closed.
|
// closed.
|
||||||
forceCloseChanPoint := ht.OpenChannel(
|
forceCloseChanPoint := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -447,7 +447,7 @@ func testGarbageCollectLinkNodes(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
ht.ConnectNodes(alice, dave)
|
ht.ConnectNodes(alice, dave)
|
||||||
persistentChanPoint := ht.OpenChannel(
|
persistentChanPoint := ht.OpenChannel(
|
||||||
alice, dave, lntemp.OpenChannelParams{
|
alice, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -527,7 +527,7 @@ func testGarbageCollectLinkNodes(ht *lntemp.HarnessTest) {
|
|||||||
// testRejectHTLC tests that a node can be created with the flag --rejecthtlc.
|
// testRejectHTLC tests that a node can be created with the flag --rejecthtlc.
|
||||||
// This means that the node will reject all forwarded HTLCs but can still
|
// This means that the node will reject all forwarded HTLCs but can still
|
||||||
// accept direct HTLCs as well as send HTLCs.
|
// accept direct HTLCs as well as send HTLCs.
|
||||||
func testRejectHTLC(ht *lntemp.HarnessTest) {
|
func testRejectHTLC(ht *lntest.HarnessTest) {
|
||||||
// RejectHTLC
|
// RejectHTLC
|
||||||
// Alice ------> Carol ------> Bob
|
// Alice ------> Carol ------> Bob
|
||||||
//
|
//
|
||||||
@@ -548,14 +548,14 @@ func testRejectHTLC(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Open a channel between Alice and Carol.
|
// Open a channel between Alice and Carol.
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Open a channel between Carol and Bob.
|
// Open a channel between Carol and Bob.
|
||||||
chanPointCarol := ht.OpenChannel(
|
chanPointCarol := ht.OpenChannel(
|
||||||
carol, bob, lntemp.OpenChannelParams{
|
carol, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -623,14 +623,14 @@ func testRejectHTLC(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testNodeSignVerify checks that only connected nodes are allowed to perform
|
// testNodeSignVerify checks that only connected nodes are allowed to perform
|
||||||
// signing and verifying messages.
|
// signing and verifying messages.
|
||||||
func testNodeSignVerify(ht *lntemp.HarnessTest) {
|
func testNodeSignVerify(ht *lntest.HarnessTest) {
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := btcutil.Amount(100000)
|
pushAmt := btcutil.Amount(100000)
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
// Create a channel between alice and bob.
|
// Create a channel between alice and bob.
|
||||||
aliceBobCh := ht.OpenChannel(
|
aliceBobCh := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
},
|
},
|
||||||
@@ -670,11 +670,11 @@ func testNodeSignVerify(ht *lntemp.HarnessTest) {
|
|||||||
// testAbandonChannel abandons a channel and asserts that it is no longer open
|
// testAbandonChannel abandons a channel and asserts that it is no longer open
|
||||||
// and not in one of the pending closure states. It also verifies that the
|
// and not in one of the pending closure states. It also verifies that the
|
||||||
// abandoned channel is reported as closed with close type 'abandoned'.
|
// abandoned channel is reported as closed with close type 'abandoned'.
|
||||||
func testAbandonChannel(ht *lntemp.HarnessTest) {
|
func testAbandonChannel(ht *lntest.HarnessTest) {
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
// First establish a channel between Alice and Bob.
|
// First establish a channel between Alice and Bob.
|
||||||
channelParam := lntemp.OpenChannelParams{
|
channelParam := lntest.OpenChannelParams{
|
||||||
Amt: funding.MaxBtcFundingAmount,
|
Amt: funding.MaxBtcFundingAmount,
|
||||||
PushAmt: btcutil.Amount(100000),
|
PushAmt: btcutil.Amount(100000),
|
||||||
}
|
}
|
||||||
@@ -741,7 +741,7 @@ func testAbandonChannel(ht *lntemp.HarnessTest) {
|
|||||||
// wallet into a single target address at the specified fee rate.
|
// wallet into a single target address at the specified fee rate.
|
||||||
//
|
//
|
||||||
// TODO(yy): expand this test to also use P2TR.
|
// TODO(yy): expand this test to also use P2TR.
|
||||||
func testSweepAllCoins(ht *lntemp.HarnessTest) {
|
func testSweepAllCoins(ht *lntest.HarnessTest) {
|
||||||
// First, we'll make a new node, ainz who'll we'll use to test wallet
|
// First, we'll make a new node, ainz who'll we'll use to test wallet
|
||||||
// sweeping.
|
// sweeping.
|
||||||
//
|
//
|
||||||
@@ -917,7 +917,7 @@ func testSweepAllCoins(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testListAddresses tests that we get all the addresses and their
|
// testListAddresses tests that we get all the addresses and their
|
||||||
// corresponding balance correctly.
|
// corresponding balance correctly.
|
||||||
func testListAddresses(ht *lntemp.HarnessTest) {
|
func testListAddresses(ht *lntest.HarnessTest) {
|
||||||
// First, we'll make a new node - Alice, which will be generating
|
// First, we'll make a new node - Alice, which will be generating
|
||||||
// new addresses.
|
// new addresses.
|
||||||
alice := ht.NewNode("Alice", nil)
|
alice := ht.NewNode("Alice", nil)
|
||||||
@@ -985,7 +985,7 @@ func testListAddresses(ht *lntemp.HarnessTest) {
|
|||||||
foundAddresses := 0
|
foundAddresses := 0
|
||||||
for _, addressList := range addressLists.AccountWithAddresses {
|
for _, addressList := range addressLists.AccountWithAddresses {
|
||||||
addresses := addressList.Addresses
|
addresses := addressList.Addresses
|
||||||
derivationPath, err := lntemp.ParseDerivationPath(
|
derivationPath, err := lntest.ParseDerivationPath(
|
||||||
addressList.DerivationPath,
|
addressList.DerivationPath,
|
||||||
)
|
)
|
||||||
require.NoError(ht, err)
|
require.NoError(ht, err)
|
||||||
@@ -1023,7 +1023,7 @@ func testListAddresses(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
for _, addressList := range addressLists.AccountWithAddresses {
|
for _, addressList := range addressLists.AccountWithAddresses {
|
||||||
addresses := addressList.Addresses
|
addresses := addressList.Addresses
|
||||||
derivationPath, err := lntemp.ParseDerivationPath(
|
derivationPath, err := lntest.ParseDerivationPath(
|
||||||
addressList.DerivationPath,
|
addressList.DerivationPath,
|
||||||
)
|
)
|
||||||
require.NoError(ht, err)
|
require.NoError(ht, err)
|
||||||
@@ -1053,7 +1053,7 @@ func testListAddresses(ht *lntemp.HarnessTest) {
|
|||||||
require.Equal(ht, len(generatedAddr), foundAddresses)
|
require.Equal(ht, len(generatedAddr), foundAddresses)
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertChannelConstraintsEqual(ht *lntemp.HarnessTest,
|
func assertChannelConstraintsEqual(ht *lntest.HarnessTest,
|
||||||
want, got *lnrpc.ChannelConstraints) {
|
want, got *lnrpc.ChannelConstraints) {
|
||||||
|
|
||||||
require.Equal(ht, want.CsvDelay, got.CsvDelay, "CsvDelay mismatched")
|
require.Equal(ht, want.CsvDelay, got.CsvDelay, "CsvDelay mismatched")
|
||||||
@@ -1076,7 +1076,7 @@ func assertChannelConstraintsEqual(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testSignVerifyMessageWithAddr tests signing and also verifying a signature
|
// testSignVerifyMessageWithAddr tests signing and also verifying a signature
|
||||||
// on a message with a provided address.
|
// on a message with a provided address.
|
||||||
func testSignVerifyMessageWithAddr(ht *lntemp.HarnessTest) {
|
func testSignVerifyMessageWithAddr(ht *lntest.HarnessTest) {
|
||||||
// Using different nodes to sign the message and verify the signature.
|
// Using different nodes to sign the message and verify the signature.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
// testSendToRouteMultiPath tests that we are able to successfully route a
|
// testSendToRouteMultiPath tests that we are able to successfully route a
|
||||||
// payment using multiple shards across different paths, by using SendToRoute.
|
// payment using multiple shards across different paths, by using SendToRoute.
|
||||||
func testSendToRouteMultiPath(ht *lntemp.HarnessTest) {
|
func testSendToRouteMultiPath(ht *lntest.HarnessTest) {
|
||||||
mts := newMppTestScenario(ht)
|
mts := newMppTestScenario(ht)
|
||||||
|
|
||||||
// To ensure the payment goes through separate paths, we'll set a
|
// To ensure the payment goes through separate paths, we'll set a
|
||||||
@@ -162,7 +162,7 @@ func testSendToRouteMultiPath(ht *lntemp.HarnessTest) {
|
|||||||
// It has two standby nodes, alice and bob, and three new nodes, carol, dave,
|
// It has two standby nodes, alice and bob, and three new nodes, carol, dave,
|
||||||
// and eve.
|
// and eve.
|
||||||
type mppTestScenario struct {
|
type mppTestScenario struct {
|
||||||
ht *lntemp.HarnessTest
|
ht *lntest.HarnessTest
|
||||||
|
|
||||||
alice, bob, carol, dave, eve *node.HarnessNode
|
alice, bob, carol, dave, eve *node.HarnessNode
|
||||||
nodes []*node.HarnessNode
|
nodes []*node.HarnessNode
|
||||||
@@ -179,7 +179,7 @@ type mppTestScenario struct {
|
|||||||
// Alice -- Carol ---- Bob
|
// Alice -- Carol ---- Bob
|
||||||
// \ /
|
// \ /
|
||||||
// \__ Dave ____/
|
// \__ Dave ____/
|
||||||
func newMppTestScenario(ht *lntemp.HarnessTest) *mppTestScenario {
|
func newMppTestScenario(ht *lntest.HarnessTest) *mppTestScenario {
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
ht.RestartNodeWithExtraArgs(bob, []string{
|
ht.RestartNodeWithExtraArgs(bob, []string{
|
||||||
"--maxpendingchannels=2",
|
"--maxpendingchannels=2",
|
||||||
@@ -256,36 +256,36 @@ type mppOpenChannelRequest struct {
|
|||||||
//
|
//
|
||||||
// NOTE: all the channels are open together to save blocks mined.
|
// NOTE: all the channels are open together to save blocks mined.
|
||||||
func (m *mppTestScenario) openChannels(r *mppOpenChannelRequest) {
|
func (m *mppTestScenario) openChannels(r *mppOpenChannelRequest) {
|
||||||
reqs := []*lntemp.OpenChannelRequest{
|
reqs := []*lntest.OpenChannelRequest{
|
||||||
{
|
{
|
||||||
Local: m.alice,
|
Local: m.alice,
|
||||||
Remote: m.carol,
|
Remote: m.carol,
|
||||||
Param: lntemp.OpenChannelParams{Amt: r.amtAliceCarol},
|
Param: lntest.OpenChannelParams{Amt: r.amtAliceCarol},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Local: m.alice,
|
Local: m.alice,
|
||||||
Remote: m.dave,
|
Remote: m.dave,
|
||||||
Param: lntemp.OpenChannelParams{Amt: r.amtAliceDave},
|
Param: lntest.OpenChannelParams{Amt: r.amtAliceDave},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Local: m.carol,
|
Local: m.carol,
|
||||||
Remote: m.bob,
|
Remote: m.bob,
|
||||||
Param: lntemp.OpenChannelParams{Amt: r.amtCarolBob},
|
Param: lntest.OpenChannelParams{Amt: r.amtCarolBob},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Local: m.carol,
|
Local: m.carol,
|
||||||
Remote: m.eve,
|
Remote: m.eve,
|
||||||
Param: lntemp.OpenChannelParams{Amt: r.amtCarolEve},
|
Param: lntest.OpenChannelParams{Amt: r.amtCarolEve},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Local: m.dave,
|
Local: m.dave,
|
||||||
Remote: m.bob,
|
Remote: m.bob,
|
||||||
Param: lntemp.OpenChannelParams{Amt: r.amtDaveBob},
|
Param: lntest.OpenChannelParams{Amt: r.amtDaveBob},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Local: m.eve,
|
Local: m.eve,
|
||||||
Remote: m.bob,
|
Remote: m.bob,
|
||||||
Param: lntemp.OpenChannelParams{Amt: r.amtEveBob},
|
Param: lntest.OpenChannelParams{Amt: r.amtEveBob},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
func testHtlcErrorPropagation(ht *lntest.HarnessTest) {
|
||||||
// In this test we wish to exercise the daemon's correct parsing,
|
// In this test we wish to exercise the daemon's correct parsing,
|
||||||
// handling, and propagation of errors that occur while processing a
|
// handling, and propagation of errors that occur while processing a
|
||||||
// multi-hop payment.
|
// multi-hop payment.
|
||||||
@@ -39,7 +39,7 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// and Bob.
|
// and Bob.
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, bob,
|
alice, bob,
|
||||||
lntemp.OpenChannelParams{Amt: chanAmt},
|
lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Next, we'll create a connection from Bob to Carol, and open a
|
// Next, we'll create a connection from Bob to Carol, and open a
|
||||||
@@ -48,14 +48,14 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// above.
|
// above.
|
||||||
const bobChanAmt = funding.MaxBtcFundingAmount
|
const bobChanAmt = funding.MaxBtcFundingAmount
|
||||||
chanPointBob := ht.OpenChannel(
|
chanPointBob := ht.OpenChannel(
|
||||||
bob, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
bob, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure that Alice has Carol in her routing table before proceeding.
|
// Ensure that Alice has Carol in her routing table before proceeding.
|
||||||
ht.AssertTopologyChannelOpen(alice, chanPointBob)
|
ht.AssertTopologyChannelOpen(alice, chanPointBob)
|
||||||
|
|
||||||
cType := ht.GetChannelCommitType(alice, chanPointAlice)
|
cType := ht.GetChannelCommitType(alice, chanPointAlice)
|
||||||
commitFee := lntemp.CalcStaticFee(cType, 0)
|
commitFee := lntest.CalcStaticFee(cType, 0)
|
||||||
|
|
||||||
assertBaseBalance := func() {
|
assertBaseBalance := func() {
|
||||||
// Alice has opened a channel with Bob with zero push amount,
|
// Alice has opened a channel with Bob with zero push amount,
|
||||||
@@ -153,24 +153,24 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
assertAliceAndBob := func() {
|
assertAliceAndBob := func() {
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
aliceEvents, routerrpc.HtlcEvent_SEND,
|
aliceEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventForward,
|
lntest.HtlcEventForward,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
aliceEvents, routerrpc.HtlcEvent_SEND,
|
aliceEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventForwardFail,
|
lntest.HtlcEventForwardFail,
|
||||||
)
|
)
|
||||||
|
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
bobEvents, routerrpc.HtlcEvent_FORWARD,
|
bobEvents, routerrpc.HtlcEvent_FORWARD,
|
||||||
lntemp.HtlcEventForward,
|
lntest.HtlcEventForward,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
bobEvents, routerrpc.HtlcEvent_FORWARD,
|
bobEvents, routerrpc.HtlcEvent_FORWARD,
|
||||||
lntemp.HtlcEventForwardFail,
|
lntest.HtlcEventForwardFail,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
bobEvents, routerrpc.HtlcEvent_UNKNOWN,
|
bobEvents, routerrpc.HtlcEvent_UNKNOWN,
|
||||||
lntemp.HtlcEventFinal,
|
lntest.HtlcEventFinal,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// There's also a final htlc event that gives the final outcome of the
|
// There's also a final htlc event that gives the final outcome of the
|
||||||
// htlc.
|
// htlc.
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
carolEvents, routerrpc.HtlcEvent_UNKNOWN, lntemp.HtlcEventFinal,
|
carolEvents, routerrpc.HtlcEvent_UNKNOWN, lntest.HtlcEventFinal,
|
||||||
)
|
)
|
||||||
|
|
||||||
// The balances of all parties should be the same as initially since
|
// The balances of all parties should be the same as initially since
|
||||||
@@ -228,7 +228,7 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// There's also a final htlc event that gives the final outcome of the
|
// There's also a final htlc event that gives the final outcome of the
|
||||||
// htlc.
|
// htlc.
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
carolEvents, routerrpc.HtlcEvent_UNKNOWN, lntemp.HtlcEventFinal,
|
carolEvents, routerrpc.HtlcEvent_UNKNOWN, lntest.HtlcEventFinal,
|
||||||
)
|
)
|
||||||
|
|
||||||
// The balances of all parties should be the same as initially since
|
// The balances of all parties should be the same as initially since
|
||||||
@@ -273,19 +273,19 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// settle event and a final htlc event for her receive.
|
// settle event and a final htlc event for her receive.
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
bobEvents, routerrpc.HtlcEvent_SEND,
|
bobEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventForward,
|
lntest.HtlcEventForward,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
bobEvents, routerrpc.HtlcEvent_SEND,
|
bobEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventSettle,
|
lntest.HtlcEventSettle,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
carolEvents, routerrpc.HtlcEvent_RECEIVE,
|
carolEvents, routerrpc.HtlcEvent_RECEIVE,
|
||||||
lntemp.HtlcEventSettle,
|
lntest.HtlcEventSettle,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
carolEvents, routerrpc.HtlcEvent_UNKNOWN,
|
carolEvents, routerrpc.HtlcEvent_UNKNOWN,
|
||||||
lntemp.HtlcEventFinal,
|
lntest.HtlcEventFinal,
|
||||||
)
|
)
|
||||||
|
|
||||||
amtSent += toSend
|
amtSent += toSend
|
||||||
@@ -316,11 +316,11 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// Alice should have a forwarding event and a forwarding failure.
|
// Alice should have a forwarding event and a forwarding failure.
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
aliceEvents, routerrpc.HtlcEvent_SEND,
|
aliceEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventForward,
|
lntest.HtlcEventForward,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
aliceEvents, routerrpc.HtlcEvent_SEND,
|
aliceEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventForwardFail,
|
lntest.HtlcEventForwardFail,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Bob should have a link failure because the htlc failed on his
|
// Bob should have a link failure because the htlc failed on his
|
||||||
@@ -331,7 +331,7 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// There's also a final htlc event that gives the final outcome of the
|
// There's also a final htlc event that gives the final outcome of the
|
||||||
// htlc.
|
// htlc.
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
bobEvents, routerrpc.HtlcEvent_UNKNOWN, lntemp.HtlcEventFinal,
|
bobEvents, routerrpc.HtlcEvent_UNKNOWN, lntest.HtlcEventFinal,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Generate new invoice to not pay same invoice twice.
|
// Generate new invoice to not pay same invoice twice.
|
||||||
@@ -362,11 +362,11 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// Alice should have a forwarding event and subsequent fail.
|
// Alice should have a forwarding event and subsequent fail.
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
aliceEvents, routerrpc.HtlcEvent_SEND,
|
aliceEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventForward,
|
lntest.HtlcEventForward,
|
||||||
)
|
)
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
aliceEvents, routerrpc.HtlcEvent_SEND,
|
aliceEvents, routerrpc.HtlcEvent_SEND,
|
||||||
lntemp.HtlcEventForwardFail,
|
lntest.HtlcEventForwardFail,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Bob should have a link failure because he could not find the next
|
// Bob should have a link failure because he could not find the next
|
||||||
@@ -377,7 +377,7 @@ func testHtlcErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// There's also a final htlc event that gives the final outcome of the
|
// There's also a final htlc event that gives the final outcome of the
|
||||||
// htlc.
|
// htlc.
|
||||||
ht.AssertHtlcEventTypes(
|
ht.AssertHtlcEventTypes(
|
||||||
bobEvents, routerrpc.HtlcEvent_UNKNOWN, lntemp.HtlcEventFinal,
|
bobEvents, routerrpc.HtlcEvent_UNKNOWN, lntest.HtlcEventFinal,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Finally, immediately close the channel. This function will also
|
// Finally, immediately close the channel. This function will also
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testMultiHopPayments(ht *lntemp.HarnessTest) {
|
func testMultiHopPayments(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = btcutil.Amount(100000)
|
const chanAmt = btcutil.Amount(100000)
|
||||||
|
|
||||||
// As preliminary setup, we'll create two new nodes: Carol and Dave,
|
// As preliminary setup, we'll create two new nodes: Carol and Dave,
|
||||||
@@ -43,21 +43,21 @@ func testMultiHopPayments(ht *lntemp.HarnessTest) {
|
|||||||
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// We'll create Dave and establish a channel to Alice. Dave will be
|
// We'll create Dave and establish a channel to Alice. Dave will be
|
||||||
// running an older node that requires the legacy onion payload.
|
// running an older node that requires the legacy onion payload.
|
||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
|
||||||
chanPointDave := ht.OpenChannel(
|
chanPointDave := ht.OpenChannel(
|
||||||
dave, alice, lntemp.OpenChannelParams{Amt: chanAmt},
|
dave, alice, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Next, we'll create Carol and establish a channel to from her to
|
// Next, we'll create Carol and establish a channel to from her to
|
||||||
// Dave.
|
// Dave.
|
||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||||
chanPointCarol := ht.OpenChannel(
|
chanPointCarol := ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{Amt: chanAmt},
|
carol, dave, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create 5 invoices for Bob, which expect a payment from Carol for 1k
|
// Create 5 invoices for Bob, which expect a payment from Carol for 1k
|
||||||
@@ -69,7 +69,7 @@ func testMultiHopPayments(ht *lntemp.HarnessTest) {
|
|||||||
// Set the fee policies of the Alice -> Bob and the Dave -> Alice
|
// Set the fee policies of the Alice -> Bob and the Dave -> Alice
|
||||||
// channel edges to relatively large non default values. This makes it
|
// channel edges to relatively large non default values. This makes it
|
||||||
// possible to pick up more subtle fee calculation errors.
|
// possible to pick up more subtle fee calculation errors.
|
||||||
maxHtlc := lntemp.CalculateMaxHtlc(chanAmt)
|
maxHtlc := lntest.CalculateMaxHtlc(chanAmt)
|
||||||
const aliceBaseFeeSat = 1
|
const aliceBaseFeeSat = 1
|
||||||
const aliceFeeRatePPM = 100000
|
const aliceFeeRatePPM = 100000
|
||||||
updateChannelPolicy(
|
updateChannelPolicy(
|
||||||
@@ -222,7 +222,7 @@ func testMultiHopPayments(ht *lntemp.HarnessTest) {
|
|||||||
// policy update.
|
// policy update.
|
||||||
//
|
//
|
||||||
// NOTE: only used in current test.
|
// NOTE: only used in current test.
|
||||||
func updateChannelPolicy(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func updateChannelPolicy(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
chanPoint *lnrpc.ChannelPoint, baseFee int64,
|
chanPoint *lnrpc.ChannelPoint, baseFee int64,
|
||||||
feeRate int64, timeLockDelta uint32,
|
feeRate int64, timeLockDelta uint32,
|
||||||
maxHtlc uint64, listenerNode *node.HarnessNode) {
|
maxHtlc uint64, listenerNode *node.HarnessNode) {
|
||||||
|
|||||||
+32
-32
@@ -12,9 +12,9 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/routing"
|
"github.com/lightningnetwork/lnd/routing"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -52,12 +52,12 @@ var commitWithZeroConf = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// caseRunner defines a single test case runner.
|
// caseRunner defines a single test case runner.
|
||||||
type caseRunner func(ht *lntemp.HarnessTest, alice, bob *node.HarnessNode,
|
type caseRunner func(ht *lntest.HarnessTest, alice, bob *node.HarnessNode,
|
||||||
c lnrpc.CommitmentType, zeroConf bool)
|
c lnrpc.CommitmentType, zeroConf bool)
|
||||||
|
|
||||||
// runMultiHopHtlcClaimTest is a helper method to build test cases based on
|
// runMultiHopHtlcClaimTest is a helper method to build test cases based on
|
||||||
// different commitment types and zero-conf config and run them.
|
// different commitment types and zero-conf config and run them.
|
||||||
func runMultiHopHtlcClaimTest(ht *lntemp.HarnessTest, tester caseRunner) {
|
func runMultiHopHtlcClaimTest(ht *lntest.HarnessTest, tester caseRunner) {
|
||||||
for _, typeAndConf := range commitWithZeroConf {
|
for _, typeAndConf := range commitWithZeroConf {
|
||||||
typeAndConf := typeAndConf
|
typeAndConf := typeAndConf
|
||||||
name := fmt.Sprintf("zeroconf=%v/committype=%v",
|
name := fmt.Sprintf("zeroconf=%v/committype=%v",
|
||||||
@@ -65,7 +65,7 @@ func runMultiHopHtlcClaimTest(ht *lntemp.HarnessTest, tester caseRunner) {
|
|||||||
|
|
||||||
// Create the nodes here so that separate logs will be created
|
// Create the nodes here so that separate logs will be created
|
||||||
// for Alice and Bob.
|
// for Alice and Bob.
|
||||||
args := lntemp.NodeArgsForCommitType(typeAndConf.commitType)
|
args := lntest.NodeArgsForCommitType(typeAndConf.commitType)
|
||||||
if typeAndConf.zeroConf {
|
if typeAndConf.zeroConf {
|
||||||
args = append(
|
args = append(
|
||||||
args, "--protocol.option-scid-alias",
|
args, "--protocol.option-scid-alias",
|
||||||
@@ -103,11 +103,11 @@ func runMultiHopHtlcClaimTest(ht *lntemp.HarnessTest, tester caseRunner) {
|
|||||||
// it using the HTLC timeout transaction. Any dust HTLC's should be immediately
|
// it using the HTLC timeout transaction. Any dust HTLC's should be immediately
|
||||||
// canceled backwards. Once the timeout has been reached, then we should sweep
|
// canceled backwards. Once the timeout has been reached, then we should sweep
|
||||||
// it on-chain, and cancel the HTLC backwards.
|
// it on-chain, and cancel the HTLC backwards.
|
||||||
func testMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest) {
|
func testMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest) {
|
||||||
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcLocalTimeout)
|
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcLocalTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
func runMultiHopHtlcLocalTimeout(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
||||||
@@ -171,7 +171,7 @@ func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
|||||||
// Bob's force close transaction should now be found in the mempool. If
|
// Bob's force close transaction should now be found in the mempool. If
|
||||||
// there are anchors, we also expect Bob's anchor sweep.
|
// there are anchors, we also expect Bob's anchor sweep.
|
||||||
expectedTxes := 1
|
expectedTxes := 1
|
||||||
hasAnchors := lntemp.CommitTypeHasAnchors(c)
|
hasAnchors := lntest.CommitTypeHasAnchors(c)
|
||||||
if hasAnchors {
|
if hasAnchors {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
}
|
}
|
||||||
@@ -272,11 +272,11 @@ func runMultiHopHtlcLocalTimeout(ht *lntemp.HarnessTest,
|
|||||||
// transaction. In this scenario, the node that sent the outgoing HTLC should
|
// transaction. In this scenario, the node that sent the outgoing HTLC should
|
||||||
// extract the preimage from the sweep transaction, and finish settling the
|
// extract the preimage from the sweep transaction, and finish settling the
|
||||||
// HTLC backwards into the route.
|
// HTLC backwards into the route.
|
||||||
func testMultiHopReceiverChainClaim(ht *lntemp.HarnessTest) {
|
func testMultiHopReceiverChainClaim(ht *lntest.HarnessTest) {
|
||||||
runMultiHopHtlcClaimTest(ht, runMultiHopReceiverChainClaim)
|
runMultiHopHtlcClaimTest(ht, runMultiHopReceiverChainClaim)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
func runMultiHopReceiverChainClaim(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
||||||
@@ -348,7 +348,7 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// transaction in order to go to the chain and sweep her HTLC. If there
|
// transaction in order to go to the chain and sweep her HTLC. If there
|
||||||
// are anchors, Carol also sweeps hers.
|
// are anchors, Carol also sweeps hers.
|
||||||
expectedTxes := 1
|
expectedTxes := 1
|
||||||
hasAnchors := lntemp.CommitTypeHasAnchors(c)
|
hasAnchors := lntest.CommitTypeHasAnchors(c)
|
||||||
if hasAnchors {
|
if hasAnchors {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
}
|
}
|
||||||
@@ -470,13 +470,13 @@ func runMultiHopReceiverChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// commitment on-chain early, then it eventually recognizes this HTLC as one
|
// commitment on-chain early, then it eventually recognizes this HTLC as one
|
||||||
// that's timed out. At this point, the node should timeout the HTLC using the
|
// that's timed out. At this point, the node should timeout the HTLC using the
|
||||||
// HTLC timeout transaction, then cancel it backwards as normal.
|
// HTLC timeout transaction, then cancel it backwards as normal.
|
||||||
func testMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest) {
|
func testMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest) {
|
||||||
runMultiHopHtlcClaimTest(
|
runMultiHopHtlcClaimTest(
|
||||||
ht, runMultiHopLocalForceCloseOnChainHtlcTimeout,
|
ht, runMultiHopLocalForceCloseOnChainHtlcTimeout,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
||||||
@@ -517,7 +517,7 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
// Now that all parties have the HTLC locked in, we'll immediately
|
// Now that all parties have the HTLC locked in, we'll immediately
|
||||||
// force close the Bob -> Carol channel. This should trigger contract
|
// force close the Bob -> Carol channel. This should trigger contract
|
||||||
// resolution mode for both of them.
|
// resolution mode for both of them.
|
||||||
hasAnchors := lntemp.CommitTypeHasAnchors(c)
|
hasAnchors := lntest.CommitTypeHasAnchors(c)
|
||||||
stream, _ := ht.CloseChannelAssertPending(bob, bobChanPoint, true)
|
stream, _ := ht.CloseChannelAssertPending(bob, bobChanPoint, true)
|
||||||
closeTx := ht.AssertStreamChannelForceClosed(
|
closeTx := ht.AssertStreamChannelForceClosed(
|
||||||
bob, bobChanPoint, hasAnchors, stream,
|
bob, bobChanPoint, hasAnchors, stream,
|
||||||
@@ -626,13 +626,13 @@ func runMultiHopLocalForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
// channel, then we properly timeout the HTLC directly on *their* commitment
|
// channel, then we properly timeout the HTLC directly on *their* commitment
|
||||||
// transaction once the timeout has expired. Once we sweep the transaction, we
|
// transaction once the timeout has expired. Once we sweep the transaction, we
|
||||||
// should also cancel back the initial HTLC.
|
// should also cancel back the initial HTLC.
|
||||||
func testMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest) {
|
func testMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest) {
|
||||||
runMultiHopHtlcClaimTest(
|
runMultiHopHtlcClaimTest(
|
||||||
ht, runMultiHopRemoteForceCloseOnChainHtlcTimeout,
|
ht, runMultiHopRemoteForceCloseOnChainHtlcTimeout,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
||||||
@@ -682,7 +682,7 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
// transaction. This will let us exercise that Bob is able to sweep the
|
// transaction. This will let us exercise that Bob is able to sweep the
|
||||||
// expired HTLC on Carol's version of the commitment transaction. If
|
// expired HTLC on Carol's version of the commitment transaction. If
|
||||||
// Carol has an anchor, it will be swept too.
|
// Carol has an anchor, it will be swept too.
|
||||||
hasAnchors := lntemp.CommitTypeHasAnchors(c)
|
hasAnchors := lntest.CommitTypeHasAnchors(c)
|
||||||
closeStream, _ := ht.CloseChannelAssertPending(
|
closeStream, _ := ht.CloseChannelAssertPending(
|
||||||
carol, bobChanPoint, true,
|
carol, bobChanPoint, true,
|
||||||
)
|
)
|
||||||
@@ -782,11 +782,11 @@ func runMultiHopRemoteForceCloseOnChainHtlcTimeout(ht *lntemp.HarnessTest,
|
|||||||
// we force close a channel with an incoming HTLC, and later find out the
|
// we force close a channel with an incoming HTLC, and later find out the
|
||||||
// preimage via the witness beacon, we properly settle the HTLC on-chain using
|
// preimage via the witness beacon, we properly settle the HTLC on-chain using
|
||||||
// the HTLC success transaction in order to ensure we don't lose any funds.
|
// the HTLC success transaction in order to ensure we don't lose any funds.
|
||||||
func testMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest) {
|
func testMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest) {
|
||||||
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcLocalChainClaim)
|
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcLocalChainClaim)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
func runMultiHopHtlcLocalChainClaim(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
||||||
@@ -840,7 +840,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// At this point, Bob decides that he wants to exit the channel
|
// At this point, Bob decides that he wants to exit the channel
|
||||||
// immediately, so he force closes his commitment transaction.
|
// immediately, so he force closes his commitment transaction.
|
||||||
hasAnchors := lntemp.CommitTypeHasAnchors(c)
|
hasAnchors := lntest.CommitTypeHasAnchors(c)
|
||||||
closeStream, _ := ht.CloseChannelAssertPending(
|
closeStream, _ := ht.CloseChannelAssertPending(
|
||||||
bob, aliceChanPoint, true,
|
bob, aliceChanPoint, true,
|
||||||
)
|
)
|
||||||
@@ -888,7 +888,7 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// Carol's commitment transaction should now be in the mempool. If
|
// Carol's commitment transaction should now be in the mempool. If
|
||||||
// there is an anchor, Carol will sweep that too.
|
// there is an anchor, Carol will sweep that too.
|
||||||
if lntemp.CommitTypeHasAnchors(c) {
|
if lntest.CommitTypeHasAnchors(c) {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
}
|
}
|
||||||
ht.Miner.AssertNumTxsInMempool(expectedTxes)
|
ht.Miner.AssertNumTxsInMempool(expectedTxes)
|
||||||
@@ -1076,11 +1076,11 @@ func runMultiHopHtlcLocalChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// we found out the preimage via the witness beacon, we properly settle the
|
// we found out the preimage via the witness beacon, we properly settle the
|
||||||
// HTLC directly on-chain using the preimage in order to ensure that we don't
|
// HTLC directly on-chain using the preimage in order to ensure that we don't
|
||||||
// lose any funds.
|
// lose any funds.
|
||||||
func testMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest) {
|
func testMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest) {
|
||||||
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcRemoteChainClaim)
|
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcRemoteChainClaim)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
func runMultiHopHtlcRemoteChainClaim(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
|
||||||
@@ -1135,7 +1135,7 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// Next, Alice decides that she wants to exit the channel, so she'll
|
// Next, Alice decides that she wants to exit the channel, so she'll
|
||||||
// immediately force close the channel by broadcast her commitment
|
// immediately force close the channel by broadcast her commitment
|
||||||
// transaction.
|
// transaction.
|
||||||
hasAnchors := lntemp.CommitTypeHasAnchors(c)
|
hasAnchors := lntest.CommitTypeHasAnchors(c)
|
||||||
closeStream, _ := ht.CloseChannelAssertPending(
|
closeStream, _ := ht.CloseChannelAssertPending(
|
||||||
alice, aliceChanPoint, true,
|
alice, aliceChanPoint, true,
|
||||||
)
|
)
|
||||||
@@ -1346,11 +1346,11 @@ func runMultiHopHtlcRemoteChainClaim(ht *lntemp.HarnessTest,
|
|||||||
// resolve them using the second level timeout and success transactions. In
|
// resolve them using the second level timeout and success transactions. In
|
||||||
// case of anchor channels, the second-level spends can also be aggregated and
|
// case of anchor channels, the second-level spends can also be aggregated and
|
||||||
// properly feebumped, so we'll check that as well.
|
// properly feebumped, so we'll check that as well.
|
||||||
func testMultiHopHtlcAggregation(ht *lntemp.HarnessTest) {
|
func testMultiHopHtlcAggregation(ht *lntest.HarnessTest) {
|
||||||
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcAggregation)
|
runMultiHopHtlcClaimTest(ht, runMultiHopHtlcAggregation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
func runMultiHopHtlcAggregation(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
alice, bob *node.HarnessNode, c lnrpc.CommitmentType, zeroConf bool) {
|
||||||
|
|
||||||
// First, we'll create a three hop network: Alice -> Bob -> Carol.
|
// First, we'll create a three hop network: Alice -> Bob -> Carol.
|
||||||
@@ -1489,7 +1489,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// Bob's force close transaction should now be found in the mempool. If
|
// Bob's force close transaction should now be found in the mempool. If
|
||||||
// there are anchors, we also expect Bob's anchor sweep.
|
// there are anchors, we also expect Bob's anchor sweep.
|
||||||
hasAnchors := lntemp.CommitTypeHasAnchors(c)
|
hasAnchors := lntest.CommitTypeHasAnchors(c)
|
||||||
expectedTxes := 1
|
expectedTxes := 1
|
||||||
if hasAnchors {
|
if hasAnchors {
|
||||||
expectedTxes = 2
|
expectedTxes = 2
|
||||||
@@ -1728,7 +1728,7 @@ func runMultiHopHtlcAggregation(ht *lntemp.HarnessTest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createThreeHopNetwork creates a topology of `Alice -> Bob -> Carol`.
|
// createThreeHopNetwork creates a topology of `Alice -> Bob -> Carol`.
|
||||||
func createThreeHopNetwork(ht *lntemp.HarnessTest,
|
func createThreeHopNetwork(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode, carolHodl bool, c lnrpc.CommitmentType,
|
alice, bob *node.HarnessNode, carolHodl bool, c lnrpc.CommitmentType,
|
||||||
zeroConf bool) (*lnrpc.ChannelPoint,
|
zeroConf bool) (*lnrpc.ChannelPoint,
|
||||||
*lnrpc.ChannelPoint, *node.HarnessNode) {
|
*lnrpc.ChannelPoint, *node.HarnessNode) {
|
||||||
@@ -1738,7 +1738,7 @@ func createThreeHopNetwork(ht *lntemp.HarnessTest,
|
|||||||
// We'll create a new node "carol" and have Bob connect to her.
|
// We'll create a new node "carol" and have Bob connect to her.
|
||||||
// If the carolHodl flag is set, we'll make carol always hold onto the
|
// If the carolHodl flag is set, we'll make carol always hold onto the
|
||||||
// HTLC, this way it'll force Bob to go to chain to resolve the HTLC.
|
// HTLC, this way it'll force Bob to go to chain to resolve the HTLC.
|
||||||
carolFlags := lntemp.NodeArgsForCommitType(c)
|
carolFlags := lntest.NodeArgsForCommitType(c)
|
||||||
if carolHodl {
|
if carolHodl {
|
||||||
carolFlags = append(carolFlags, "--hodl.exit-settle")
|
carolFlags = append(carolFlags, "--hodl.exit-settle")
|
||||||
}
|
}
|
||||||
@@ -1790,7 +1790,7 @@ func createThreeHopNetwork(ht *lntemp.HarnessTest,
|
|||||||
go acceptChannel(ht.T, true, acceptStream)
|
go acceptChannel(ht.T, true, acceptStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
aliceParams := lntemp.OpenChannelParams{
|
aliceParams := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
CommitmentType: c,
|
CommitmentType: c,
|
||||||
FundingShim: aliceFundingShim,
|
FundingShim: aliceFundingShim,
|
||||||
@@ -1819,7 +1819,7 @@ func createThreeHopNetwork(ht *lntemp.HarnessTest,
|
|||||||
go acceptChannel(ht.T, true, acceptStream)
|
go acceptChannel(ht.T, true, acceptStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
bobParams := lntemp.OpenChannelParams{
|
bobParams := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
CommitmentType: c,
|
CommitmentType: c,
|
||||||
FundingShim: bobFundingShim,
|
FundingShim: bobFundingShim,
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
|
|
||||||
"github.com/lightningnetwork/lnd/lncfg"
|
"github.com/lightningnetwork/lnd/lncfg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
// testNetworkConnectionTimeout checks that the connectiontimeout is taking
|
// testNetworkConnectionTimeout checks that the connectiontimeout is taking
|
||||||
// effect. It creates a node with a small connection timeout value, and
|
// effect. It creates a node with a small connection timeout value, and
|
||||||
// connects it to a non-routable IP address.
|
// connects it to a non-routable IP address.
|
||||||
func testNetworkConnectionTimeout(ht *lntemp.HarnessTest) {
|
func testNetworkConnectionTimeout(ht *lntest.HarnessTest) {
|
||||||
var (
|
var (
|
||||||
// testPub is a random public key for testing only.
|
// testPub is a random public key for testing only.
|
||||||
testPub = "0332bda7da70fefe4b6ab92f53b3c4f4ee7999" +
|
testPub = "0332bda7da70fefe4b6ab92f53b3c4f4ee7999" +
|
||||||
@@ -74,7 +74,7 @@ func testNetworkConnectionTimeout(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testReconnectAfterIPChange verifies that if a persistent inbound node changes
|
// testReconnectAfterIPChange verifies that if a persistent inbound node changes
|
||||||
// its listening address then it's peer will still be able to reconnect to it.
|
// its listening address then it's peer will still be able to reconnect to it.
|
||||||
func testReconnectAfterIPChange(ht *lntemp.HarnessTest) {
|
func testReconnectAfterIPChange(ht *lntest.HarnessTest) {
|
||||||
// In this test, the following network will be set up. A single
|
// In this test, the following network will be set up. A single
|
||||||
// dash line represents a peer connection and a double dash line
|
// dash line represents a peer connection and a double dash line
|
||||||
// represents a channel.
|
// represents a channel.
|
||||||
@@ -126,7 +126,7 @@ func testReconnectAfterIPChange(ht *lntemp.HarnessTest) {
|
|||||||
// ensures that Charlie receives the node announcement from Alice as
|
// ensures that Charlie receives the node announcement from Alice as
|
||||||
// part of the announcement broadcast.
|
// part of the announcement broadcast.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, dave, lntemp.OpenChannelParams{Amt: 1000000},
|
alice, dave, lntest.OpenChannelParams{Amt: 1000000},
|
||||||
)
|
)
|
||||||
|
|
||||||
// waitForNodeAnnouncement is a closure used to wait on the given graph
|
// waitForNodeAnnouncement is a closure used to wait on the given graph
|
||||||
@@ -209,7 +209,7 @@ func testReconnectAfterIPChange(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testAddPeerConfig tests that the "--addpeer" config flag successfully adds
|
// testAddPeerConfig tests that the "--addpeer" config flag successfully adds
|
||||||
// a new peer.
|
// a new peer.
|
||||||
func testAddPeerConfig(ht *lntemp.HarnessTest) {
|
func testAddPeerConfig(ht *lntest.HarnessTest) {
|
||||||
alice := ht.Alice
|
alice := ht.Alice
|
||||||
info := alice.RPC.GetInfo()
|
info := alice.RPC.GetInfo()
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package itest
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/neutrinorpc"
|
"github.com/lightningnetwork/lnd/lnrpc/neutrinorpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testNeutrino checks that the neutrino sub-server can fetch compact
|
// testNeutrino checks that the neutrino sub-server can fetch compact
|
||||||
// block filters, server status and connect to a connected peer.
|
// block filters, server status and connect to a connected peer.
|
||||||
func testNeutrino(ht *lntemp.HarnessTest) {
|
func testNeutrino(ht *lntest.HarnessTest) {
|
||||||
if !ht.IsNeutrinoBackend() {
|
if !ht.IsNeutrinoBackend() {
|
||||||
ht.Skipf("skipping test for non neutrino backends")
|
ht.Skipf("skipping test for non neutrino backends")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
package itest
|
package itest
|
||||||
|
|
||||||
import "github.com/lightningnetwork/lnd/lntemp"
|
import "github.com/lightningnetwork/lnd/lntest"
|
||||||
|
|
||||||
// testEtcdFailover is an empty itest when LND is not compiled with etcd
|
// testEtcdFailover is an empty itest when LND is not compiled with etcd
|
||||||
// support.
|
// support.
|
||||||
func testEtcdFailover(ht *lntemp.HarnessTest) {}
|
func testEtcdFailover(ht *lntest.HarnessTest) {}
|
||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testNonstdSweep(ht *lntemp.HarnessTest) {
|
func testNonstdSweep(ht *lntest.HarnessTest) {
|
||||||
p2shAddr, err := btcutil.NewAddressScriptHash(
|
p2shAddr, err := btcutil.NewAddressScriptHash(
|
||||||
make([]byte, 1), harnessNetParams,
|
make([]byte, 1), harnessNetParams,
|
||||||
)
|
)
|
||||||
@@ -74,7 +74,7 @@ func testNonstdSweep(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNonStdSweepInner(ht *lntemp.HarnessTest, address string) {
|
func testNonStdSweepInner(ht *lntest.HarnessTest, address string) {
|
||||||
carol := ht.NewNode("carol", nil)
|
carol := ht.NewNode("carol", nil)
|
||||||
|
|
||||||
// Give Carol a UTXO so SendCoins will behave as expected.
|
// Give Carol a UTXO so SendCoins will behave as expected.
|
||||||
|
|||||||
+19
-19
@@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/sweep"
|
"github.com/lightningnetwork/lnd/sweep"
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// testChainKit tests ChainKit RPC endpoints.
|
// testChainKit tests ChainKit RPC endpoints.
|
||||||
func testChainKit(ht *lntemp.HarnessTest) {
|
func testChainKit(ht *lntest.HarnessTest) {
|
||||||
// Test functions registered as test cases spin up separate nodes
|
// Test functions registered as test cases spin up separate nodes
|
||||||
// during execution. By calling sub-test functions as seen below we
|
// during execution. By calling sub-test functions as seen below we
|
||||||
// avoid the need to start separate nodes.
|
// avoid the need to start separate nodes.
|
||||||
@@ -30,7 +30,7 @@ func testChainKit(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testChainKitGetBlock ensures that given a block hash, the RPC endpoint
|
// testChainKitGetBlock ensures that given a block hash, the RPC endpoint
|
||||||
// returns the correct target block.
|
// returns the correct target block.
|
||||||
func testChainKitGetBlock(ht *lntemp.HarnessTest) {
|
func testChainKitGetBlock(ht *lntest.HarnessTest) {
|
||||||
// Get best block hash.
|
// Get best block hash.
|
||||||
bestBlockRes := ht.Alice.RPC.GetBestBlock(nil)
|
bestBlockRes := ht.Alice.RPC.GetBestBlock(nil)
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ func testChainKitGetBlock(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testChainKitGetBlockHash ensures that given a block height, the RPC endpoint
|
// testChainKitGetBlockHash ensures that given a block height, the RPC endpoint
|
||||||
// returns the correct target block hash.
|
// returns the correct target block hash.
|
||||||
func testChainKitGetBlockHash(ht *lntemp.HarnessTest) {
|
func testChainKitGetBlockHash(ht *lntest.HarnessTest) {
|
||||||
// Get best block hash.
|
// Get best block hash.
|
||||||
bestBlockRes := ht.Alice.RPC.GetBestBlock(nil)
|
bestBlockRes := ht.Alice.RPC.GetBestBlock(nil)
|
||||||
|
|
||||||
@@ -78,13 +78,13 @@ func testChainKitGetBlockHash(ht *lntemp.HarnessTest) {
|
|||||||
// rate by broadcasting a Child-Pays-For-Parent (CPFP) transaction.
|
// rate by broadcasting a Child-Pays-For-Parent (CPFP) transaction.
|
||||||
//
|
//
|
||||||
// TODO(wilmer): Add RBF case once btcd supports it.
|
// TODO(wilmer): Add RBF case once btcd supports it.
|
||||||
func testCPFP(ht *lntemp.HarnessTest) {
|
func testCPFP(ht *lntest.HarnessTest) {
|
||||||
runCPFP(ht, ht.Alice, ht.Bob)
|
runCPFP(ht, ht.Alice, ht.Bob)
|
||||||
}
|
}
|
||||||
|
|
||||||
// runCPFP ensures that the daemon can bump an unconfirmed transaction's fee
|
// runCPFP ensures that the daemon can bump an unconfirmed transaction's fee
|
||||||
// rate by broadcasting a Child-Pays-For-Parent (CPFP) transaction.
|
// rate by broadcasting a Child-Pays-For-Parent (CPFP) transaction.
|
||||||
func runCPFP(ht *lntemp.HarnessTest, alice, bob *node.HarnessNode) {
|
func runCPFP(ht *lntest.HarnessTest, alice, bob *node.HarnessNode) {
|
||||||
// Skip this test for neutrino, as it's not aware of mempool
|
// Skip this test for neutrino, as it's not aware of mempool
|
||||||
// transactions.
|
// transactions.
|
||||||
if ht.IsNeutrinoBackend() {
|
if ht.IsNeutrinoBackend() {
|
||||||
@@ -180,9 +180,9 @@ func runCPFP(ht *lntemp.HarnessTest, alice, bob *node.HarnessNode) {
|
|||||||
// testAnchorReservedValue tests that we won't allow sending transactions when
|
// testAnchorReservedValue tests that we won't allow sending transactions when
|
||||||
// that would take the value we reserve for anchor fee bumping out of our
|
// that would take the value we reserve for anchor fee bumping out of our
|
||||||
// wallet.
|
// wallet.
|
||||||
func testAnchorReservedValue(ht *lntemp.HarnessTest) {
|
func testAnchorReservedValue(ht *lntest.HarnessTest) {
|
||||||
// Start two nodes supporting anchor channels.
|
// Start two nodes supporting anchor channels.
|
||||||
args := lntemp.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
|
args := lntest.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
|
||||||
|
|
||||||
// NOTE: we cannot reuse the standby node here as the test requires the
|
// NOTE: we cannot reuse the standby node here as the test requires the
|
||||||
// node to start with no UTXOs.
|
// node to start with no UTXOs.
|
||||||
@@ -203,7 +203,7 @@ func testAnchorReservedValue(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// wallet, without a change output. This should not be allowed.
|
// wallet, without a change output. This should not be allowed.
|
||||||
ht.OpenChannelAssertErr(
|
ht.OpenChannelAssertErr(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
}, lnwallet.ErrReservedValueInvalidated,
|
}, lnwallet.ErrReservedValueInvalidated,
|
||||||
)
|
)
|
||||||
@@ -211,13 +211,13 @@ func testAnchorReservedValue(ht *lntemp.HarnessTest) {
|
|||||||
// Alice opens a smaller channel. This works since it will have a
|
// Alice opens a smaller channel. This works since it will have a
|
||||||
// change output.
|
// change output.
|
||||||
chanPoint1 := ht.OpenChannel(
|
chanPoint1 := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt / 4},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt / 4},
|
||||||
)
|
)
|
||||||
|
|
||||||
// If Alice tries to open another anchor channel to Bob, Bob should not
|
// If Alice tries to open another anchor channel to Bob, Bob should not
|
||||||
// reject it as he is not contributing any funds.
|
// reject it as he is not contributing any funds.
|
||||||
chanPoint2 := ht.OpenChannel(
|
chanPoint2 := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt / 4},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt / 4},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Similarly, if Alice tries to open a legacy channel to Bob, Bob
|
// Similarly, if Alice tries to open a legacy channel to Bob, Bob
|
||||||
@@ -229,7 +229,7 @@ func testAnchorReservedValue(ht *lntemp.HarnessTest) {
|
|||||||
ht.EnsureConnected(alice, bob)
|
ht.EnsureConnected(alice, bob)
|
||||||
|
|
||||||
chanPoint3 := ht.OpenChannel(
|
chanPoint3 := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt / 4},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt / 4},
|
||||||
)
|
)
|
||||||
chanPoints := []*lnrpc.ChannelPoint{chanPoint1, chanPoint2, chanPoint3}
|
chanPoints := []*lnrpc.ChannelPoint{chanPoint1, chanPoint2, chanPoint3}
|
||||||
|
|
||||||
@@ -347,13 +347,13 @@ func testAnchorReservedValue(ht *lntemp.HarnessTest) {
|
|||||||
// testAnchorThirdPartySpend tests that if we force close a channel, but then
|
// testAnchorThirdPartySpend tests that if we force close a channel, but then
|
||||||
// don't sweep the anchor in time and a 3rd party spends it, that we remove any
|
// don't sweep the anchor in time and a 3rd party spends it, that we remove any
|
||||||
// transactions that are a descendent of that sweep.
|
// transactions that are a descendent of that sweep.
|
||||||
func testAnchorThirdPartySpend(ht *lntemp.HarnessTest) {
|
func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
|
||||||
// First, we'll create two new nodes that both default to anchor
|
// First, we'll create two new nodes that both default to anchor
|
||||||
// channels.
|
// channels.
|
||||||
//
|
//
|
||||||
// NOTE: The itests differ here as anchors is default off vs the normal
|
// NOTE: The itests differ here as anchors is default off vs the normal
|
||||||
// lnd binary.
|
// lnd binary.
|
||||||
args := lntemp.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
|
args := lntest.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
|
||||||
alice := ht.NewNode("Alice", args)
|
alice := ht.NewNode("Alice", args)
|
||||||
defer ht.Shutdown(alice)
|
defer ht.Shutdown(alice)
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ func testAnchorThirdPartySpend(ht *lntemp.HarnessTest) {
|
|||||||
// Open the channel between the two nodes and wait for it to confirm
|
// Open the channel between the two nodes and wait for it to confirm
|
||||||
// fully.
|
// fully.
|
||||||
aliceChanPoint1 := ht.OpenChannel(
|
aliceChanPoint1 := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: firstChanSize,
|
Amt: firstChanSize,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -493,7 +493,7 @@ func testAnchorThirdPartySpend(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// assertAnchorOutputLost asserts that the anchor output for the given channel
|
// assertAnchorOutputLost asserts that the anchor output for the given channel
|
||||||
// has the state of being lost.
|
// has the state of being lost.
|
||||||
func assertAnchorOutputLost(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func assertAnchorOutputLost(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
chanPoint *lnrpc.ChannelPoint) {
|
chanPoint *lnrpc.ChannelPoint) {
|
||||||
|
|
||||||
cp := ht.OutPointFromChannelPoint(chanPoint)
|
cp := ht.OutPointFromChannelPoint(chanPoint)
|
||||||
@@ -527,8 +527,8 @@ func assertAnchorOutputLost(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
|||||||
// genAnchorSweep generates a "3rd party" anchor sweeping from an existing one.
|
// genAnchorSweep generates a "3rd party" anchor sweeping from an existing one.
|
||||||
// In practice, we just re-use the existing witness, and track on our own
|
// In practice, we just re-use the existing witness, and track on our own
|
||||||
// output producing a 1-in-1-out transaction.
|
// output producing a 1-in-1-out transaction.
|
||||||
func genAnchorSweep(ht *lntemp.HarnessTest,
|
func genAnchorSweep(ht *lntest.HarnessTest,
|
||||||
aliceAnchor *lntemp.SweptOutput, anchorCsv uint32) *btcutil.Tx {
|
aliceAnchor *lntest.SweptOutput, anchorCsv uint32) *btcutil.Tx {
|
||||||
|
|
||||||
// At this point, we have the transaction that Alice used to try to
|
// At this point, we have the transaction that Alice used to try to
|
||||||
// sweep her anchor. As this is actually just something anyone can
|
// sweep her anchor. As this is actually just something anyone can
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
// testOpenChannelAfterReorg tests that in the case where we have an open
|
// testOpenChannelAfterReorg tests that in the case where we have an open
|
||||||
// channel where the funding tx gets reorged out, the channel will no
|
// channel where the funding tx gets reorged out, the channel will no
|
||||||
// longer be present in the node's routing table.
|
// longer be present in the node's routing table.
|
||||||
func testOpenChannelAfterReorg(ht *lntemp.HarnessTest) {
|
func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
|
||||||
// Skip test for neutrino, as we cannot disconnect the miner at will.
|
// Skip test for neutrino, as we cannot disconnect the miner at will.
|
||||||
// TODO(halseth): remove when either can disconnect at will, or restart
|
// TODO(halseth): remove when either can disconnect at will, or restart
|
||||||
// node with connection to new miner.
|
// node with connection to new miner.
|
||||||
@@ -33,7 +33,7 @@ func testOpenChannelAfterReorg(ht *lntemp.HarnessTest) {
|
|||||||
// Set up a new miner that we can use to cause a reorg.
|
// Set up a new miner that we can use to cause a reorg.
|
||||||
tempLogDir := ".tempminerlogs"
|
tempLogDir := ".tempminerlogs"
|
||||||
logFilename := "output-open_channel_reorg-temp_miner.log"
|
logFilename := "output-open_channel_reorg-temp_miner.log"
|
||||||
tempMiner := lntemp.NewTempMiner(
|
tempMiner := lntest.NewTempMiner(
|
||||||
ht.Context(), ht.T, tempLogDir, logFilename,
|
ht.Context(), ht.T, tempLogDir, logFilename,
|
||||||
)
|
)
|
||||||
defer tempMiner.Stop()
|
defer tempMiner.Stop()
|
||||||
@@ -68,7 +68,7 @@ func testOpenChannelAfterReorg(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Create a new channel that requires 1 confs before it's considered
|
// Create a new channel that requires 1 confs before it's considered
|
||||||
// open, then broadcast the funding transaction
|
// open, then broadcast the funding transaction
|
||||||
params := lntemp.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: funding.MaxBtcFundingAmount,
|
Amt: funding.MaxBtcFundingAmount,
|
||||||
Private: true,
|
Private: true,
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ func testOpenChannelAfterReorg(ht *lntemp.HarnessTest) {
|
|||||||
// ChannelUpdate --> defaultBaseFee, provided FeeRate
|
// ChannelUpdate --> defaultBaseFee, provided FeeRate
|
||||||
// 4.) baseFee and feeRate provided to OpenChannelRequest
|
// 4.) baseFee and feeRate provided to OpenChannelRequest
|
||||||
// ChannelUpdate --> provided baseFee, provided feeRate.
|
// ChannelUpdate --> provided baseFee, provided feeRate.
|
||||||
func testOpenChannelUpdateFeePolicy(ht *lntemp.HarnessTest) {
|
func testOpenChannelUpdateFeePolicy(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
defaultBaseFee = 1000
|
defaultBaseFee = 1000
|
||||||
defaultFeeRate = 1
|
defaultFeeRate = 1
|
||||||
@@ -182,12 +182,12 @@ func testOpenChannelUpdateFeePolicy(ht *lntemp.HarnessTest) {
|
|||||||
optionalFeeRate = 1337
|
optionalFeeRate = 1337
|
||||||
)
|
)
|
||||||
|
|
||||||
defaultMaxHtlc := lntemp.CalculateMaxHtlc(funding.MaxBtcFundingAmount)
|
defaultMaxHtlc := lntest.CalculateMaxHtlc(funding.MaxBtcFundingAmount)
|
||||||
|
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := chanAmt / 2
|
pushAmt := chanAmt / 2
|
||||||
|
|
||||||
feeScenarios := []lntemp.OpenChannelParams{
|
feeScenarios := []lntest.OpenChannelParams{
|
||||||
{
|
{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
@@ -259,8 +259,8 @@ func testOpenChannelUpdateFeePolicy(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
runTestCase := func(ht *lntemp.HarnessTest,
|
runTestCase := func(ht *lntest.HarnessTest,
|
||||||
fs lntemp.OpenChannelParams,
|
fs lntest.OpenChannelParams,
|
||||||
alicePolicy, bobPolicy *lnrpc.RoutingPolicy) {
|
alicePolicy, bobPolicy *lnrpc.RoutingPolicy) {
|
||||||
|
|
||||||
// Create a channel Alice->Bob.
|
// Create a channel Alice->Bob.
|
||||||
@@ -305,14 +305,14 @@ func testOpenChannelUpdateFeePolicy(ht *lntemp.HarnessTest) {
|
|||||||
// testBasicChannelCreationAndUpdates tests multiple channel opening and
|
// testBasicChannelCreationAndUpdates tests multiple channel opening and
|
||||||
// closing, and ensures that if a node is subscribed to channel updates they
|
// closing, and ensures that if a node is subscribed to channel updates they
|
||||||
// will be received correctly for both cooperative and force closed channels.
|
// will be received correctly for both cooperative and force closed channels.
|
||||||
func testBasicChannelCreationAndUpdates(ht *lntemp.HarnessTest) {
|
func testBasicChannelCreationAndUpdates(ht *lntest.HarnessTest) {
|
||||||
runBasicChannelCreationAndUpdates(ht, ht.Alice, ht.Bob)
|
runBasicChannelCreationAndUpdates(ht, ht.Alice, ht.Bob)
|
||||||
}
|
}
|
||||||
|
|
||||||
// runBasicChannelCreationAndUpdates tests multiple channel opening and closing,
|
// runBasicChannelCreationAndUpdates tests multiple channel opening and closing,
|
||||||
// and ensures that if a node is subscribed to channel updates they will be
|
// and ensures that if a node is subscribed to channel updates they will be
|
||||||
// received correctly for both cooperative and force closed channels.
|
// received correctly for both cooperative and force closed channels.
|
||||||
func runBasicChannelCreationAndUpdates(ht *lntemp.HarnessTest,
|
func runBasicChannelCreationAndUpdates(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode) {
|
alice, bob *node.HarnessNode) {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -329,7 +329,7 @@ func runBasicChannelCreationAndUpdates(ht *lntemp.HarnessTest,
|
|||||||
chanPoints := make([]*lnrpc.ChannelPoint, numChannels)
|
chanPoints := make([]*lnrpc.ChannelPoint, numChannels)
|
||||||
for i := 0; i < numChannels; i++ {
|
for i := 0; i < numChannels; i++ {
|
||||||
chanPoints[i] = ht.OpenChannel(
|
chanPoints[i] = ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: amount,
|
Amt: amount,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -458,8 +458,8 @@ func runBasicChannelCreationAndUpdates(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// assertMinerBlockHeightDelta ensures that tempMiner is 'delta' blocks ahead
|
// assertMinerBlockHeightDelta ensures that tempMiner is 'delta' blocks ahead
|
||||||
// of miner.
|
// of miner.
|
||||||
func assertMinerBlockHeightDelta(ht *lntemp.HarnessTest,
|
func assertMinerBlockHeightDelta(ht *lntest.HarnessTest,
|
||||||
miner, tempMiner *lntemp.HarnessMiner, delta int32) {
|
miner, tempMiner *lntest.HarnessMiner, delta int32) {
|
||||||
|
|
||||||
// Ensure the chain lengths are what we expect.
|
// Ensure the chain lengths are what we expect.
|
||||||
err := wait.NoError(func() error {
|
err := wait.NoError(func() error {
|
||||||
|
|||||||
+16
-16
@@ -10,13 +10,13 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testListPayments(ht *lntemp.HarnessTest) {
|
func testListPayments(ht *lntest.HarnessTest) {
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
|
||||||
// Check that there are no payments before test.
|
// Check that there are no payments before test.
|
||||||
@@ -26,7 +26,7 @@ func testListPayments(ht *lntemp.HarnessTest) {
|
|||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanAmt := btcutil.Amount(100000)
|
chanAmt := btcutil.Amount(100000)
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get the number of invoices Bob already has.
|
// Get the number of invoices Bob already has.
|
||||||
@@ -169,13 +169,13 @@ func testListPayments(ht *lntemp.HarnessTest) {
|
|||||||
// subsystems trying to update the channel state in the db. We follow this
|
// subsystems trying to update the channel state in the db. We follow this
|
||||||
// transition with a payment that updates the commitment state and verify that
|
// transition with a payment that updates the commitment state and verify that
|
||||||
// the pending state is up to date.
|
// the pending state is up to date.
|
||||||
func testPaymentFollowingChannelOpen(ht *lntemp.HarnessTest) {
|
func testPaymentFollowingChannelOpen(ht *lntest.HarnessTest) {
|
||||||
const paymentAmt = btcutil.Amount(100)
|
const paymentAmt = btcutil.Amount(100)
|
||||||
channelCapacity := paymentAmt * 1000
|
channelCapacity := paymentAmt * 1000
|
||||||
|
|
||||||
// We first establish a channel between Alice and Bob.
|
// We first establish a channel between Alice and Bob.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
p := lntemp.OpenChannelParams{
|
p := lntest.OpenChannelParams{
|
||||||
Amt: channelCapacity,
|
Amt: channelCapacity,
|
||||||
}
|
}
|
||||||
pendingUpdate := ht.OpenChannelAssertPending(alice, bob, p)
|
pendingUpdate := ht.OpenChannelAssertPending(alice, bob, p)
|
||||||
@@ -196,7 +196,7 @@ func testPaymentFollowingChannelOpen(ht *lntemp.HarnessTest) {
|
|||||||
ht.MineBlocksAndAssertNumTxes(6, 1)
|
ht.MineBlocksAndAssertNumTxes(6, 1)
|
||||||
|
|
||||||
// We verify that the channel is open from both nodes point of view.
|
// We verify that the channel is open from both nodes point of view.
|
||||||
chanPoint := lntemp.ChanPointFromPendingUpdate(pendingUpdate)
|
chanPoint := lntest.ChanPointFromPendingUpdate(pendingUpdate)
|
||||||
ht.AssertNodesNumPendingOpenChannels(alice, bob, 0)
|
ht.AssertNodesNumPendingOpenChannels(alice, bob, 0)
|
||||||
ht.AssertChannelExists(alice, chanPoint)
|
ht.AssertChannelExists(alice, chanPoint)
|
||||||
ht.AssertChannelExists(bob, chanPoint)
|
ht.AssertChannelExists(bob, chanPoint)
|
||||||
@@ -224,7 +224,7 @@ func testPaymentFollowingChannelOpen(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// testAsyncPayments tests the performance of the async payments.
|
// testAsyncPayments tests the performance of the async payments.
|
||||||
func testAsyncPayments(ht *lntemp.HarnessTest) {
|
func testAsyncPayments(ht *lntest.HarnessTest) {
|
||||||
// We use new nodes here as the benchmark test creates lots of data
|
// We use new nodes here as the benchmark test creates lots of data
|
||||||
// which can be costly to be carried on.
|
// which can be costly to be carried on.
|
||||||
alice := ht.NewNode("Alice", []string{"--pending-commit-interval=3m"})
|
alice := ht.NewNode("Alice", []string{"--pending-commit-interval=3m"})
|
||||||
@@ -237,7 +237,7 @@ func testAsyncPayments(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// runAsyncPayments tests the performance of the async payments.
|
// runAsyncPayments tests the performance of the async payments.
|
||||||
func runAsyncPayments(ht *lntemp.HarnessTest, alice, bob *node.HarnessNode) {
|
func runAsyncPayments(ht *lntest.HarnessTest, alice, bob *node.HarnessNode) {
|
||||||
const paymentAmt = 100
|
const paymentAmt = 100
|
||||||
|
|
||||||
// First establish a channel with a capacity equals to the overall
|
// First establish a channel with a capacity equals to the overall
|
||||||
@@ -245,7 +245,7 @@ func runAsyncPayments(ht *lntemp.HarnessTest, alice, bob *node.HarnessNode) {
|
|||||||
// Alice should send all money from her side to Bob.
|
// Alice should send all money from her side to Bob.
|
||||||
channelCapacity := btcutil.Amount(paymentAmt * 2000)
|
channelCapacity := btcutil.Amount(paymentAmt * 2000)
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: channelCapacity},
|
alice, bob, lntest.OpenChannelParams{Amt: channelCapacity},
|
||||||
)
|
)
|
||||||
|
|
||||||
info := ht.QueryChannelByChanPoint(alice, chanPoint)
|
info := ht.QueryChannelByChanPoint(alice, chanPoint)
|
||||||
@@ -322,7 +322,7 @@ func runAsyncPayments(ht *lntemp.HarnessTest, alice, bob *node.HarnessNode) {
|
|||||||
|
|
||||||
// testBidirectionalAsyncPayments tests that nodes are able to send the
|
// testBidirectionalAsyncPayments tests that nodes are able to send the
|
||||||
// payments to each other in async manner without blocking.
|
// payments to each other in async manner without blocking.
|
||||||
func testBidirectionalAsyncPayments(ht *lntemp.HarnessTest) {
|
func testBidirectionalAsyncPayments(ht *lntest.HarnessTest) {
|
||||||
const paymentAmt = 1000
|
const paymentAmt = 1000
|
||||||
|
|
||||||
// We use new nodes here as the benchmark test creates lots of data
|
// We use new nodes here as the benchmark test creates lots of data
|
||||||
@@ -337,7 +337,7 @@ func testBidirectionalAsyncPayments(ht *lntemp.HarnessTest) {
|
|||||||
// amount of payments, between Alice and Bob, at the end of the test
|
// amount of payments, between Alice and Bob, at the end of the test
|
||||||
// Alice should send all money from her side to Bob.
|
// Alice should send all money from her side to Bob.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: paymentAmt * 2000,
|
Amt: paymentAmt * 2000,
|
||||||
PushAmt: paymentAmt * 1000,
|
PushAmt: paymentAmt * 1000,
|
||||||
},
|
},
|
||||||
@@ -419,7 +419,7 @@ func testBidirectionalAsyncPayments(ht *lntemp.HarnessTest) {
|
|||||||
ht.CloseChannel(alice, chanPoint)
|
ht.CloseChannel(alice, chanPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInvoiceSubscriptions(ht *lntemp.HarnessTest) {
|
func testInvoiceSubscriptions(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = btcutil.Amount(500000)
|
const chanAmt = btcutil.Amount(500000)
|
||||||
|
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
@@ -432,7 +432,7 @@ func testInvoiceSubscriptions(ht *lntemp.HarnessTest) {
|
|||||||
// Open a channel with 500k satoshis between Alice and Bob with Alice
|
// Open a channel with 500k satoshis between Alice and Bob with Alice
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Next create a new invoice for Bob requesting 1k satoshis.
|
// Next create a new invoice for Bob requesting 1k satoshis.
|
||||||
@@ -549,7 +549,7 @@ func testInvoiceSubscriptions(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// assertChannelState asserts the channel state by checking the values in
|
// assertChannelState asserts the channel state by checking the values in
|
||||||
// fields, LocalBalance, RemoteBalance and num of PendingHtlcs.
|
// fields, LocalBalance, RemoteBalance and num of PendingHtlcs.
|
||||||
func assertChannelState(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func assertChannelState(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
cp *lnrpc.ChannelPoint, localBalance, remoteBalance int64) {
|
cp *lnrpc.ChannelPoint, localBalance, remoteBalance int64) {
|
||||||
|
|
||||||
// Get the funding point.
|
// Get the funding point.
|
||||||
@@ -576,6 +576,6 @@ func assertChannelState(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}, lntemp.DefaultTimeout)
|
}, lntest.DefaultTimeout)
|
||||||
require.NoError(ht, err, "timeout while chekcing for balance")
|
require.NoError(ht, err, "timeout while chekcing for balance")
|
||||||
}
|
}
|
||||||
+24
-24
@@ -20,15 +20,15 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testPsbtChanFunding makes sure a channel can be opened between carol and dave
|
// testPsbtChanFunding makes sure a channel can be opened between carol and dave
|
||||||
// by using a Partially Signed Bitcoin Transaction that funds the channel
|
// by using a Partially Signed Bitcoin Transaction that funds the channel
|
||||||
// multisig funding output.
|
// multisig funding output.
|
||||||
func testPsbtChanFunding(ht *lntemp.HarnessTest) {
|
func testPsbtChanFunding(ht *lntest.HarnessTest) {
|
||||||
// First, we'll create two new nodes that we'll use to open channels
|
// First, we'll create two new nodes that we'll use to open channels
|
||||||
// between for this test. Dave gets some coins that will be used to
|
// between for this test. Dave gets some coins that will be used to
|
||||||
// fund the PSBT, just to make sure that Carol has an empty wallet.
|
// fund the PSBT, just to make sure that Carol has an empty wallet.
|
||||||
@@ -41,7 +41,7 @@ func testPsbtChanFunding(ht *lntemp.HarnessTest) {
|
|||||||
// runPsbtChanFunding makes sure a channel can be opened between carol and dave
|
// runPsbtChanFunding makes sure a channel can be opened between carol and dave
|
||||||
// by using a Partially Signed Bitcoin Transaction that funds the channel
|
// by using a Partially Signed Bitcoin Transaction that funds the channel
|
||||||
// multisig funding output.
|
// multisig funding output.
|
||||||
func runPsbtChanFunding(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode) {
|
func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode) {
|
||||||
const chanSize = funding.MaxBtcFundingAmount
|
const chanSize = funding.MaxBtcFundingAmount
|
||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ func runPsbtChanFunding(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode) {
|
|||||||
// by specifying a PSBT shim. We use the NoPublish flag here to avoid
|
// by specifying a PSBT shim. We use the NoPublish flag here to avoid
|
||||||
// publishing the whole batch TX too early.
|
// publishing the whole batch TX too early.
|
||||||
chanUpdates, tempPsbt := ht.OpenChannelPsbt(
|
chanUpdates, tempPsbt := ht.OpenChannelPsbt(
|
||||||
carol, dave, lntemp.OpenChannelParams{
|
carol, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanSize,
|
Amt: chanSize,
|
||||||
FundingShim: &lnrpc.FundingShim{
|
FundingShim: &lnrpc.FundingShim{
|
||||||
Shim: &lnrpc.FundingShim_PsbtShim{
|
Shim: &lnrpc.FundingShim_PsbtShim{
|
||||||
@@ -80,7 +80,7 @@ func runPsbtChanFunding(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode) {
|
|||||||
// Alice. We will publish the batch TX once this channel funding is
|
// Alice. We will publish the batch TX once this channel funding is
|
||||||
// complete.
|
// complete.
|
||||||
chanUpdates2, psbtBytes2 := ht.OpenChannelPsbt(
|
chanUpdates2, psbtBytes2 := ht.OpenChannelPsbt(
|
||||||
carol, alice, lntemp.OpenChannelParams{
|
carol, alice, lntest.OpenChannelParams{
|
||||||
Amt: chanSize,
|
Amt: chanSize,
|
||||||
FundingShim: &lnrpc.FundingShim{
|
FundingShim: &lnrpc.FundingShim{
|
||||||
Shim: &lnrpc.FundingShim_PsbtShim{
|
Shim: &lnrpc.FundingShim_PsbtShim{
|
||||||
@@ -230,7 +230,7 @@ func runPsbtChanFunding(ht *lntemp.HarnessTest, carol, dave *node.HarnessNode) {
|
|||||||
// and dave by using a Partially Signed Bitcoin Transaction that funds the
|
// and dave by using a Partially Signed Bitcoin Transaction that funds the
|
||||||
// channel multisig funding output and is fully funded by an external third
|
// channel multisig funding output and is fully funded by an external third
|
||||||
// party.
|
// party.
|
||||||
func testPsbtChanFundingExternal(ht *lntemp.HarnessTest) {
|
func testPsbtChanFundingExternal(ht *lntest.HarnessTest) {
|
||||||
const chanSize = funding.MaxBtcFundingAmount
|
const chanSize = funding.MaxBtcFundingAmount
|
||||||
|
|
||||||
// First, we'll create two new nodes that we'll use to open channels
|
// First, we'll create two new nodes that we'll use to open channels
|
||||||
@@ -257,7 +257,7 @@ func testPsbtChanFundingExternal(ht *lntemp.HarnessTest) {
|
|||||||
// by specifying a PSBT shim. We use the NoPublish flag here to avoid
|
// by specifying a PSBT shim. We use the NoPublish flag here to avoid
|
||||||
// publishing the whole batch TX too early.
|
// publishing the whole batch TX too early.
|
||||||
chanUpdates, tempPsbt := ht.OpenChannelPsbt(
|
chanUpdates, tempPsbt := ht.OpenChannelPsbt(
|
||||||
carol, dave, lntemp.OpenChannelParams{
|
carol, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanSize,
|
Amt: chanSize,
|
||||||
FundingShim: &lnrpc.FundingShim{
|
FundingShim: &lnrpc.FundingShim{
|
||||||
Shim: &lnrpc.FundingShim_PsbtShim{
|
Shim: &lnrpc.FundingShim_PsbtShim{
|
||||||
@@ -274,7 +274,7 @@ func testPsbtChanFundingExternal(ht *lntemp.HarnessTest) {
|
|||||||
// Alice. We will publish the batch TX once this channel funding is
|
// Alice. We will publish the batch TX once this channel funding is
|
||||||
// complete.
|
// complete.
|
||||||
chanUpdates2, psbtBytes2 := ht.OpenChannelPsbt(
|
chanUpdates2, psbtBytes2 := ht.OpenChannelPsbt(
|
||||||
carol, alice, lntemp.OpenChannelParams{
|
carol, alice, lntest.OpenChannelParams{
|
||||||
Amt: chanSize,
|
Amt: chanSize,
|
||||||
FundingShim: &lnrpc.FundingShim{
|
FundingShim: &lnrpc.FundingShim{
|
||||||
Shim: &lnrpc.FundingShim_PsbtShim{
|
Shim: &lnrpc.FundingShim_PsbtShim{
|
||||||
@@ -412,10 +412,10 @@ func testPsbtChanFundingExternal(ht *lntemp.HarnessTest) {
|
|||||||
// the wallet of both nodes are empty and one of them uses PSBT and an external
|
// the wallet of both nodes are empty and one of them uses PSBT and an external
|
||||||
// wallet to fund the channel while creating reserve output in the same
|
// wallet to fund the channel while creating reserve output in the same
|
||||||
// transaction.
|
// transaction.
|
||||||
func testPsbtChanFundingSingleStep(ht *lntemp.HarnessTest) {
|
func testPsbtChanFundingSingleStep(ht *lntest.HarnessTest) {
|
||||||
const chanSize = funding.MaxBtcFundingAmount
|
const chanSize = funding.MaxBtcFundingAmount
|
||||||
|
|
||||||
args := lntemp.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
|
args := lntest.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
|
||||||
|
|
||||||
// First, we'll create two new nodes that we'll use to open channels
|
// First, we'll create two new nodes that we'll use to open channels
|
||||||
// between for this test. But in this case both nodes have an empty
|
// between for this test. But in this case both nodes have an empty
|
||||||
@@ -453,7 +453,7 @@ func testPsbtChanFundingSingleStep(ht *lntemp.HarnessTest) {
|
|||||||
// Now that we have the pending channel ID, Carol will open the channel
|
// Now that we have the pending channel ID, Carol will open the channel
|
||||||
// by specifying a PSBT shim.
|
// by specifying a PSBT shim.
|
||||||
chanUpdates, tempPsbt := ht.OpenChannelPsbt(
|
chanUpdates, tempPsbt := ht.OpenChannelPsbt(
|
||||||
carol, dave, lntemp.OpenChannelParams{
|
carol, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanSize,
|
Amt: chanSize,
|
||||||
FundingShim: &lnrpc.FundingShim{
|
FundingShim: &lnrpc.FundingShim{
|
||||||
Shim: &lnrpc.FundingShim_PsbtShim{
|
Shim: &lnrpc.FundingShim_PsbtShim{
|
||||||
@@ -575,7 +575,7 @@ func testPsbtChanFundingSingleStep(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// testSignPsbt tests that the SignPsbt RPC works correctly.
|
// testSignPsbt tests that the SignPsbt RPC works correctly.
|
||||||
func testSignPsbt(ht *lntemp.HarnessTest) {
|
func testSignPsbt(ht *lntest.HarnessTest) {
|
||||||
runSignPsbtSegWitV0P2WKH(ht, ht.Alice)
|
runSignPsbtSegWitV0P2WKH(ht, ht.Alice)
|
||||||
runSignPsbtSegWitV0NP2WKH(ht, ht.Alice)
|
runSignPsbtSegWitV0NP2WKH(ht, ht.Alice)
|
||||||
runSignPsbtSegWitV1KeySpendBip86(ht, ht.Alice)
|
runSignPsbtSegWitV1KeySpendBip86(ht, ht.Alice)
|
||||||
@@ -590,7 +590,7 @@ func testSignPsbt(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// runSignPsbtSegWitV0P2WKH tests that the SignPsbt RPC works correctly for a
|
// runSignPsbtSegWitV0P2WKH tests that the SignPsbt RPC works correctly for a
|
||||||
// SegWit v0 p2wkh input.
|
// SegWit v0 p2wkh input.
|
||||||
func runSignPsbtSegWitV0P2WKH(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
func runSignPsbtSegWitV0P2WKH(ht *lntest.HarnessTest, alice *node.HarnessNode) {
|
||||||
// We test that we can sign a PSBT that spends funds from an input that
|
// We test that we can sign a PSBT that spends funds from an input that
|
||||||
// the wallet doesn't know about. To set up that test case, we first
|
// the wallet doesn't know about. To set up that test case, we first
|
||||||
// derive an address manually that the wallet won't be watching on
|
// derive an address manually that the wallet won't be watching on
|
||||||
@@ -669,7 +669,7 @@ func runSignPsbtSegWitV0P2WKH(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
|||||||
|
|
||||||
// runSignPsbtSegWitV0NP2WKH tests that the SignPsbt RPC works correctly for a
|
// runSignPsbtSegWitV0NP2WKH tests that the SignPsbt RPC works correctly for a
|
||||||
// SegWit v0 np2wkh input.
|
// SegWit v0 np2wkh input.
|
||||||
func runSignPsbtSegWitV0NP2WKH(ht *lntemp.HarnessTest,
|
func runSignPsbtSegWitV0NP2WKH(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// We test that we can sign a PSBT that spends funds from an input that
|
// We test that we can sign a PSBT that spends funds from an input that
|
||||||
@@ -758,7 +758,7 @@ func runSignPsbtSegWitV0NP2WKH(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// runSignPsbtSegWitV1KeySpendBip86 tests that the SignPsbt RPC works correctly
|
// runSignPsbtSegWitV1KeySpendBip86 tests that the SignPsbt RPC works correctly
|
||||||
// for a SegWit v1 p2tr key spend BIP-0086 input.
|
// for a SegWit v1 p2tr key spend BIP-0086 input.
|
||||||
func runSignPsbtSegWitV1KeySpendBip86(ht *lntemp.HarnessTest,
|
func runSignPsbtSegWitV1KeySpendBip86(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// Derive a key we can use for signing.
|
// Derive a key we can use for signing.
|
||||||
@@ -802,7 +802,7 @@ func runSignPsbtSegWitV1KeySpendBip86(ht *lntemp.HarnessTest,
|
|||||||
// runSignPsbtSegWitV1KeySpendRootHash tests that the SignPsbt RPC works
|
// runSignPsbtSegWitV1KeySpendRootHash tests that the SignPsbt RPC works
|
||||||
// correctly for a SegWit v1 p2tr key spend that also commits to a script tree
|
// correctly for a SegWit v1 p2tr key spend that also commits to a script tree
|
||||||
// root hash.
|
// root hash.
|
||||||
func runSignPsbtSegWitV1KeySpendRootHash(ht *lntemp.HarnessTest,
|
func runSignPsbtSegWitV1KeySpendRootHash(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// Derive a key we can use for signing.
|
// Derive a key we can use for signing.
|
||||||
@@ -849,7 +849,7 @@ func runSignPsbtSegWitV1KeySpendRootHash(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// runSignPsbtSegWitV1ScriptSpend tests that the SignPsbt RPC works correctly
|
// runSignPsbtSegWitV1ScriptSpend tests that the SignPsbt RPC works correctly
|
||||||
// for a SegWit v1 p2tr script spend.
|
// for a SegWit v1 p2tr script spend.
|
||||||
func runSignPsbtSegWitV1ScriptSpend(ht *lntemp.HarnessTest,
|
func runSignPsbtSegWitV1ScriptSpend(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// Derive a key we can use for signing.
|
// Derive a key we can use for signing.
|
||||||
@@ -910,7 +910,7 @@ func runSignPsbtSegWitV1ScriptSpend(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// runFundAndSignPsbt makes sure we can sign PSBTs that were funded by our
|
// runFundAndSignPsbt makes sure we can sign PSBTs that were funded by our
|
||||||
// internal wallet.
|
// internal wallet.
|
||||||
func runFundAndSignPsbt(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
func runFundAndSignPsbt(ht *lntest.HarnessTest, alice *node.HarnessNode) {
|
||||||
alice.AddToLogf("================ runFundAndSignPsbt ===============")
|
alice.AddToLogf("================ runFundAndSignPsbt ===============")
|
||||||
|
|
||||||
// We'll be using a "main" address where we send the funds to and from
|
// We'll be using a "main" address where we send the funds to and from
|
||||||
@@ -964,7 +964,7 @@ func runFundAndSignPsbt(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
|||||||
// assertPsbtSpend creates an output with the given pkScript on chain and then
|
// assertPsbtSpend creates an output with the given pkScript on chain and then
|
||||||
// attempts to create a sweep transaction that is signed using the SignPsbt RPC
|
// attempts to create a sweep transaction that is signed using the SignPsbt RPC
|
||||||
// that spends that output again.
|
// that spends that output again.
|
||||||
func assertPsbtSpend(ht *lntemp.HarnessTest, alice *node.HarnessNode,
|
func assertPsbtSpend(ht *lntest.HarnessTest, alice *node.HarnessNode,
|
||||||
pkScript []byte, decorateUnsigned func(*psbt.Packet),
|
pkScript []byte, decorateUnsigned func(*psbt.Packet),
|
||||||
verifySigned func(*psbt.Packet)) {
|
verifySigned func(*psbt.Packet)) {
|
||||||
|
|
||||||
@@ -1073,7 +1073,7 @@ func assertPsbtSpend(ht *lntemp.HarnessTest, alice *node.HarnessNode,
|
|||||||
|
|
||||||
// assertPsbtFundSignSpend funds a PSBT from the internal wallet and then
|
// assertPsbtFundSignSpend funds a PSBT from the internal wallet and then
|
||||||
// attempts to sign it by using the SignPsbt or FinalizePsbt method.
|
// attempts to sign it by using the SignPsbt or FinalizePsbt method.
|
||||||
func assertPsbtFundSignSpend(ht *lntemp.HarnessTest, alice *node.HarnessNode,
|
func assertPsbtFundSignSpend(ht *lntest.HarnessTest, alice *node.HarnessNode,
|
||||||
fundOutputs map[string]uint64, changeType walletrpc.ChangeAddressType,
|
fundOutputs map[string]uint64, changeType walletrpc.ChangeAddressType,
|
||||||
useFinalize bool) {
|
useFinalize bool) {
|
||||||
|
|
||||||
@@ -1148,7 +1148,7 @@ func assertPsbtFundSignSpend(ht *lntemp.HarnessTest, alice *node.HarnessNode,
|
|||||||
// assertChangeScriptType checks if the given script has the right type given
|
// assertChangeScriptType checks if the given script has the right type given
|
||||||
// the change address type we used in FundPsbt. By default, the script should
|
// the change address type we used in FundPsbt. By default, the script should
|
||||||
// be a P2WPKH one.
|
// be a P2WPKH one.
|
||||||
func assertChangeScriptType(ht *lntemp.HarnessTest, script []byte,
|
func assertChangeScriptType(ht *lntest.HarnessTest, script []byte,
|
||||||
fundChangeType walletrpc.ChangeAddressType) {
|
fundChangeType walletrpc.ChangeAddressType) {
|
||||||
|
|
||||||
switch fundChangeType {
|
switch fundChangeType {
|
||||||
@@ -1162,7 +1162,7 @@ func assertChangeScriptType(ht *lntemp.HarnessTest, script []byte,
|
|||||||
|
|
||||||
// deriveInternalKey derives a signing key and returns its descriptor, full
|
// deriveInternalKey derives a signing key and returns its descriptor, full
|
||||||
// derivation path and parsed public key.
|
// derivation path and parsed public key.
|
||||||
func deriveInternalKey(ht *lntemp.HarnessTest,
|
func deriveInternalKey(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) (*signrpc.KeyDescriptor, *btcec.PublicKey,
|
alice *node.HarnessNode) (*signrpc.KeyDescriptor, *btcec.PublicKey,
|
||||||
[]uint32) {
|
[]uint32) {
|
||||||
|
|
||||||
@@ -1221,7 +1221,7 @@ func receiveChanUpdate(ctx context.Context,
|
|||||||
|
|
||||||
// sendAllCoinsToAddrType sweeps all coins from the wallet and sends them to a
|
// sendAllCoinsToAddrType sweeps all coins from the wallet and sends them to a
|
||||||
// new address of the given type.
|
// new address of the given type.
|
||||||
func sendAllCoinsToAddrType(ht *lntemp.HarnessTest,
|
func sendAllCoinsToAddrType(ht *lntest.HarnessTest,
|
||||||
hn *node.HarnessNode, addrType lnrpc.AddressType) {
|
hn *node.HarnessNode, addrType lnrpc.AddressType) {
|
||||||
|
|
||||||
resp := hn.RPC.NewAddress(&lnrpc.NewAddressRequest{
|
resp := hn.RPC.NewAddress(&lnrpc.NewAddressRequest{
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
// testGetRecoveryInfo checks whether lnd gives the right information about
|
// testGetRecoveryInfo checks whether lnd gives the right information about
|
||||||
// the wallet recovery process.
|
// the wallet recovery process.
|
||||||
func testGetRecoveryInfo(ht *lntemp.HarnessTest) {
|
func testGetRecoveryInfo(ht *lntest.HarnessTest) {
|
||||||
// First, create a new node with strong passphrase and grab the mnemonic
|
// First, create a new node with strong passphrase and grab the mnemonic
|
||||||
// used for key derivation. This will bring up Carol with an empty
|
// used for key derivation. This will bring up Carol with an empty
|
||||||
// wallet, and such that she is synced up.
|
// wallet, and such that she is synced up.
|
||||||
@@ -94,7 +94,7 @@ func testGetRecoveryInfo(ht *lntemp.HarnessTest) {
|
|||||||
// when providing a valid aezeed that owns outputs on the chain. This test
|
// when providing a valid aezeed that owns outputs on the chain. This test
|
||||||
// performs multiple restorations using the same seed and various recovery
|
// performs multiple restorations using the same seed and various recovery
|
||||||
// windows to ensure we detect funds properly.
|
// windows to ensure we detect funds properly.
|
||||||
func testOnchainFundRecovery(ht *lntemp.HarnessTest) {
|
func testOnchainFundRecovery(ht *lntest.HarnessTest) {
|
||||||
// First, create a new node with strong passphrase and grab the mnemonic
|
// First, create a new node with strong passphrase and grab the mnemonic
|
||||||
// used for key derivation. This will bring up Carol with an empty
|
// used for key derivation. This will bring up Carol with an empty
|
||||||
// wallet, and such that she is synced up.
|
// wallet, and such that she is synced up.
|
||||||
@@ -321,7 +321,7 @@ func testOnchainFundRecovery(ht *lntemp.HarnessTest) {
|
|||||||
// The fix in the wallet is simple: In step 6, don't detect addresses from
|
// The fix in the wallet is simple: In step 6, don't detect addresses from
|
||||||
// internal scopes while re-scanning to be in line with the logic in other areas
|
// internal scopes while re-scanning to be in line with the logic in other areas
|
||||||
// of the wallet code.
|
// of the wallet code.
|
||||||
func testRescanAddressDetection(ht *lntemp.HarnessTest) {
|
func testRescanAddressDetection(ht *lntest.HarnessTest) {
|
||||||
// We start off by creating a new node with the wallet re-scan flag
|
// We start off by creating a new node with the wallet re-scan flag
|
||||||
// enabled. This won't have any effect on the first startup but will
|
// enabled. This won't have any effect on the first startup but will
|
||||||
// come into effect after we re-start the node.
|
// come into effect after we re-start the node.
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,24 +55,24 @@ var (
|
|||||||
|
|
||||||
// testRemoteSigner tests that a watch-only wallet can use a remote signing
|
// testRemoteSigner tests that a watch-only wallet can use a remote signing
|
||||||
// wallet to perform any signing or ECDH operations.
|
// wallet to perform any signing or ECDH operations.
|
||||||
func testRemoteSigner(ht *lntemp.HarnessTest) {
|
func testRemoteSigner(ht *lntest.HarnessTest) {
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
name string
|
name string
|
||||||
randomSeed bool
|
randomSeed bool
|
||||||
sendCoins bool
|
sendCoins bool
|
||||||
fn func(tt *lntemp.HarnessTest,
|
fn func(tt *lntest.HarnessTest,
|
||||||
wo, carol *node.HarnessNode)
|
wo, carol *node.HarnessNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
subTests := []testCase{{
|
subTests := []testCase{{
|
||||||
name: "random seed",
|
name: "random seed",
|
||||||
randomSeed: true,
|
randomSeed: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
// Nothing more to test here.
|
// Nothing more to test here.
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "account import",
|
name: "account import",
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runWalletImportAccountScenario(
|
runWalletImportAccountScenario(
|
||||||
tt, walletrpc.AddressType_WITNESS_PUBKEY_HASH,
|
tt, walletrpc.AddressType_WITNESS_PUBKEY_HASH,
|
||||||
carol, wo,
|
carol, wo,
|
||||||
@@ -81,36 +81,36 @@ func testRemoteSigner(ht *lntemp.HarnessTest) {
|
|||||||
}, {
|
}, {
|
||||||
name: "basic channel open close",
|
name: "basic channel open close",
|
||||||
sendCoins: true,
|
sendCoins: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runBasicChannelCreationAndUpdates(tt, wo, carol)
|
runBasicChannelCreationAndUpdates(tt, wo, carol)
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "channel funding input types",
|
name: "channel funding input types",
|
||||||
sendCoins: false,
|
sendCoins: false,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runChannelFundingInputTypes(tt, carol, wo)
|
runChannelFundingInputTypes(tt, carol, wo)
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "async payments",
|
name: "async payments",
|
||||||
sendCoins: true,
|
sendCoins: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runAsyncPayments(tt, wo, carol)
|
runAsyncPayments(tt, wo, carol)
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "shared key",
|
name: "shared key",
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runDeriveSharedKey(tt, wo)
|
runDeriveSharedKey(tt, wo)
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "cpfp",
|
name: "cpfp",
|
||||||
sendCoins: true,
|
sendCoins: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runCPFP(tt, wo, carol)
|
runCPFP(tt, wo, carol)
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "psbt",
|
name: "psbt",
|
||||||
randomSeed: true,
|
randomSeed: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runPsbtChanFunding(tt, carol, wo)
|
runPsbtChanFunding(tt, carol, wo)
|
||||||
runSignPsbtSegWitV0P2WKH(tt, wo)
|
runSignPsbtSegWitV0P2WKH(tt, wo)
|
||||||
runSignPsbtSegWitV1KeySpendBip86(tt, wo)
|
runSignPsbtSegWitV1KeySpendBip86(tt, wo)
|
||||||
@@ -125,20 +125,20 @@ func testRemoteSigner(ht *lntemp.HarnessTest) {
|
|||||||
}, {
|
}, {
|
||||||
name: "sign output raw",
|
name: "sign output raw",
|
||||||
sendCoins: true,
|
sendCoins: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runSignOutputRaw(tt, wo)
|
runSignOutputRaw(tt, wo)
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "sign verify msg",
|
name: "sign verify msg",
|
||||||
sendCoins: true,
|
sendCoins: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
runSignVerifyMessage(tt, wo)
|
runSignVerifyMessage(tt, wo)
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "taproot",
|
name: "taproot",
|
||||||
sendCoins: true,
|
sendCoins: true,
|
||||||
randomSeed: true,
|
randomSeed: true,
|
||||||
fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) {
|
fn: func(tt *lntest.HarnessTest, wo, carol *node.HarnessNode) {
|
||||||
testTaprootSendCoinsKeySpendBip86(tt, wo)
|
testTaprootSendCoinsKeySpendBip86(tt, wo)
|
||||||
testTaprootComputeInputScriptKeySpendBip86(tt, wo)
|
testTaprootComputeInputScriptKeySpendBip86(tt, wo)
|
||||||
testTaprootSignOutputRawScriptSpend(tt, wo)
|
testTaprootSignOutputRawScriptSpend(tt, wo)
|
||||||
@@ -162,7 +162,7 @@ func testRemoteSigner(ht *lntemp.HarnessTest) {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
prepareTest := func(st *lntemp.HarnessTest,
|
prepareTest := func(st *lntest.HarnessTest,
|
||||||
subTest testCase) (*node.HarnessNode,
|
subTest testCase) (*node.HarnessNode,
|
||||||
*node.HarnessNode, *node.HarnessNode) {
|
*node.HarnessNode, *node.HarnessNode) {
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testResHandoff tests that the contractcourt is able to properly hand-off
|
// testResHandoff tests that the contractcourt is able to properly hand-off
|
||||||
// resolution messages to the switch.
|
// resolution messages to the switch.
|
||||||
func testResHandoff(ht *lntemp.HarnessTest) {
|
func testResHandoff(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = btcutil.Amount(1000000)
|
chanAmt = btcutil.Amount(1000000)
|
||||||
paymentAmt = 50000
|
paymentAmt = 50000
|
||||||
@@ -22,7 +22,7 @@ func testResHandoff(ht *lntemp.HarnessTest) {
|
|||||||
// First we'll create a channel between Alice and Bob.
|
// First we'll create a channel between Alice and Bob.
|
||||||
ht.EnsureConnected(alice, bob)
|
ht.EnsureConnected(alice, bob)
|
||||||
|
|
||||||
params := lntemp.OpenChannelParams{Amt: chanAmt}
|
params := lntest.OpenChannelParams{Amt: chanAmt}
|
||||||
chanPointAlice := ht.OpenChannel(alice, bob, params)
|
chanPointAlice := ht.OpenChannel(alice, bob, params)
|
||||||
|
|
||||||
// Create a new node Carol that will be in hodl mode. This is used to
|
// Create a new node Carol that will be in hodl mode. This is used to
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ var (
|
|||||||
|
|
||||||
// testRestAPI tests that the most important features of the REST API work
|
// testRestAPI tests that the most important features of the REST API work
|
||||||
// correctly.
|
// correctly.
|
||||||
func testRestAPI(ht *lntemp.HarnessTest) {
|
func testRestAPI(ht *lntest.HarnessTest) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
run func(*testing.T, *node.HarnessNode, *node.HarnessNode)
|
run func(*testing.T, *node.HarnessNode, *node.HarnessNode)
|
||||||
@@ -201,7 +201,7 @@ func testRestAPI(ht *lntemp.HarnessTest) {
|
|||||||
}}
|
}}
|
||||||
wsTestCases := []struct {
|
wsTestCases := []struct {
|
||||||
name string
|
name string
|
||||||
run func(ht *lntemp.HarnessTest)
|
run func(ht *lntest.HarnessTest)
|
||||||
}{{
|
}{{
|
||||||
name: "websocket subscription",
|
name: "websocket subscription",
|
||||||
run: wsTestCaseSubscription,
|
run: wsTestCaseSubscription,
|
||||||
@@ -243,7 +243,7 @@ func testRestAPI(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wsTestCaseSubscription(ht *lntemp.HarnessTest) {
|
func wsTestCaseSubscription(ht *lntest.HarnessTest) {
|
||||||
// Find out the current best block so we can subscribe to the next one.
|
// Find out the current best block so we can subscribe to the next one.
|
||||||
hash, height := ht.Miner.GetBestBlock()
|
hash, height := ht.Miner.GetBestBlock()
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ func wsTestCaseSubscription(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wsTestCaseSubscriptionMacaroon(ht *lntemp.HarnessTest) {
|
func wsTestCaseSubscriptionMacaroon(ht *lntest.HarnessTest) {
|
||||||
// Find out the current best block so we can subscribe to the next one.
|
// Find out the current best block so we can subscribe to the next one.
|
||||||
hash, height := ht.Miner.GetBestBlock()
|
hash, height := ht.Miner.GetBestBlock()
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ func wsTestCaseSubscriptionMacaroon(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wsTestCaseBiDirectionalSubscription(ht *lntemp.HarnessTest) {
|
func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
|
||||||
initialRequest := &lnrpc.ChannelAcceptResponse{}
|
initialRequest := &lnrpc.ChannelAcceptResponse{}
|
||||||
url := "/v1/channels/acceptor"
|
url := "/v1/channels/acceptor"
|
||||||
|
|
||||||
@@ -530,7 +530,7 @@ func wsTestCaseBiDirectionalSubscription(ht *lntemp.HarnessTest) {
|
|||||||
const numChannels = 3
|
const numChannels = 3
|
||||||
for i := 0; i < numChannels; i++ {
|
for i := 0; i < numChannels; i++ {
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
bob, alice, lntemp.OpenChannelParams{Amt: 500000},
|
bob, alice, lntest.OpenChannelParams{Amt: 500000},
|
||||||
)
|
)
|
||||||
defer ht.CloseChannel(bob, chanPoint)
|
defer ht.CloseChannel(bob, chanPoint)
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ func wsTestCaseBiDirectionalSubscription(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wsTestPingPongTimeout(ht *lntemp.HarnessTest) {
|
func wsTestPingPongTimeout(ht *lntest.HarnessTest) {
|
||||||
initialRequest := &lnrpc.InvoiceSubscription{
|
initialRequest := &lnrpc.InvoiceSubscription{
|
||||||
AddIndex: 1, SettleIndex: 1,
|
AddIndex: 1, SettleIndex: 1,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/wtclientrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/wtclientrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
// testRevokedCloseRetribution tests that Carol is able carry out
|
// testRevokedCloseRetribution tests that Carol is able carry out
|
||||||
// retribution in the event that she fails immediately after detecting Bob's
|
// retribution in the event that she fails immediately after detecting Bob's
|
||||||
// breach txn in the mempool.
|
// breach txn in the mempool.
|
||||||
func testRevokedCloseRetribution(ht *lntemp.HarnessTest) {
|
func testRevokedCloseRetribution(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = funding.MaxBtcFundingAmount
|
chanAmt = funding.MaxBtcFundingAmount
|
||||||
paymentAmt = 10000
|
paymentAmt = 10000
|
||||||
@@ -50,7 +50,7 @@ func testRevokedCloseRetribution(ht *lntemp.HarnessTest) {
|
|||||||
// closure by Bob, we'll first open up a channel between them with a
|
// closure by Bob, we'll first open up a channel between them with a
|
||||||
// 0.5 BTC value.
|
// 0.5 BTC value.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
carol, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
carol, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// With the channel open, we'll create a few invoices for Bob that
|
// With the channel open, we'll create a few invoices for Bob that
|
||||||
@@ -165,7 +165,7 @@ func testRevokedCloseRetribution(ht *lntemp.HarnessTest) {
|
|||||||
// testRevokedCloseRetributionZeroValueRemoteOutput tests that Dave is able
|
// testRevokedCloseRetributionZeroValueRemoteOutput tests that Dave is able
|
||||||
// carry out retribution in the event that he fails in state where the remote
|
// carry out retribution in the event that he fails in state where the remote
|
||||||
// commitment output has zero-value.
|
// commitment output has zero-value.
|
||||||
func testRevokedCloseRetributionZeroValueRemoteOutput(ht *lntemp.HarnessTest) {
|
func testRevokedCloseRetributionZeroValueRemoteOutput(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = funding.MaxBtcFundingAmount
|
chanAmt = funding.MaxBtcFundingAmount
|
||||||
paymentAmt = 10000
|
paymentAmt = 10000
|
||||||
@@ -198,7 +198,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(ht *lntemp.HarnessTest) {
|
|||||||
// closure by Carol, we'll first open up a channel between them with a
|
// closure by Carol, we'll first open up a channel between them with a
|
||||||
// 0.5 BTC value.
|
// 0.5 BTC value.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
dave, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
dave, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// With the channel open, we'll create a few invoices for Carol that
|
// With the channel open, we'll create a few invoices for Carol that
|
||||||
@@ -297,7 +297,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(ht *lntemp.HarnessTest) {
|
|||||||
// testRevokedCloseRetributionRemoteHodl tests that Dave properly responds to a
|
// testRevokedCloseRetributionRemoteHodl tests that Dave properly responds to a
|
||||||
// channel breach made by the remote party, specifically in the case that the
|
// channel breach made by the remote party, specifically in the case that the
|
||||||
// remote party breaches before settling extended HTLCs.
|
// remote party breaches before settling extended HTLCs.
|
||||||
func testRevokedCloseRetributionRemoteHodl(ht *lntemp.HarnessTest) {
|
func testRevokedCloseRetributionRemoteHodl(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = funding.MaxBtcFundingAmount
|
chanAmt = funding.MaxBtcFundingAmount
|
||||||
pushAmt = 200000
|
pushAmt = 200000
|
||||||
@@ -332,7 +332,7 @@ func testRevokedCloseRetributionRemoteHodl(ht *lntemp.HarnessTest) {
|
|||||||
// by Carol, we'll first open up a channel between them with a
|
// by Carol, we'll first open up a channel between them with a
|
||||||
// funding.MaxBtcFundingAmount (2^24) satoshis value.
|
// funding.MaxBtcFundingAmount (2^24) satoshis value.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
dave, carol, lntemp.OpenChannelParams{
|
dave, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
},
|
},
|
||||||
@@ -577,7 +577,7 @@ func testRevokedCloseRetributionRemoteHodl(ht *lntemp.HarnessTest) {
|
|||||||
// trigger a breach. Carol is kept offline throughout the process and the test
|
// trigger a breach. Carol is kept offline throughout the process and the test
|
||||||
// asserts that Willy responds by broadcasting the justice transaction on
|
// asserts that Willy responds by broadcasting the justice transaction on
|
||||||
// Carol's behalf sweeping her funds without a reward.
|
// Carol's behalf sweeping her funds without a reward.
|
||||||
func testRevokedCloseRetributionAltruistWatchtower(ht *lntemp.HarnessTest) {
|
func testRevokedCloseRetributionAltruistWatchtower(ht *lntest.HarnessTest) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
anchors bool
|
anchors bool
|
||||||
@@ -591,7 +591,7 @@ func testRevokedCloseRetributionAltruistWatchtower(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
testFunc := func(ht *lntemp.HarnessTest) {
|
testFunc := func(ht *lntest.HarnessTest) {
|
||||||
testRevokedCloseRetributionAltruistWatchtowerCase(
|
testRevokedCloseRetributionAltruistWatchtowerCase(
|
||||||
ht, tc.anchors,
|
ht, tc.anchors,
|
||||||
)
|
)
|
||||||
@@ -600,7 +600,7 @@ func testRevokedCloseRetributionAltruistWatchtower(ht *lntemp.HarnessTest) {
|
|||||||
success := ht.Run(tc.name, func(tt *testing.T) {
|
success := ht.Run(tc.name, func(tt *testing.T) {
|
||||||
st := ht.Subtest(tt)
|
st := ht.Subtest(tt)
|
||||||
|
|
||||||
st.RunTestCase(&lntemp.TestCase{
|
st.RunTestCase(&lntest.TestCase{
|
||||||
Name: tc.name,
|
Name: tc.name,
|
||||||
TestFunc: testFunc,
|
TestFunc: testFunc,
|
||||||
})
|
})
|
||||||
@@ -618,7 +618,7 @@ func testRevokedCloseRetributionAltruistWatchtower(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntemp.HarnessTest,
|
func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
||||||
anchors bool) {
|
anchors bool) {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -695,7 +695,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntemp.HarnessTest,
|
|||||||
// In order to test Dave's response to an uncooperative channel
|
// In order to test Dave's response to an uncooperative channel
|
||||||
// closure by Carol, we'll first open up a channel between them with a
|
// closure by Carol, we'll first open up a channel between them with a
|
||||||
// 0.5 BTC value.
|
// 0.5 BTC value.
|
||||||
params := lntemp.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: 3 * (chanAmt / 4),
|
Amt: 3 * (chanAmt / 4),
|
||||||
PushAmt: chanAmt / 4,
|
PushAmt: chanAmt / 4,
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-37
@@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -65,7 +65,7 @@ var singleHopSendToRouteCases = []singleHopSendToRouteCase{
|
|||||||
// by feeding the route back into the various SendToRoute RPC methods. Here we
|
// by feeding the route back into the various SendToRoute RPC methods. Here we
|
||||||
// test all three SendToRoute endpoints, forcing each to perform both a regular
|
// test all three SendToRoute endpoints, forcing each to perform both a regular
|
||||||
// payment and an MPP payment.
|
// payment and an MPP payment.
|
||||||
func testSingleHopSendToRoute(ht *lntemp.HarnessTest) {
|
func testSingleHopSendToRoute(ht *lntest.HarnessTest) {
|
||||||
for _, test := range singleHopSendToRouteCases {
|
for _, test := range singleHopSendToRouteCases {
|
||||||
test := test
|
test := test
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ func testSingleHopSendToRoute(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSingleHopSendToRouteCase(ht *lntemp.HarnessTest,
|
func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
|
||||||
test singleHopSendToRouteCase) {
|
test singleHopSendToRouteCase) {
|
||||||
|
|
||||||
const chanAmt = btcutil.Amount(100000)
|
const chanAmt = btcutil.Amount(100000)
|
||||||
@@ -97,7 +97,7 @@ func testSingleHopSendToRouteCase(ht *lntemp.HarnessTest,
|
|||||||
// Open a channel with 100k satoshis between Carol and Dave with Carol
|
// Open a channel with 100k satoshis between Carol and Dave with Carol
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanPointCarol := ht.OpenChannel(
|
chanPointCarol := ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{Amt: chanAmt},
|
carol, dave, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
defer ht.CloseChannel(carol, chanPointCarol)
|
defer ht.CloseChannel(carol, chanPointCarol)
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ func testSingleHopSendToRouteCase(ht *lntemp.HarnessTest,
|
|||||||
//
|
//
|
||||||
// We'll query the daemon for routes from Alice to Carol and then
|
// We'll query the daemon for routes from Alice to Carol and then
|
||||||
// send payments through the routes.
|
// send payments through the routes.
|
||||||
func testMultiHopSendToRoute(ht *lntemp.HarnessTest) {
|
func testMultiHopSendToRoute(ht *lntest.HarnessTest) {
|
||||||
ht.Run("with cache", func(tt *testing.T) {
|
ht.Run("with cache", func(tt *testing.T) {
|
||||||
st := ht.Subtest(tt)
|
st := ht.Subtest(tt)
|
||||||
runMultiHopSendToRoute(st, true)
|
runMultiHopSendToRoute(st, true)
|
||||||
@@ -309,7 +309,7 @@ func testMultiHopSendToRoute(ht *lntemp.HarnessTest) {
|
|||||||
//
|
//
|
||||||
// We'll query the daemon for routes from Alice to Carol and then
|
// We'll query the daemon for routes from Alice to Carol and then
|
||||||
// send payments through the routes.
|
// send payments through the routes.
|
||||||
func runMultiHopSendToRoute(ht *lntemp.HarnessTest, useGraphCache bool) {
|
func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
|
||||||
var opts []string
|
var opts []string
|
||||||
if !useGraphCache {
|
if !useGraphCache {
|
||||||
opts = append(opts, "--db.no-graph-cache")
|
opts = append(opts, "--db.no-graph-cache")
|
||||||
@@ -325,7 +325,7 @@ func runMultiHopSendToRoute(ht *lntemp.HarnessTest, useGraphCache bool) {
|
|||||||
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
defer ht.CloseChannel(alice, chanPointAlice)
|
defer ht.CloseChannel(alice, chanPointAlice)
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ func runMultiHopSendToRoute(ht *lntemp.HarnessTest, useGraphCache bool) {
|
|||||||
ht.ConnectNodes(carol, bob)
|
ht.ConnectNodes(carol, bob)
|
||||||
|
|
||||||
chanPointBob := ht.OpenChannel(
|
chanPointBob := ht.OpenChannel(
|
||||||
bob, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
bob, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
defer ht.CloseChannel(carol, chanPointBob)
|
defer ht.CloseChannel(carol, chanPointBob)
|
||||||
|
|
||||||
@@ -407,14 +407,14 @@ func runMultiHopSendToRoute(ht *lntemp.HarnessTest, useGraphCache bool) {
|
|||||||
|
|
||||||
// testSendToRouteErrorPropagation tests propagation of errors that occur
|
// testSendToRouteErrorPropagation tests propagation of errors that occur
|
||||||
// while processing a multi-hop payment through an unknown route.
|
// while processing a multi-hop payment through an unknown route.
|
||||||
func testSendToRouteErrorPropagation(ht *lntemp.HarnessTest) {
|
func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = btcutil.Amount(100000)
|
const chanAmt = btcutil.Amount(100000)
|
||||||
|
|
||||||
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a new nodes (Carol and Charlie), load her with some funds,
|
// Create a new nodes (Carol and Charlie), load her with some funds,
|
||||||
@@ -432,7 +432,7 @@ func testSendToRouteErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, charlie)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, charlie)
|
||||||
|
|
||||||
ht.ConnectNodes(carol, charlie)
|
ht.ConnectNodes(carol, charlie)
|
||||||
ht.OpenChannel(carol, charlie, lntemp.OpenChannelParams{Amt: chanAmt})
|
ht.OpenChannel(carol, charlie, lntest.OpenChannelParams{Amt: chanAmt})
|
||||||
|
|
||||||
// Query routes from Carol to Charlie which will be an invalid route
|
// Query routes from Carol to Charlie which will be an invalid route
|
||||||
// for Alice -> Bob.
|
// for Alice -> Bob.
|
||||||
@@ -476,7 +476,7 @@ func testSendToRouteErrorPropagation(ht *lntemp.HarnessTest) {
|
|||||||
// testPrivateChannels tests that a private channel can be used for
|
// testPrivateChannels tests that a private channel can be used for
|
||||||
// routing by the two endpoints of the channel, but is not known by
|
// routing by the two endpoints of the channel, but is not known by
|
||||||
// the rest of the nodes in the graph.
|
// the rest of the nodes in the graph.
|
||||||
func testPrivateChannels(ht *lntemp.HarnessTest) {
|
func testPrivateChannels(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = btcutil.Amount(100000)
|
const chanAmt = btcutil.Amount(100000)
|
||||||
|
|
||||||
// We create the following topology:
|
// We create the following topology:
|
||||||
@@ -493,7 +493,7 @@ func testPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
// Open a channel with 200k satoshis between Alice and Bob.
|
// Open a channel with 200k satoshis between Alice and Bob.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt * 2},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt * 2},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create Dave, and a channel to Alice of 100k.
|
// Create Dave, and a channel to Alice of 100k.
|
||||||
@@ -502,7 +502,7 @@ func testPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
|
||||||
|
|
||||||
chanPointDave := ht.OpenChannel(
|
chanPointDave := ht.OpenChannel(
|
||||||
dave, alice, lntemp.OpenChannelParams{Amt: chanAmt},
|
dave, alice, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Next, we'll create Carol and establish a channel from her to
|
// Next, we'll create Carol and establish a channel from her to
|
||||||
@@ -512,14 +512,14 @@ func testPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||||
|
|
||||||
chanPointCarol := ht.OpenChannel(
|
chanPointCarol := ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{Amt: chanAmt},
|
carol, dave, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Now create a _private_ channel directly between Carol and
|
// Now create a _private_ channel directly between Carol and
|
||||||
// Alice of 100k.
|
// Alice of 100k.
|
||||||
ht.ConnectNodes(carol, alice)
|
ht.ConnectNodes(carol, alice)
|
||||||
chanPointPrivate := ht.OpenChannel(
|
chanPointPrivate := ht.OpenChannel(
|
||||||
carol, alice, lntemp.OpenChannelParams{
|
carol, alice, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: true,
|
Private: true,
|
||||||
},
|
},
|
||||||
@@ -602,7 +602,7 @@ func testPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testInvoiceRoutingHints tests that the routing hints for an invoice are
|
// testInvoiceRoutingHints tests that the routing hints for an invoice are
|
||||||
// created properly.
|
// created properly.
|
||||||
func testInvoiceRoutingHints(ht *lntemp.HarnessTest) {
|
func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = btcutil.Amount(100000)
|
const chanAmt = btcutil.Amount(100000)
|
||||||
|
|
||||||
// Throughout this test, we'll be opening a channel between Alice and
|
// Throughout this test, we'll be opening a channel between Alice and
|
||||||
@@ -615,7 +615,7 @@ func testInvoiceRoutingHints(ht *lntemp.HarnessTest) {
|
|||||||
// invoice's payment.
|
// invoice's payment.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPointBob := ht.OpenChannel(
|
chanPointBob := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: chanAmt / 2,
|
PushAmt: chanAmt / 2,
|
||||||
Private: true,
|
Private: true,
|
||||||
@@ -629,7 +629,7 @@ func testInvoiceRoutingHints(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
ht.ConnectNodes(alice, carol)
|
ht.ConnectNodes(alice, carol)
|
||||||
chanPointCarol := ht.OpenChannel(
|
chanPointCarol := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: chanAmt / 2,
|
PushAmt: chanAmt / 2,
|
||||||
},
|
},
|
||||||
@@ -642,7 +642,7 @@ func testInvoiceRoutingHints(ht *lntemp.HarnessTest) {
|
|||||||
// that wish to stay unadvertised.
|
// that wish to stay unadvertised.
|
||||||
ht.ConnectNodes(bob, carol)
|
ht.ConnectNodes(bob, carol)
|
||||||
chanPointBobCarol := ht.OpenChannel(
|
chanPointBobCarol := ht.OpenChannel(
|
||||||
bob, carol, lntemp.OpenChannelParams{
|
bob, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: chanAmt / 2,
|
PushAmt: chanAmt / 2,
|
||||||
},
|
},
|
||||||
@@ -656,7 +656,7 @@ func testInvoiceRoutingHints(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
ht.ConnectNodes(alice, dave)
|
ht.ConnectNodes(alice, dave)
|
||||||
chanPointDave := ht.OpenChannel(
|
chanPointDave := ht.OpenChannel(
|
||||||
alice, dave, lntemp.OpenChannelParams{
|
alice, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: true,
|
Private: true,
|
||||||
},
|
},
|
||||||
@@ -669,7 +669,7 @@ func testInvoiceRoutingHints(ht *lntemp.HarnessTest) {
|
|||||||
eve := ht.NewNode("Eve", nil)
|
eve := ht.NewNode("Eve", nil)
|
||||||
ht.ConnectNodes(alice, eve)
|
ht.ConnectNodes(alice, eve)
|
||||||
chanPointEve := ht.OpenChannel(
|
chanPointEve := ht.OpenChannel(
|
||||||
alice, eve, lntemp.OpenChannelParams{
|
alice, eve, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: chanAmt / 2,
|
PushAmt: chanAmt / 2,
|
||||||
Private: true,
|
Private: true,
|
||||||
@@ -744,7 +744,7 @@ func testInvoiceRoutingHints(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testMultiHopOverPrivateChannels tests that private channels can be used as
|
// testMultiHopOverPrivateChannels tests that private channels can be used as
|
||||||
// intermediate hops in a route for payments.
|
// intermediate hops in a route for payments.
|
||||||
func testMultiHopOverPrivateChannels(ht *lntemp.HarnessTest) {
|
func testMultiHopOverPrivateChannels(ht *lntest.HarnessTest) {
|
||||||
// We'll test that multi-hop payments over private channels work as
|
// We'll test that multi-hop payments over private channels work as
|
||||||
// intended. To do so, we'll create the following topology:
|
// intended. To do so, we'll create the following topology:
|
||||||
// private public private
|
// private public private
|
||||||
@@ -755,7 +755,7 @@ func testMultiHopOverPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
// being the funder.
|
// being the funder.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPointAlice := ht.OpenChannel(
|
chanPointAlice := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: true,
|
Private: true,
|
||||||
},
|
},
|
||||||
@@ -766,7 +766,7 @@ func testMultiHopOverPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
carol := ht.NewNode("Carol", nil)
|
carol := ht.NewNode("Carol", nil)
|
||||||
ht.ConnectNodes(bob, carol)
|
ht.ConnectNodes(bob, carol)
|
||||||
chanPointBob := ht.OpenChannel(
|
chanPointBob := ht.OpenChannel(
|
||||||
bob, carol, lntemp.OpenChannelParams{
|
bob, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -781,7 +781,7 @@ func testMultiHopOverPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||||
|
|
||||||
chanPointCarol := ht.OpenChannel(
|
chanPointCarol := ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{
|
carol, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: true,
|
Private: true,
|
||||||
},
|
},
|
||||||
@@ -851,7 +851,7 @@ func testMultiHopOverPrivateChannels(ht *lntemp.HarnessTest) {
|
|||||||
// Alice --> Bob --> Carol --> Dave
|
// Alice --> Bob --> Carol --> Dave
|
||||||
//
|
//
|
||||||
// and query the daemon for routes from Alice to Dave.
|
// and query the daemon for routes from Alice to Dave.
|
||||||
func testQueryRoutes(ht *lntemp.HarnessTest) {
|
func testQueryRoutes(ht *lntest.HarnessTest) {
|
||||||
const chanAmt = btcutil.Amount(100000)
|
const chanAmt = btcutil.Amount(100000)
|
||||||
|
|
||||||
// Grab Alice and Bob from the standby nodes.
|
// Grab Alice and Bob from the standby nodes.
|
||||||
@@ -869,8 +869,8 @@ func testQueryRoutes(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// We now proceed to open channels:
|
// We now proceed to open channels:
|
||||||
// Alice=>Bob, Bob=>Carol and Carol=>Dave.
|
// Alice=>Bob, Bob=>Carol and Carol=>Dave.
|
||||||
p := lntemp.OpenChannelParams{Amt: chanAmt}
|
p := lntest.OpenChannelParams{Amt: chanAmt}
|
||||||
reqs := []*lntemp.OpenChannelRequest{
|
reqs := []*lntest.OpenChannelRequest{
|
||||||
{Local: alice, Remote: bob, Param: p},
|
{Local: alice, Remote: bob, Param: p},
|
||||||
{Local: bob, Remote: carol, Param: p},
|
{Local: bob, Remote: carol, Param: p},
|
||||||
{Local: carol, Remote: dave, Param: p},
|
{Local: carol, Remote: dave, Param: p},
|
||||||
@@ -1086,7 +1086,7 @@ func testMissionControlCfg(t *testing.T, hn *node.HarnessNode) {
|
|||||||
|
|
||||||
// testMissionControlImport tests import of mission control results from an
|
// testMissionControlImport tests import of mission control results from an
|
||||||
// external source.
|
// external source.
|
||||||
func testMissionControlImport(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func testMissionControlImport(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
fromNode, toNode []byte) {
|
fromNode, toNode []byte) {
|
||||||
|
|
||||||
// Reset mission control so that our query will return the default
|
// Reset mission control so that our query will return the default
|
||||||
@@ -1138,7 +1138,7 @@ func testMissionControlImport(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
|||||||
|
|
||||||
// testRouteFeeCutoff tests that we are able to prevent querying routes and
|
// testRouteFeeCutoff tests that we are able to prevent querying routes and
|
||||||
// sending payments that incur a fee higher than the fee limit.
|
// sending payments that incur a fee higher than the fee limit.
|
||||||
func testRouteFeeCutoff(ht *lntemp.HarnessTest) {
|
func testRouteFeeCutoff(ht *lntest.HarnessTest) {
|
||||||
// For this test, we'll create the following topology:
|
// For this test, we'll create the following topology:
|
||||||
//
|
//
|
||||||
// --- Bob ---
|
// --- Bob ---
|
||||||
@@ -1155,7 +1155,7 @@ func testRouteFeeCutoff(ht *lntemp.HarnessTest) {
|
|||||||
// Open a channel between Alice and Bob.
|
// Open a channel between Alice and Bob.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
chanPointAliceBob := ht.OpenChannel(
|
chanPointAliceBob := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create Carol's node and open a channel between her and Alice with
|
// Create Carol's node and open a channel between her and Alice with
|
||||||
@@ -1165,7 +1165,7 @@ func testRouteFeeCutoff(ht *lntemp.HarnessTest) {
|
|||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||||
|
|
||||||
chanPointAliceCarol := ht.OpenChannel(
|
chanPointAliceCarol := ht.OpenChannel(
|
||||||
alice, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create Dave's node and open a channel between him and Bob with Bob
|
// Create Dave's node and open a channel between him and Bob with Bob
|
||||||
@@ -1173,13 +1173,13 @@ func testRouteFeeCutoff(ht *lntemp.HarnessTest) {
|
|||||||
dave := ht.NewNode("Dave", nil)
|
dave := ht.NewNode("Dave", nil)
|
||||||
ht.ConnectNodes(dave, bob)
|
ht.ConnectNodes(dave, bob)
|
||||||
chanPointBobDave := ht.OpenChannel(
|
chanPointBobDave := ht.OpenChannel(
|
||||||
bob, dave, lntemp.OpenChannelParams{Amt: chanAmt},
|
bob, dave, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Open a channel between Carol and Dave.
|
// Open a channel between Carol and Dave.
|
||||||
ht.ConnectNodes(carol, dave)
|
ht.ConnectNodes(carol, dave)
|
||||||
chanPointCarolDave := ht.OpenChannel(
|
chanPointCarolDave := ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{Amt: chanAmt},
|
carol, dave, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Now that all the channels were set up, we'll wait for all the nodes
|
// Now that all the channels were set up, we'll wait for all the nodes
|
||||||
@@ -1203,7 +1203,7 @@ func testRouteFeeCutoff(ht *lntemp.HarnessTest) {
|
|||||||
baseFee := int64(10000)
|
baseFee := int64(10000)
|
||||||
feeRate := int64(5)
|
feeRate := int64(5)
|
||||||
timeLockDelta := uint32(chainreg.DefaultBitcoinTimeLockDelta)
|
timeLockDelta := uint32(chainreg.DefaultBitcoinTimeLockDelta)
|
||||||
maxHtlc := lntemp.CalculateMaxHtlc(chanAmt)
|
maxHtlc := lntest.CalculateMaxHtlc(chanAmt)
|
||||||
|
|
||||||
expectedPolicy := &lnrpc.RoutingPolicy{
|
expectedPolicy := &lnrpc.RoutingPolicy{
|
||||||
FeeBaseMsat: baseFee,
|
FeeBaseMsat: baseFee,
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
"github.com/lightningnetwork/lnd/zpay32"
|
"github.com/lightningnetwork/lnd/zpay32"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
// testRPCMiddlewareInterceptor tests that the RPC middleware interceptor can
|
// testRPCMiddlewareInterceptor tests that the RPC middleware interceptor can
|
||||||
// be used correctly and in a safe way.
|
// be used correctly and in a safe way.
|
||||||
func testRPCMiddlewareInterceptor(ht *lntemp.HarnessTest) {
|
func testRPCMiddlewareInterceptor(ht *lntest.HarnessTest) {
|
||||||
// Let's first enable the middleware interceptor.
|
// Let's first enable the middleware interceptor.
|
||||||
//
|
//
|
||||||
// NOTE: we cannot use standby nodes here as the test messes with
|
// NOTE: we cannot use standby nodes here as the test messes with
|
||||||
@@ -32,7 +32,7 @@ func testRPCMiddlewareInterceptor(ht *lntemp.HarnessTest) {
|
|||||||
// data to inspect when doing RPC calls to Alice later.
|
// data to inspect when doing RPC calls to Alice later.
|
||||||
ht.EnsureConnected(alice, bob)
|
ht.EnsureConnected(alice, bob)
|
||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
|
||||||
ht.OpenChannel(alice, bob, lntemp.OpenChannelParams{Amt: 1_234_567})
|
ht.OpenChannel(alice, bob, lntest.OpenChannelParams{Amt: 1_234_567})
|
||||||
|
|
||||||
// Load or bake the macaroons that the simulated users will use to
|
// Load or bake the macaroons that the simulated users will use to
|
||||||
// access the RPC.
|
// access the RPC.
|
||||||
@@ -545,7 +545,7 @@ func middlewareRequestManipulationTest(t *testing.T, node *node.HarnessNode,
|
|||||||
|
|
||||||
// middlewareMandatoryTest tests that all RPC requests are blocked if there is
|
// middlewareMandatoryTest tests that all RPC requests are blocked if there is
|
||||||
// a mandatory middleware declared that's currently not registered.
|
// a mandatory middleware declared that's currently not registered.
|
||||||
func middlewareMandatoryTest(ht *lntemp.HarnessTest, node *node.HarnessNode) {
|
func middlewareMandatoryTest(ht *lntest.HarnessTest, node *node.HarnessNode) {
|
||||||
// Let's declare our itest interceptor as mandatory but don't register
|
// Let's declare our itest interceptor as mandatory but don't register
|
||||||
// it just yet. That should cause all RPC requests to fail, except for
|
// it just yet. That should cause all RPC requests to fail, except for
|
||||||
// the registration itself.
|
// the registration itself.
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testSendMultiPathPayment tests that we are able to successfully route a
|
// testSendMultiPathPayment tests that we are able to successfully route a
|
||||||
// payment using multiple shards across different paths.
|
// payment using multiple shards across different paths.
|
||||||
func testSendMultiPathPayment(ht *lntemp.HarnessTest) {
|
func testSendMultiPathPayment(ht *lntest.HarnessTest) {
|
||||||
mts := newMppTestScenario(ht)
|
mts := newMppTestScenario(ht)
|
||||||
|
|
||||||
const paymentAmt = btcutil.Amount(300000)
|
const paymentAmt = btcutil.Amount(300000)
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
// DeriveSharedKey. It creates an ephemeral private key, performing an ECDH with
|
// DeriveSharedKey. It creates an ephemeral private key, performing an ECDH with
|
||||||
// the node's pubkey and a customized public key to check the validity of the
|
// the node's pubkey and a customized public key to check the validity of the
|
||||||
// result.
|
// result.
|
||||||
func testDeriveSharedKey(ht *lntemp.HarnessTest) {
|
func testDeriveSharedKey(ht *lntest.HarnessTest) {
|
||||||
runDeriveSharedKey(ht, ht.Alice)
|
runDeriveSharedKey(ht, ht.Alice)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func testDeriveSharedKey(ht *lntemp.HarnessTest) {
|
|||||||
// DeriveSharedKey. It creates an ephemeral private key, performing an ECDH with
|
// DeriveSharedKey. It creates an ephemeral private key, performing an ECDH with
|
||||||
// the node's pubkey and a customized public key to check the validity of the
|
// the node's pubkey and a customized public key to check the validity of the
|
||||||
// result.
|
// result.
|
||||||
func runDeriveSharedKey(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
func runDeriveSharedKey(ht *lntest.HarnessTest, alice *node.HarnessNode) {
|
||||||
// Create an ephemeral key, extracts its public key, and make a
|
// Create an ephemeral key, extracts its public key, and make a
|
||||||
// PrivKeyECDH using the ephemeral key.
|
// PrivKeyECDH using the ephemeral key.
|
||||||
ephemeralPriv, err := btcec.NewPrivateKey()
|
ephemeralPriv, err := btcec.NewPrivateKey()
|
||||||
@@ -194,13 +194,13 @@ func runDeriveSharedKey(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
|||||||
|
|
||||||
// testSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all
|
// testSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all
|
||||||
// custom ways of specifying the signing key in the key descriptor/locator.
|
// custom ways of specifying the signing key in the key descriptor/locator.
|
||||||
func testSignOutputRaw(ht *lntemp.HarnessTest) {
|
func testSignOutputRaw(ht *lntest.HarnessTest) {
|
||||||
runSignOutputRaw(ht, ht.Alice)
|
runSignOutputRaw(ht, ht.Alice)
|
||||||
}
|
}
|
||||||
|
|
||||||
// runSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all
|
// runSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all
|
||||||
// custom ways of specifying the signing key in the key descriptor/locator.
|
// custom ways of specifying the signing key in the key descriptor/locator.
|
||||||
func runSignOutputRaw(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
func runSignOutputRaw(ht *lntest.HarnessTest, alice *node.HarnessNode) {
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
// for this. We want this to be an index of zero.
|
// for this. We want this to be an index of zero.
|
||||||
const testCustomKeyFamily = 44
|
const testCustomKeyFamily = 44
|
||||||
@@ -272,7 +272,7 @@ func runSignOutputRaw(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
|||||||
// assertSignOutputRaw sends coins to a p2wkh address derived from the given
|
// assertSignOutputRaw sends coins to a p2wkh address derived from the given
|
||||||
// target public key and then tries to spend that output again by invoking the
|
// target public key and then tries to spend that output again by invoking the
|
||||||
// SignOutputRaw RPC with the key descriptor provided.
|
// SignOutputRaw RPC with the key descriptor provided.
|
||||||
func assertSignOutputRaw(ht *lntemp.HarnessTest,
|
func assertSignOutputRaw(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode, targetPubKey *btcec.PublicKey,
|
alice *node.HarnessNode, targetPubKey *btcec.PublicKey,
|
||||||
keyDesc *signrpc.KeyDescriptor,
|
keyDesc *signrpc.KeyDescriptor,
|
||||||
sigHash txscript.SigHashType) {
|
sigHash txscript.SigHashType) {
|
||||||
@@ -373,14 +373,14 @@ func assertSignOutputRaw(ht *lntemp.HarnessTest,
|
|||||||
// testSignVerifyMessage makes sure that the SignMessage RPC can be used with
|
// testSignVerifyMessage makes sure that the SignMessage RPC can be used with
|
||||||
// all custom flags by verifying with VerifyMessage. Tests both ECDSA and
|
// all custom flags by verifying with VerifyMessage. Tests both ECDSA and
|
||||||
// Schnorr signatures.
|
// Schnorr signatures.
|
||||||
func testSignVerifyMessage(ht *lntemp.HarnessTest) {
|
func testSignVerifyMessage(ht *lntest.HarnessTest) {
|
||||||
runSignVerifyMessage(ht, ht.Alice)
|
runSignVerifyMessage(ht, ht.Alice)
|
||||||
}
|
}
|
||||||
|
|
||||||
// runSignVerifyMessage makes sure that the SignMessage RPC can be used with
|
// runSignVerifyMessage makes sure that the SignMessage RPC can be used with
|
||||||
// all custom flags by verifying with VerifyMessage. Tests both ECDSA and
|
// all custom flags by verifying with VerifyMessage. Tests both ECDSA and
|
||||||
// Schnorr signatures.
|
// Schnorr signatures.
|
||||||
func runSignVerifyMessage(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
func runSignVerifyMessage(ht *lntest.HarnessTest, alice *node.HarnessNode) {
|
||||||
aliceMsg := []byte("alice msg")
|
aliceMsg := []byte("alice msg")
|
||||||
keyLoc := &signrpc.KeyLocator{
|
keyLoc := &signrpc.KeyLocator{
|
||||||
KeyFamily: int32(keychain.KeyFamilyNodeKey),
|
KeyFamily: int32(keychain.KeyFamilyNodeKey),
|
||||||
|
|||||||
@@ -7,20 +7,20 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/record"
|
"github.com/lightningnetwork/lnd/record"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testSingleHopInvoice(ht *lntemp.HarnessTest) {
|
func testSingleHopInvoice(ht *lntest.HarnessTest) {
|
||||||
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
// Open a channel with 100k satoshis between Alice and Bob with Alice
|
||||||
// being the sole funder of the channel.
|
// being the sole funder of the channel.
|
||||||
chanAmt := btcutil.Amount(100000)
|
chanAmt := btcutil.Amount(100000)
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
cp := ht.OpenChannel(
|
cp := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// assertAmountPaid is a helper closure that asserts the amount paid by
|
// assertAmountPaid is a helper closure that asserts the amount paid by
|
||||||
|
|||||||
+12
-12
@@ -3,8 +3,8 @@ package itest
|
|||||||
import (
|
import (
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,11 +21,11 @@ const (
|
|||||||
//
|
//
|
||||||
// The general flow of this test:
|
// The general flow of this test:
|
||||||
// 1. Carol --> Dave --> Alice --> Bob forward payment
|
// 1. Carol --> Dave --> Alice --> Bob forward payment
|
||||||
// 2. -------X X X Bob restart sender and intermediaries
|
// 2. X X X Bob restart sender and intermediaries
|
||||||
// 3. Carol <-- Dave <-- Alice <-- Bob expect settle to propagate
|
// 3. Carol <-- Dave <-- Alice <-- Bob expect settle to propagate
|
||||||
//
|
//
|
||||||
//nolint:dupword
|
//nolint:dupword
|
||||||
func testSwitchCircuitPersistence(ht *lntemp.HarnessTest) {
|
func testSwitchCircuitPersistence(ht *lntest.HarnessTest) {
|
||||||
// Setup our test scenario. We should now have four nodes running with
|
// Setup our test scenario. We should now have four nodes running with
|
||||||
// three channels.
|
// three channels.
|
||||||
s := setupScenarioFourNodes(ht)
|
s := setupScenarioFourNodes(ht)
|
||||||
@@ -95,7 +95,7 @@ func testSwitchCircuitPersistence(ht *lntemp.HarnessTest) {
|
|||||||
// 2. Carol --- Dave X Alice --- Bob disconnect intermediaries
|
// 2. Carol --- Dave X Alice --- Bob disconnect intermediaries
|
||||||
// 3. Carol --- Dave X Alice <-- Bob settle last hop
|
// 3. Carol --- Dave X Alice <-- Bob settle last hop
|
||||||
// 4. Carol <-- Dave <-- Alice --- Bob reconnect, expect settle to propagate
|
// 4. Carol <-- Dave <-- Alice --- Bob reconnect, expect settle to propagate
|
||||||
func testSwitchOfflineDelivery(ht *lntemp.HarnessTest) {
|
func testSwitchOfflineDelivery(ht *lntest.HarnessTest) {
|
||||||
// Setup our test scenario. We should now have four nodes running with
|
// Setup our test scenario. We should now have four nodes running with
|
||||||
// three channels.
|
// three channels.
|
||||||
s := setupScenarioFourNodes(ht)
|
s := setupScenarioFourNodes(ht)
|
||||||
@@ -174,7 +174,7 @@ func testSwitchOfflineDelivery(ht *lntemp.HarnessTest) {
|
|||||||
// 3. Carol --- Dave X Alice <-- Bob settle last hop
|
// 3. Carol --- Dave X Alice <-- Bob settle last hop
|
||||||
// 4. Carol --- Dave X X Bob restart Alice
|
// 4. Carol --- Dave X X Bob restart Alice
|
||||||
// 5. Carol <-- Dave <-- Alice --- Bob expect settle to propagate
|
// 5. Carol <-- Dave <-- Alice --- Bob expect settle to propagate
|
||||||
func testSwitchOfflineDeliveryPersistence(ht *lntemp.HarnessTest) {
|
func testSwitchOfflineDeliveryPersistence(ht *lntest.HarnessTest) {
|
||||||
// Setup our test scenario. We should now have four nodes running with
|
// Setup our test scenario. We should now have four nodes running with
|
||||||
// three channels.
|
// three channels.
|
||||||
s := setupScenarioFourNodes(ht)
|
s := setupScenarioFourNodes(ht)
|
||||||
@@ -260,7 +260,7 @@ func testSwitchOfflineDeliveryPersistence(ht *lntemp.HarnessTest) {
|
|||||||
// 3. Carol --- Dave X Alice <-- Bob settle last hop
|
// 3. Carol --- Dave X Alice <-- Bob settle last hop
|
||||||
// 4. Carol --- Dave X X shutdown Bob, restart Alice
|
// 4. Carol --- Dave X X shutdown Bob, restart Alice
|
||||||
// 5. Carol <-- Dave <-- Alice X expect settle to propagate
|
// 5. Carol <-- Dave <-- Alice X expect settle to propagate
|
||||||
func testSwitchOfflineDeliveryOutgoingOffline(ht *lntemp.HarnessTest) {
|
func testSwitchOfflineDeliveryOutgoingOffline(ht *lntest.HarnessTest) {
|
||||||
// Setup our test scenario. We should now have four nodes running with
|
// Setup our test scenario. We should now have four nodes running with
|
||||||
// three channels. Note that we won't call the cleanUp function here as
|
// three channels. Note that we won't call the cleanUp function here as
|
||||||
// we will manually stop the node Carol and her channel.
|
// we will manually stop the node Carol and her channel.
|
||||||
@@ -371,13 +371,13 @@ type scenarioFourNodes struct {
|
|||||||
//
|
//
|
||||||
// NOTE: caller needs to call cleanUp to clean the nodes and channels created
|
// NOTE: caller needs to call cleanUp to clean the nodes and channels created
|
||||||
// from this setup.
|
// from this setup.
|
||||||
func setupScenarioFourNodes(ht *lntemp.HarnessTest) *scenarioFourNodes {
|
func setupScenarioFourNodes(ht *lntest.HarnessTest) *scenarioFourNodes {
|
||||||
const (
|
const (
|
||||||
chanAmt = btcutil.Amount(1000000)
|
chanAmt = btcutil.Amount(1000000)
|
||||||
pushAmt = btcutil.Amount(900000)
|
pushAmt = btcutil.Amount(900000)
|
||||||
)
|
)
|
||||||
|
|
||||||
params := lntemp.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ func setupScenarioFourNodes(ht *lntemp.HarnessTest) *scenarioFourNodes {
|
|||||||
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
|
||||||
|
|
||||||
// Open channels in batch to save blocks mined.
|
// Open channels in batch to save blocks mined.
|
||||||
reqs := []*lntemp.OpenChannelRequest{
|
reqs := []*lntest.OpenChannelRequest{
|
||||||
{Local: alice, Remote: bob, Param: params},
|
{Local: alice, Remote: bob, Param: params},
|
||||||
{Local: dave, Remote: alice, Param: params},
|
{Local: dave, Remote: alice, Param: params},
|
||||||
{Local: carol, Remote: dave, Param: params},
|
{Local: carol, Remote: dave, Param: params},
|
||||||
@@ -456,7 +456,7 @@ func setupScenarioFourNodes(ht *lntemp.HarnessTest) *scenarioFourNodes {
|
|||||||
|
|
||||||
// assertHTLCs is a helper function which asserts the desired num of
|
// assertHTLCs is a helper function which asserts the desired num of
|
||||||
// HTLCs has been seen in the nodes.
|
// HTLCs has been seen in the nodes.
|
||||||
func (s *scenarioFourNodes) assertHTLCs(ht *lntemp.HarnessTest, num int) {
|
func (s *scenarioFourNodes) assertHTLCs(ht *lntest.HarnessTest, num int) {
|
||||||
// Alice should have both the same number of outgoing and
|
// Alice should have both the same number of outgoing and
|
||||||
// incoming HTLCs.
|
// incoming HTLCs.
|
||||||
ht.AssertNumActiveHtlcs(s.alice, num*2)
|
ht.AssertNumActiveHtlcs(s.alice, num*2)
|
||||||
@@ -472,7 +472,7 @@ func (s *scenarioFourNodes) assertHTLCs(ht *lntemp.HarnessTest, num int) {
|
|||||||
// assertAmoutPaid is a helper method which takes a given paid amount
|
// assertAmoutPaid is a helper method which takes a given paid amount
|
||||||
// and number of payments and asserts the desired payments are made in
|
// and number of payments and asserts the desired payments are made in
|
||||||
// the four nodes.
|
// the four nodes.
|
||||||
func (s *scenarioFourNodes) assertAmoutPaid(ht *lntemp.HarnessTest,
|
func (s *scenarioFourNodes) assertAmoutPaid(ht *lntest.HarnessTest,
|
||||||
amt int64, num int64) {
|
amt int64, num int64) {
|
||||||
|
|
||||||
ht.AssertAmountPaid(
|
ht.AssertAmountPaid(
|
||||||
|
|||||||
+27
-27
@@ -20,8 +20,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -47,7 +47,7 @@ var (
|
|||||||
|
|
||||||
// testTaproot ensures that the daemon can send to and spend from taproot (p2tr)
|
// testTaproot ensures that the daemon can send to and spend from taproot (p2tr)
|
||||||
// outputs.
|
// outputs.
|
||||||
func testTaproot(ht *lntemp.HarnessTest) {
|
func testTaproot(ht *lntest.HarnessTest) {
|
||||||
testTaprootSendCoinsKeySpendBip86(ht, ht.Alice)
|
testTaprootSendCoinsKeySpendBip86(ht, ht.Alice)
|
||||||
testTaprootComputeInputScriptKeySpendBip86(ht, ht.Alice)
|
testTaprootComputeInputScriptKeySpendBip86(ht, ht.Alice)
|
||||||
testTaprootSignOutputRawScriptSpend(ht, ht.Alice)
|
testTaprootSignOutputRawScriptSpend(ht, ht.Alice)
|
||||||
@@ -81,7 +81,7 @@ func testTaproot(ht *lntemp.HarnessTest) {
|
|||||||
// testTaprootSendCoinsKeySpendBip86 tests sending to and spending from
|
// testTaprootSendCoinsKeySpendBip86 tests sending to and spending from
|
||||||
// p2tr key spend only (BIP-0086) addresses through the SendCoins RPC which
|
// p2tr key spend only (BIP-0086) addresses through the SendCoins RPC which
|
||||||
// internally uses the ComputeInputScript method for signing.
|
// internally uses the ComputeInputScript method for signing.
|
||||||
func testTaprootSendCoinsKeySpendBip86(ht *lntemp.HarnessTest,
|
func testTaprootSendCoinsKeySpendBip86(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// We'll start the test by sending Alice some coins, which she'll use to
|
// We'll start the test by sending Alice some coins, which she'll use to
|
||||||
@@ -137,7 +137,7 @@ func testTaprootSendCoinsKeySpendBip86(ht *lntemp.HarnessTest,
|
|||||||
// testTaprootComputeInputScriptKeySpendBip86 tests sending to and spending from
|
// testTaprootComputeInputScriptKeySpendBip86 tests sending to and spending from
|
||||||
// p2tr key spend only (BIP-0086) addresses through the SendCoins RPC which
|
// p2tr key spend only (BIP-0086) addresses through the SendCoins RPC which
|
||||||
// internally uses the ComputeInputScript method for signing.
|
// internally uses the ComputeInputScript method for signing.
|
||||||
func testTaprootComputeInputScriptKeySpendBip86(ht *lntemp.HarnessTest,
|
func testTaprootComputeInputScriptKeySpendBip86(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// We'll start the test by sending Alice some coins, which she'll use
|
// We'll start the test by sending Alice some coins, which she'll use
|
||||||
@@ -234,7 +234,7 @@ func testTaprootComputeInputScriptKeySpendBip86(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootSignOutputRawScriptSpend tests sending to and spending from p2tr
|
// testTaprootSignOutputRawScriptSpend tests sending to and spending from p2tr
|
||||||
// script addresses using the script path with the SignOutputRaw RPC.
|
// script addresses using the script path with the SignOutputRaw RPC.
|
||||||
func testTaprootSignOutputRawScriptSpend(ht *lntemp.HarnessTest,
|
func testTaprootSignOutputRawScriptSpend(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode, sigHashType ...txscript.SigHashType) {
|
alice *node.HarnessNode, sigHashType ...txscript.SigHashType) {
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
@@ -392,7 +392,7 @@ func testTaprootSignOutputRawScriptSpend(ht *lntemp.HarnessTest,
|
|||||||
// testTaprootSignOutputRawKeySpendBip86 tests that a tapscript address can
|
// testTaprootSignOutputRawKeySpendBip86 tests that a tapscript address can
|
||||||
// also be spent using the key spend path through the SignOutputRaw RPC using a
|
// also be spent using the key spend path through the SignOutputRaw RPC using a
|
||||||
// BIP0086 key spend only commitment.
|
// BIP0086 key spend only commitment.
|
||||||
func testTaprootSignOutputRawKeySpendBip86(ht *lntemp.HarnessTest,
|
func testTaprootSignOutputRawKeySpendBip86(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode, sigHashType ...txscript.SigHashType) {
|
alice *node.HarnessNode, sigHashType ...txscript.SigHashType) {
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
@@ -490,7 +490,7 @@ func testTaprootSignOutputRawKeySpendBip86(ht *lntemp.HarnessTest,
|
|||||||
// testTaprootSignOutputRawKeySpendRootHash tests that a tapscript address can
|
// testTaprootSignOutputRawKeySpendRootHash tests that a tapscript address can
|
||||||
// also be spent using the key spend path through the SignOutputRaw RPC using a
|
// also be spent using the key spend path through the SignOutputRaw RPC using a
|
||||||
// tapscript root hash.
|
// tapscript root hash.
|
||||||
func testTaprootSignOutputRawKeySpendRootHash(ht *lntemp.HarnessTest,
|
func testTaprootSignOutputRawKeySpendRootHash(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
@@ -583,7 +583,7 @@ func testTaprootSignOutputRawKeySpendRootHash(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootMuSig2KeySpendBip86 tests that a combined MuSig2 key can also be
|
// testTaprootMuSig2KeySpendBip86 tests that a combined MuSig2 key can also be
|
||||||
// used as a BIP-0086 key spend only key.
|
// used as a BIP-0086 key spend only key.
|
||||||
func testTaprootMuSig2KeySpendBip86(ht *lntemp.HarnessTest,
|
func testTaprootMuSig2KeySpendBip86(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
||||||
|
|
||||||
// We're not going to commit to a script. So our taproot tweak will be
|
// We're not going to commit to a script. So our taproot tweak will be
|
||||||
@@ -711,7 +711,7 @@ func testTaprootMuSig2KeySpendBip86(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootMuSig2KeySpendRootHash tests that a tapscript address can also be
|
// testTaprootMuSig2KeySpendRootHash tests that a tapscript address can also be
|
||||||
// spent using a MuSig2 combined key.
|
// spent using a MuSig2 combined key.
|
||||||
func testTaprootMuSig2KeySpendRootHash(ht *lntemp.HarnessTest,
|
func testTaprootMuSig2KeySpendRootHash(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
||||||
|
|
||||||
// We're going to commit to a script as well. This is a hash lock with a
|
// We're going to commit to a script as well. This is a hash lock with a
|
||||||
@@ -843,7 +843,7 @@ func testTaprootMuSig2KeySpendRootHash(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootMuSig2ScriptSpend tests that a tapscript address with an internal
|
// testTaprootMuSig2ScriptSpend tests that a tapscript address with an internal
|
||||||
// key that is a MuSig2 combined key can also be spent using the script path.
|
// key that is a MuSig2 combined key can also be spent using the script path.
|
||||||
func testTaprootMuSig2ScriptSpend(ht *lntemp.HarnessTest,
|
func testTaprootMuSig2ScriptSpend(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
||||||
|
|
||||||
// We're going to commit to a script and spend the output using the
|
// We're going to commit to a script and spend the output using the
|
||||||
@@ -926,7 +926,7 @@ func testTaprootMuSig2ScriptSpend(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootMuSig2CombinedLeafKeySpend tests that a MuSig2 combined key can be
|
// testTaprootMuSig2CombinedLeafKeySpend tests that a MuSig2 combined key can be
|
||||||
// used for an OP_CHECKSIG inside a tap script leaf spend.
|
// used for an OP_CHECKSIG inside a tap script leaf spend.
|
||||||
func testTaprootMuSig2CombinedLeafKeySpend(ht *lntemp.HarnessTest,
|
func testTaprootMuSig2CombinedLeafKeySpend(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
alice *node.HarnessNode, version signrpc.MuSig2Version) {
|
||||||
|
|
||||||
// We're using the combined MuSig2 key in a script leaf. So we need to
|
// We're using the combined MuSig2 key in a script leaf. So we need to
|
||||||
@@ -1102,7 +1102,7 @@ func testTaprootMuSig2CombinedLeafKeySpend(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootImportTapscriptScriptSpend tests importing p2tr script addresses
|
// testTaprootImportTapscriptScriptSpend tests importing p2tr script addresses
|
||||||
// using the script path with the full tree known.
|
// using the script path with the full tree known.
|
||||||
func testTaprootImportTapscriptFullTree(ht *lntemp.HarnessTest,
|
func testTaprootImportTapscriptFullTree(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
@@ -1176,7 +1176,7 @@ func testTaprootImportTapscriptFullTree(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootImportTapscriptPartialReveal tests importing p2tr script addresses
|
// testTaprootImportTapscriptPartialReveal tests importing p2tr script addresses
|
||||||
// for which we only know part of the tree.
|
// for which we only know part of the tree.
|
||||||
func testTaprootImportTapscriptPartialReveal(ht *lntemp.HarnessTest,
|
func testTaprootImportTapscriptPartialReveal(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
@@ -1247,7 +1247,7 @@ func testTaprootImportTapscriptPartialReveal(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootImportTapscriptRootHashOnly tests importing p2tr script addresses
|
// testTaprootImportTapscriptRootHashOnly tests importing p2tr script addresses
|
||||||
// for which we only know the root hash.
|
// for which we only know the root hash.
|
||||||
func testTaprootImportTapscriptRootHashOnly(ht *lntemp.HarnessTest,
|
func testTaprootImportTapscriptRootHashOnly(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
@@ -1306,7 +1306,7 @@ func testTaprootImportTapscriptRootHashOnly(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testTaprootImportTapscriptFullKey tests importing p2tr script addresses for
|
// testTaprootImportTapscriptFullKey tests importing p2tr script addresses for
|
||||||
// which we only know the full Taproot key.
|
// which we only know the full Taproot key.
|
||||||
func testTaprootImportTapscriptFullKey(ht *lntemp.HarnessTest,
|
func testTaprootImportTapscriptFullKey(ht *lntest.HarnessTest,
|
||||||
alice *node.HarnessNode) {
|
alice *node.HarnessNode) {
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
// For the next step, we need a public key. Let's use a special family
|
||||||
@@ -1365,7 +1365,7 @@ func testTaprootImportTapscriptFullKey(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// clearWalletImportedTapscriptBalance manually assembles and then attempts to
|
// clearWalletImportedTapscriptBalance manually assembles and then attempts to
|
||||||
// sign a TX to sweep funds from an imported tapscript address.
|
// sign a TX to sweep funds from an imported tapscript address.
|
||||||
func clearWalletImportedTapscriptBalance(ht *lntemp.HarnessTest,
|
func clearWalletImportedTapscriptBalance(ht *lntest.HarnessTest,
|
||||||
hn *node.HarnessNode, utxo *wire.TxOut, outPoint wire.OutPoint,
|
hn *node.HarnessNode, utxo *wire.TxOut, outPoint wire.OutPoint,
|
||||||
internalKey *btcec.PublicKey, derivationPath []uint32,
|
internalKey *btcec.PublicKey, derivationPath []uint32,
|
||||||
rootHash []byte) {
|
rootHash []byte) {
|
||||||
@@ -1460,7 +1460,7 @@ func testScriptSchnorrSig(t *testing.T,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newAddrWithScript returns a new address and its pkScript.
|
// newAddrWithScript returns a new address and its pkScript.
|
||||||
func newAddrWithScript(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
func newAddrWithScript(ht *lntest.HarnessTest, node *node.HarnessNode,
|
||||||
addrType lnrpc.AddressType) (btcutil.Address, []byte) {
|
addrType lnrpc.AddressType) (btcutil.Address, []byte) {
|
||||||
|
|
||||||
p2wkhResp := node.RPC.NewAddress(&lnrpc.NewAddressRequest{
|
p2wkhResp := node.RPC.NewAddress(&lnrpc.NewAddressRequest{
|
||||||
@@ -1479,7 +1479,7 @@ func newAddrWithScript(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
|||||||
|
|
||||||
// sendToTaprootOutput sends coins to a p2tr output of the given taproot key and
|
// sendToTaprootOutput sends coins to a p2tr output of the given taproot key and
|
||||||
// mines a block to confirm the coins.
|
// mines a block to confirm the coins.
|
||||||
func sendToTaprootOutput(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func sendToTaprootOutput(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
taprootKey *btcec.PublicKey, amt int64) (wire.OutPoint, []byte) {
|
taprootKey *btcec.PublicKey, amt int64) (wire.OutPoint, []byte) {
|
||||||
|
|
||||||
tapScriptAddr, err := btcutil.NewAddressTaproot(
|
tapScriptAddr, err := btcutil.NewAddressTaproot(
|
||||||
@@ -1542,7 +1542,7 @@ func sendToTaprootOutput(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
|||||||
// after checking its weight against an estimate. After asserting the given
|
// after checking its weight against an estimate. After asserting the given
|
||||||
// spend request, the given sweep address' balance is verified to be seen as
|
// spend request, the given sweep address' balance is verified to be seen as
|
||||||
// funds belonging to the wallet.
|
// funds belonging to the wallet.
|
||||||
func publishTxAndConfirmSweep(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
func publishTxAndConfirmSweep(ht *lntest.HarnessTest, node *node.HarnessNode,
|
||||||
tx *wire.MsgTx, estimatedWeight int64,
|
tx *wire.MsgTx, estimatedWeight int64,
|
||||||
spendRequest *chainrpc.SpendRequest, sweepAddr string) {
|
spendRequest *chainrpc.SpendRequest, sweepAddr string) {
|
||||||
|
|
||||||
@@ -1604,7 +1604,7 @@ func publishTxAndConfirmSweep(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
|||||||
// confirmAddress makes sure that a transaction in the mempool spends funds to
|
// confirmAddress makes sure that a transaction in the mempool spends funds to
|
||||||
// the given address. It also checks that a confirmation notification for the
|
// the given address. It also checks that a confirmation notification for the
|
||||||
// address is triggered when the transaction is mined.
|
// address is triggered when the transaction is mined.
|
||||||
func confirmAddress(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
func confirmAddress(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||||
addrString string) {
|
addrString string) {
|
||||||
|
|
||||||
// Wait until the tx that sends to the address is found.
|
// Wait until the tx that sends to the address is found.
|
||||||
@@ -1654,7 +1654,7 @@ func confirmAddress(ht *lntemp.HarnessTest, hn *node.HarnessNode,
|
|||||||
|
|
||||||
// deriveSigningKeys derives three signing keys and returns their descriptors,
|
// deriveSigningKeys derives three signing keys and returns their descriptors,
|
||||||
// as well as the public keys in the Schnorr serialized format.
|
// as well as the public keys in the Schnorr serialized format.
|
||||||
func deriveSigningKeys(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
func deriveSigningKeys(ht *lntest.HarnessTest, node *node.HarnessNode,
|
||||||
version signrpc.MuSig2Version) (*signrpc.KeyDescriptor,
|
version signrpc.MuSig2Version) (*signrpc.KeyDescriptor,
|
||||||
*signrpc.KeyDescriptor, *signrpc.KeyDescriptor, [][]byte) {
|
*signrpc.KeyDescriptor, *signrpc.KeyDescriptor, [][]byte) {
|
||||||
|
|
||||||
@@ -1700,7 +1700,7 @@ func deriveSigningKeys(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
|||||||
// combined into a single key. The same node is used for the three signing
|
// combined into a single key. The same node is used for the three signing
|
||||||
// participants but a separate key is generated for each session. So the result
|
// participants but a separate key is generated for each session. So the result
|
||||||
// should be the same as if it were three different nodes.
|
// should be the same as if it were three different nodes.
|
||||||
func createMuSigSessions(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
func createMuSigSessions(ht *lntest.HarnessTest, node *node.HarnessNode,
|
||||||
taprootTweak *signrpc.TaprootTweakDesc,
|
taprootTweak *signrpc.TaprootTweakDesc,
|
||||||
keyDesc1, keyDesc2, keyDesc3 *signrpc.KeyDescriptor,
|
keyDesc1, keyDesc2, keyDesc3 *signrpc.KeyDescriptor,
|
||||||
allPubKeys [][]byte, version signrpc.MuSig2Version) (*btcec.PublicKey,
|
allPubKeys [][]byte, version signrpc.MuSig2Version) (*btcec.PublicKey,
|
||||||
@@ -1838,7 +1838,7 @@ func createMuSigSessions(ht *lntemp.HarnessTest, node *node.HarnessNode,
|
|||||||
// testTaprootCoopClose asserts that if both peers signal ShutdownAnySegwit,
|
// testTaprootCoopClose asserts that if both peers signal ShutdownAnySegwit,
|
||||||
// then a taproot closing addr is used. Otherwise, we shouldn't expect one to
|
// then a taproot closing addr is used. Otherwise, we shouldn't expect one to
|
||||||
// be used.
|
// be used.
|
||||||
func testTaprootCoopClose(ht *lntemp.HarnessTest) {
|
func testTaprootCoopClose(ht *lntest.HarnessTest) {
|
||||||
// We'll start by making two new nodes, and funding a channel between
|
// We'll start by making two new nodes, and funding a channel between
|
||||||
// them.
|
// them.
|
||||||
carol := ht.NewNode("Carol", nil)
|
carol := ht.NewNode("Carol", nil)
|
||||||
@@ -1853,7 +1853,7 @@ func testTaprootCoopClose(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// We'll now open a channel between Carol and Dave.
|
// We'll now open a channel between Carol and Dave.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
carol, dave, lntemp.OpenChannelParams{
|
carol, dave, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
SatPerVByte: satPerVbyte,
|
SatPerVByte: satPerVbyte,
|
||||||
@@ -1888,7 +1888,7 @@ func testTaprootCoopClose(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// We'll now open up a chanel again between Carol and Eve.
|
// We'll now open up a chanel again between Carol and Eve.
|
||||||
chanPoint = ht.OpenChannel(
|
chanPoint = ht.OpenChannel(
|
||||||
carol, eve, lntemp.OpenChannelParams{
|
carol, eve, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
SatPerVByte: satPerVbyte,
|
SatPerVByte: satPerVbyte,
|
||||||
@@ -1904,7 +1904,7 @@ func testTaprootCoopClose(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testMuSig2CombineKey makes sure that combining a key with MuSig2 returns the
|
// testMuSig2CombineKey makes sure that combining a key with MuSig2 returns the
|
||||||
// correct result according to the MuSig2 version specified.
|
// correct result according to the MuSig2 version specified.
|
||||||
func testMuSig2CombineKey(ht *lntemp.HarnessTest, alice *node.HarnessNode,
|
func testMuSig2CombineKey(ht *lntest.HarnessTest, alice *node.HarnessNode,
|
||||||
version signrpc.MuSig2Version) {
|
version signrpc.MuSig2Version) {
|
||||||
|
|
||||||
testVector040Key1 := hexDecode(
|
testVector040Key1 := hexDecode(
|
||||||
|
|||||||
+5
-5
@@ -15,8 +15,8 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/integration/rpctest"
|
"github.com/btcsuite/btcd/integration/rpctest"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
@@ -90,11 +90,11 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
|||||||
node.ApplyPortOffset(uint32(trancheIndex) * 1000)
|
node.ApplyPortOffset(uint32(trancheIndex) * 1000)
|
||||||
|
|
||||||
// Create a simple fee service.
|
// Create a simple fee service.
|
||||||
feeService := lntemp.NewFeeService(t)
|
feeService := lntest.NewFeeService(t)
|
||||||
|
|
||||||
// Get the binary path and setup the harness test.
|
// Get the binary path and setup the harness test.
|
||||||
binary := getLndBinary(t)
|
binary := getLndBinary(t)
|
||||||
harnessTest := lntemp.SetupHarness(
|
harnessTest := lntest.SetupHarness(
|
||||||
t, binary, *dbBackendFlag, feeService,
|
t, binary, *dbBackendFlag, feeService,
|
||||||
)
|
)
|
||||||
defer harnessTest.Stop()
|
defer harnessTest.Stop()
|
||||||
@@ -156,7 +156,7 @@ func TestLightningNetworkDaemon(t *testing.T) {
|
|||||||
// getTestCaseSplitTranche returns the sub slice of the test cases that should
|
// getTestCaseSplitTranche returns the sub slice of the test cases that should
|
||||||
// be run as the current split tranche as well as the index and slice offset of
|
// be run as the current split tranche as well as the index and slice offset of
|
||||||
// the tranche.
|
// the tranche.
|
||||||
func getTestCaseSplitTranche() ([]*lntemp.TestCase, uint, uint) {
|
func getTestCaseSplitTranche() ([]*lntest.TestCase, uint, uint) {
|
||||||
numTranches := defaultSplitTranches
|
numTranches := defaultSplitTranches
|
||||||
if testCasesSplitTranches != nil {
|
if testCasesSplitTranches != nil {
|
||||||
numTranches = *testCasesSplitTranches
|
numTranches = *testCasesSplitTranches
|
||||||
|
|||||||
@@ -7,17 +7,17 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testTrackPayments tests whether a client that calls the TrackPayments api
|
// testTrackPayments tests whether a client that calls the TrackPayments api
|
||||||
// receives payment updates.
|
// receives payment updates.
|
||||||
func testTrackPayments(ht *lntemp.HarnessTest) {
|
func testTrackPayments(ht *lntest.HarnessTest) {
|
||||||
// Open a channel between alice and bob.
|
// Open a channel between alice and bob.
|
||||||
alice, bob := ht.Alice, ht.Bob
|
alice, bob := ht.Alice, ht.Bob
|
||||||
channel := ht.OpenChannel(
|
channel := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Amt: btcutil.Amount(300000),
|
Amt: btcutil.Amount(300000),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -51,7 +51,7 @@ func walletToLNAddrType(t *testing.T,
|
|||||||
|
|
||||||
// newExternalAddr generates a new external address of an imported account for a
|
// newExternalAddr generates a new external address of an imported account for a
|
||||||
// pair of nodes, where one acts as the funder and the other as the signer.
|
// pair of nodes, where one acts as the funder and the other as the signer.
|
||||||
func newExternalAddr(ht *lntemp.HarnessTest, funder, signer *node.HarnessNode,
|
func newExternalAddr(ht *lntest.HarnessTest, funder, signer *node.HarnessNode,
|
||||||
importedAccount string, addrType walletrpc.AddressType) string {
|
importedAccount string, addrType walletrpc.AddressType) string {
|
||||||
|
|
||||||
// We'll generate a new address for Carol from Dave's node to receive
|
// We'll generate a new address for Carol from Dave's node to receive
|
||||||
@@ -125,7 +125,7 @@ func assertOutputScriptType(t *testing.T, expType txscript.ScriptClass,
|
|||||||
|
|
||||||
// psbtSendFromImportedAccount attempts to fund a PSBT from the given imported
|
// psbtSendFromImportedAccount attempts to fund a PSBT from the given imported
|
||||||
// account, originating from the source node to the destination.
|
// account, originating from the source node to the destination.
|
||||||
func psbtSendFromImportedAccount(ht *lntemp.HarnessTest, srcNode, destNode,
|
func psbtSendFromImportedAccount(ht *lntest.HarnessTest, srcNode, destNode,
|
||||||
signer *node.HarnessNode, account string,
|
signer *node.HarnessNode, account string,
|
||||||
accountAddrType walletrpc.AddressType) {
|
accountAddrType walletrpc.AddressType) {
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ func psbtSendFromImportedAccount(ht *lntemp.HarnessTest, srcNode, destNode,
|
|||||||
// node. To ensure the channel is operational before closing it, a test payment
|
// node. To ensure the channel is operational before closing it, a test payment
|
||||||
// is made. Several balance assertions are made along the way for the sake of
|
// is made. Several balance assertions are made along the way for the sake of
|
||||||
// correctness.
|
// correctness.
|
||||||
func fundChanAndCloseFromImportedAccount(ht *lntemp.HarnessTest, srcNode,
|
func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode,
|
||||||
destNode, signer *node.HarnessNode, account string,
|
destNode, signer *node.HarnessNode, account string,
|
||||||
accountAddrType walletrpc.AddressType, utxoAmt, chanSize int64) {
|
accountAddrType walletrpc.AddressType, utxoAmt, chanSize int64) {
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ func fundChanAndCloseFromImportedAccount(ht *lntemp.HarnessTest, srcNode,
|
|||||||
// The source node will then fund the channel through a PSBT shim.
|
// The source node will then fund the channel through a PSBT shim.
|
||||||
pendingChanID := ht.Random32Bytes()
|
pendingChanID := ht.Random32Bytes()
|
||||||
chanUpdates, rawPsbt := ht.OpenChannelPsbt(
|
chanUpdates, rawPsbt := ht.OpenChannelPsbt(
|
||||||
srcNode, destNode, lntemp.OpenChannelParams{
|
srcNode, destNode, lntest.OpenChannelParams{
|
||||||
Amt: btcutil.Amount(chanSize),
|
Amt: btcutil.Amount(chanSize),
|
||||||
FundingShim: &lnrpc.FundingShim{
|
FundingShim: &lnrpc.FundingShim{
|
||||||
Shim: &lnrpc.FundingShim_PsbtShim{
|
Shim: &lnrpc.FundingShim_PsbtShim{
|
||||||
@@ -463,7 +463,7 @@ func fundChanAndCloseFromImportedAccount(ht *lntemp.HarnessTest, srcNode,
|
|||||||
// testWalletImportAccount tests that an imported account can fund transactions
|
// testWalletImportAccount tests that an imported account can fund transactions
|
||||||
// and channels through PSBTs, by having one node (the one with the imported
|
// and channels through PSBTs, by having one node (the one with the imported
|
||||||
// account) craft the transactions and another node act as the signer.
|
// account) craft the transactions and another node act as the signer.
|
||||||
func testWalletImportAccount(ht *lntemp.HarnessTest) {
|
func testWalletImportAccount(ht *lntest.HarnessTest) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
addrType walletrpc.AddressType
|
addrType walletrpc.AddressType
|
||||||
@@ -491,7 +491,7 @@ func testWalletImportAccount(ht *lntemp.HarnessTest) {
|
|||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
success := ht.Run(tc.name, func(tt *testing.T) {
|
success := ht.Run(tc.name, func(tt *testing.T) {
|
||||||
testFunc := func(ht *lntemp.HarnessTest) {
|
testFunc := func(ht *lntest.HarnessTest) {
|
||||||
testWalletImportAccountScenario(
|
testWalletImportAccountScenario(
|
||||||
ht, tc.addrType,
|
ht, tc.addrType,
|
||||||
)
|
)
|
||||||
@@ -499,7 +499,7 @@ func testWalletImportAccount(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
st := ht.Subtest(tt)
|
st := ht.Subtest(tt)
|
||||||
|
|
||||||
st.RunTestCase(&lntemp.TestCase{
|
st.RunTestCase(&lntest.TestCase{
|
||||||
Name: tc.name,
|
Name: tc.name,
|
||||||
TestFunc: testFunc,
|
TestFunc: testFunc,
|
||||||
})
|
})
|
||||||
@@ -515,7 +515,7 @@ func testWalletImportAccount(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWalletImportAccountScenario(ht *lntemp.HarnessTest,
|
func testWalletImportAccountScenario(ht *lntest.HarnessTest,
|
||||||
addrType walletrpc.AddressType) {
|
addrType walletrpc.AddressType) {
|
||||||
|
|
||||||
// We'll start our test by having two nodes, Carol and Dave. Carol's
|
// We'll start our test by having two nodes, Carol and Dave. Carol's
|
||||||
@@ -529,7 +529,7 @@ func testWalletImportAccountScenario(ht *lntemp.HarnessTest,
|
|||||||
runWalletImportAccountScenario(ht, addrType, carol, dave)
|
runWalletImportAccountScenario(ht, addrType, carol, dave)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runWalletImportAccountScenario(ht *lntemp.HarnessTest,
|
func runWalletImportAccountScenario(ht *lntest.HarnessTest,
|
||||||
addrType walletrpc.AddressType, carol, dave *node.HarnessNode) {
|
addrType walletrpc.AddressType, carol, dave *node.HarnessNode) {
|
||||||
|
|
||||||
const utxoAmt int64 = btcutil.SatoshiPerBitcoin
|
const utxoAmt int64 = btcutil.SatoshiPerBitcoin
|
||||||
@@ -619,7 +619,7 @@ func runWalletImportAccountScenario(ht *lntemp.HarnessTest,
|
|||||||
// testWalletImportPubKey tests that an imported public keys can fund
|
// testWalletImportPubKey tests that an imported public keys can fund
|
||||||
// transactions and channels through PSBTs, by having one node (the one with the
|
// transactions and channels through PSBTs, by having one node (the one with the
|
||||||
// imported account) craft the transactions and another node act as the signer.
|
// imported account) craft the transactions and another node act as the signer.
|
||||||
func testWalletImportPubKey(ht *lntemp.HarnessTest) {
|
func testWalletImportPubKey(ht *lntest.HarnessTest) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
addrType walletrpc.AddressType
|
addrType walletrpc.AddressType
|
||||||
@@ -642,7 +642,7 @@ func testWalletImportPubKey(ht *lntemp.HarnessTest) {
|
|||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
success := ht.Run(tc.name, func(tt *testing.T) {
|
success := ht.Run(tc.name, func(tt *testing.T) {
|
||||||
testFunc := func(ht *lntemp.HarnessTest) {
|
testFunc := func(ht *lntest.HarnessTest) {
|
||||||
testWalletImportPubKeyScenario(
|
testWalletImportPubKeyScenario(
|
||||||
ht, tc.addrType,
|
ht, tc.addrType,
|
||||||
)
|
)
|
||||||
@@ -650,7 +650,7 @@ func testWalletImportPubKey(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
st := ht.Subtest(tt)
|
st := ht.Subtest(tt)
|
||||||
|
|
||||||
st.RunTestCase(&lntemp.TestCase{
|
st.RunTestCase(&lntest.TestCase{
|
||||||
Name: tc.name,
|
Name: tc.name,
|
||||||
TestFunc: testFunc,
|
TestFunc: testFunc,
|
||||||
})
|
})
|
||||||
@@ -666,7 +666,7 @@ func testWalletImportPubKey(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWalletImportPubKeyScenario(ht *lntemp.HarnessTest,
|
func testWalletImportPubKeyScenario(ht *lntest.HarnessTest,
|
||||||
addrType walletrpc.AddressType) {
|
addrType walletrpc.AddressType) {
|
||||||
|
|
||||||
const utxoAmt int64 = btcutil.SatoshiPerBitcoin
|
const utxoAmt int64 = btcutil.SatoshiPerBitcoin
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ type pendingChan *lnrpc.PendingChannelsResponse_PendingChannel
|
|||||||
// packages are wiped.
|
// packages are wiped.
|
||||||
// - Bob coop closes the channel Bob->Carol, and checks from both Bob PoVs
|
// - Bob coop closes the channel Bob->Carol, and checks from both Bob PoVs
|
||||||
// that the forwarding packages are wiped.
|
// that the forwarding packages are wiped.
|
||||||
func testWipeForwardingPackages(ht *lntemp.HarnessTest) {
|
func testWipeForwardingPackages(ht *lntest.HarnessTest) {
|
||||||
const (
|
const (
|
||||||
chanAmt = 10e6
|
chanAmt = 10e6
|
||||||
paymentAmt = 10e4
|
paymentAmt = 10e4
|
||||||
@@ -41,12 +41,12 @@ func testWipeForwardingPackages(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// Open a channel between Alice and Bob.
|
// Open a channel between Alice and Bob.
|
||||||
chanPointAB := ht.OpenChannel(
|
chanPointAB := ht.OpenChannel(
|
||||||
alice, bob, lntemp.OpenChannelParams{Amt: chanAmt},
|
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Open a channel between Bob and Carol.
|
// Open a channel between Bob and Carol.
|
||||||
chanPointBC := ht.OpenChannel(
|
chanPointBC := ht.OpenChannel(
|
||||||
bob, carol, lntemp.OpenChannelParams{Amt: chanAmt},
|
bob, carol, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Before we continue, make sure Alice has seen the channel between Bob
|
// Before we continue, make sure Alice has seen the channel between Bob
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package itest
|
|||||||
import (
|
import (
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/funding"
|
"github.com/lightningnetwork/lnd/funding"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
// acceptances will allow a wumbo channel to be created. Additionally, if a
|
// acceptances will allow a wumbo channel to be created. Additionally, if a
|
||||||
// node is running with mini channels only enabled, then they should reject any
|
// node is running with mini channels only enabled, then they should reject any
|
||||||
// inbound wumbo channel requests.
|
// inbound wumbo channel requests.
|
||||||
func testWumboChannels(ht *lntemp.HarnessTest) {
|
func testWumboChannels(ht *lntest.HarnessTest) {
|
||||||
// With all the channel types exercised, we'll now make sure the wumbo
|
// With all the channel types exercised, we'll now make sure the wumbo
|
||||||
// signalling support works properly.
|
// signalling support works properly.
|
||||||
//
|
//
|
||||||
@@ -33,7 +33,7 @@ func testWumboChannels(ht *lntemp.HarnessTest) {
|
|||||||
// The test should indicate a failure due to the channel being too
|
// The test should indicate a failure due to the channel being too
|
||||||
// large.
|
// large.
|
||||||
ht.OpenChannelAssertErr(
|
ht.OpenChannelAssertErr(
|
||||||
wumboNode, miniNode, lntemp.OpenChannelParams{Amt: chanAmt},
|
wumboNode, miniNode, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
lnwallet.ErrChanTooLarge(chanAmt, funding.MaxBtcFundingAmount),
|
lnwallet.ErrChanTooLarge(chanAmt, funding.MaxBtcFundingAmount),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ func testWumboChannels(ht *lntemp.HarnessTest) {
|
|||||||
// Creating a wumbo channel between these two nodes should succeed.
|
// Creating a wumbo channel between these two nodes should succeed.
|
||||||
ht.EnsureConnected(wumboNode, wumboNode2)
|
ht.EnsureConnected(wumboNode, wumboNode2)
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
wumboNode, wumboNode2, lntemp.OpenChannelParams{Amt: chanAmt},
|
wumboNode, wumboNode2, lntest.OpenChannelParams{Amt: chanAmt},
|
||||||
)
|
)
|
||||||
ht.CloseChannel(wumboNode, chanPoint)
|
ht.CloseChannel(wumboNode, chanPoint)
|
||||||
}
|
}
|
||||||
+24
-24
@@ -13,9 +13,9 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainreg"
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp"
|
"github.com/lightningnetwork/lnd/lntest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
// testZeroConfChannelOpen tests that opening a zero-conf channel works and
|
// testZeroConfChannelOpen tests that opening a zero-conf channel works and
|
||||||
// sending payments also works.
|
// sending payments also works.
|
||||||
func testZeroConfChannelOpen(ht *lntemp.HarnessTest) {
|
func testZeroConfChannelOpen(ht *lntest.HarnessTest) {
|
||||||
// Since option-scid-alias is opt-in, the provided harness nodes will
|
// Since option-scid-alias is opt-in, the provided harness nodes will
|
||||||
// not have the feature bit set. Also need to set anchors as those are
|
// not have the feature bit set. Also need to set anchors as those are
|
||||||
// default-off in itests.
|
// default-off in itests.
|
||||||
@@ -39,7 +39,7 @@ func testZeroConfChannelOpen(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// We'll open a regular public channel between Bob and Carol here.
|
// We'll open a regular public channel between Bob and Carol here.
|
||||||
chanAmt := btcutil.Amount(1_000_000)
|
chanAmt := btcutil.Amount(1_000_000)
|
||||||
p := lntemp.OpenChannelParams{
|
p := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
}
|
}
|
||||||
chanPoint := ht.OpenChannel(bob, carol, p)
|
chanPoint := ht.OpenChannel(bob, carol, p)
|
||||||
@@ -58,7 +58,7 @@ func testZeroConfChannelOpen(ht *lntemp.HarnessTest) {
|
|||||||
go acceptChannel(ht.T, true, acceptStream)
|
go acceptChannel(ht.T, true, acceptStream)
|
||||||
|
|
||||||
// Open a private zero-conf anchors channel of 1M satoshis.
|
// Open a private zero-conf anchors channel of 1M satoshis.
|
||||||
params := lntemp.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: true,
|
Private: true,
|
||||||
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
||||||
@@ -191,7 +191,7 @@ func testZeroConfChannelOpen(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
// testOptionScidAlias checks that opening an option_scid_alias channel-type
|
// testOptionScidAlias checks that opening an option_scid_alias channel-type
|
||||||
// channel or w/o the channel-type works properly.
|
// channel or w/o the channel-type works properly.
|
||||||
func testOptionScidAlias(ht *lntemp.HarnessTest) {
|
func testOptionScidAlias(ht *lntest.HarnessTest) {
|
||||||
type scidTestCase struct {
|
type scidTestCase struct {
|
||||||
name string
|
name string
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ func testOptionScidAlias(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func optionScidAliasScenario(ht *lntemp.HarnessTest, chantype, private bool) {
|
func optionScidAliasScenario(ht *lntest.HarnessTest, chantype, private bool) {
|
||||||
// Option-scid-alias is opt-in, as is anchors.
|
// Option-scid-alias is opt-in, as is anchors.
|
||||||
scidAliasArgs := []string{
|
scidAliasArgs := []string{
|
||||||
"--protocol.option-scid-alias",
|
"--protocol.option-scid-alias",
|
||||||
@@ -256,7 +256,7 @@ func optionScidAliasScenario(ht *lntemp.HarnessTest, chantype, private bool) {
|
|||||||
|
|
||||||
chanAmt := btcutil.Amount(1_000_000)
|
chanAmt := btcutil.Amount(1_000_000)
|
||||||
|
|
||||||
params := lntemp.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: private,
|
Private: private,
|
||||||
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
||||||
@@ -282,7 +282,7 @@ func optionScidAliasScenario(ht *lntemp.HarnessTest, chantype, private bool) {
|
|||||||
// We'll now open a regular public channel between Bob and Carol and
|
// We'll now open a regular public channel between Bob and Carol and
|
||||||
// assert that Bob can pay Dave. We'll also assert that the invoice
|
// assert that Bob can pay Dave. We'll also assert that the invoice
|
||||||
// Dave issues has the startingAlias as a hop hint.
|
// Dave issues has the startingAlias as a hop hint.
|
||||||
p := lntemp.OpenChannelParams{
|
p := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
}
|
}
|
||||||
fundingPoint2 := ht.OpenChannel(bob, carol, p)
|
fundingPoint2 := ht.OpenChannel(bob, carol, p)
|
||||||
@@ -409,7 +409,7 @@ func waitForZeroConfGraphChange(hn *node.HarnessNode,
|
|||||||
// testUpdateChannelPolicyScidAlias checks that option-scid-alias, zero-conf
|
// testUpdateChannelPolicyScidAlias checks that option-scid-alias, zero-conf
|
||||||
// channel-types, and option-scid-alias feature-bit-only channels have the
|
// channel-types, and option-scid-alias feature-bit-only channels have the
|
||||||
// expected graph and that payments work when updating the channel policy.
|
// expected graph and that payments work when updating the channel policy.
|
||||||
func testUpdateChannelPolicyScidAlias(ht *lntemp.HarnessTest) {
|
func testUpdateChannelPolicyScidAlias(ht *lntest.HarnessTest) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ func testUpdateChannelPolicyScidAlias(ht *lntemp.HarnessTest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
func testPrivateUpdateAlias(ht *lntest.HarnessTest,
|
||||||
zeroConf, scidAliasType, private bool) {
|
zeroConf, scidAliasType, private bool) {
|
||||||
|
|
||||||
// We'll create a new node Eve that will not have option-scid-alias
|
// We'll create a new node Eve that will not have option-scid-alias
|
||||||
@@ -494,7 +494,7 @@ func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
chanAmt := btcutil.Amount(1_000_000)
|
chanAmt := btcutil.Amount(1_000_000)
|
||||||
|
|
||||||
p := lntemp.OpenChannelParams{
|
p := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: chanAmt / 2,
|
PushAmt: chanAmt / 2,
|
||||||
}
|
}
|
||||||
@@ -508,7 +508,7 @@ func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
|||||||
go acceptChannel(ht.T, zeroConf, acceptStream)
|
go acceptChannel(ht.T, zeroConf, acceptStream)
|
||||||
|
|
||||||
// Open a private channel, optionally specifying a channel-type.
|
// Open a private channel, optionally specifying a channel-type.
|
||||||
params := lntemp.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
Private: private,
|
Private: private,
|
||||||
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
||||||
@@ -541,7 +541,7 @@ func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
|||||||
FeeRateMilliMsat: testFeeBase * feeRate,
|
FeeRateMilliMsat: testFeeBase * feeRate,
|
||||||
TimeLockDelta: timeLockDelta,
|
TimeLockDelta: timeLockDelta,
|
||||||
MinHtlc: 1000, // default value
|
MinHtlc: 1000, // default value
|
||||||
MaxHtlcMsat: lntemp.CalculateMaxHtlc(chanAmt),
|
MaxHtlcMsat: lntest.CalculateMaxHtlc(chanAmt),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that Dave receives Carol's policy update.
|
// Assert that Dave receives Carol's policy update.
|
||||||
@@ -567,7 +567,7 @@ func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
|||||||
FeeRateMilliMsat: testFeeBase * feeRate,
|
FeeRateMilliMsat: testFeeBase * feeRate,
|
||||||
TimeLockDelta: timeLockDelta,
|
TimeLockDelta: timeLockDelta,
|
||||||
MinHtlc: 1000,
|
MinHtlc: 1000,
|
||||||
MaxHtlcMsat: lntemp.CalculateMaxHtlc(chanAmt),
|
MaxHtlcMsat: lntest.CalculateMaxHtlc(chanAmt),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that Carol receives Dave's policy update.
|
// Assert that Carol receives Dave's policy update.
|
||||||
@@ -654,7 +654,7 @@ func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
|||||||
FeeRateMilliMsat: testFeeBase * feeRate,
|
FeeRateMilliMsat: testFeeBase * feeRate,
|
||||||
TimeLockDelta: timeLockDelta,
|
TimeLockDelta: timeLockDelta,
|
||||||
MinHtlc: 1000,
|
MinHtlc: 1000,
|
||||||
MaxHtlcMsat: lntemp.CalculateMaxHtlc(chanAmt),
|
MaxHtlcMsat: lntest.CalculateMaxHtlc(chanAmt),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert Dave receives Carol's policy update.
|
// Assert Dave receives Carol's policy update.
|
||||||
@@ -743,7 +743,7 @@ func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
|||||||
FeeRateMilliMsat: testFeeBase * feeRate,
|
FeeRateMilliMsat: testFeeBase * feeRate,
|
||||||
TimeLockDelta: timeLockDelta,
|
TimeLockDelta: timeLockDelta,
|
||||||
MinHtlc: 1000,
|
MinHtlc: 1000,
|
||||||
MaxHtlcMsat: lntemp.CalculateMaxHtlc(chanAmt),
|
MaxHtlcMsat: lntest.CalculateMaxHtlc(chanAmt),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert Dave and optionally Eve receives Carol's update.
|
// Assert Dave and optionally Eve receives Carol's update.
|
||||||
@@ -763,7 +763,7 @@ func testPrivateUpdateAlias(ht *lntemp.HarnessTest,
|
|||||||
|
|
||||||
// testOptionScidUpgrade tests that toggling the option-scid-alias feature bit
|
// testOptionScidUpgrade tests that toggling the option-scid-alias feature bit
|
||||||
// correctly upgrades existing channels.
|
// correctly upgrades existing channels.
|
||||||
func testOptionScidUpgrade(ht *lntemp.HarnessTest) {
|
func testOptionScidUpgrade(ht *lntest.HarnessTest) {
|
||||||
bob := ht.Bob
|
bob := ht.Bob
|
||||||
|
|
||||||
// Start carol with anchors only.
|
// Start carol with anchors only.
|
||||||
@@ -787,7 +787,7 @@ func testOptionScidUpgrade(ht *lntemp.HarnessTest) {
|
|||||||
|
|
||||||
chanAmt := btcutil.Amount(1_000_000)
|
chanAmt := btcutil.Amount(1_000_000)
|
||||||
|
|
||||||
p := lntemp.OpenChannelParams{
|
p := lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: chanAmt / 2,
|
PushAmt: chanAmt / 2,
|
||||||
Private: true,
|
Private: true,
|
||||||
@@ -797,7 +797,7 @@ func testOptionScidUpgrade(ht *lntemp.HarnessTest) {
|
|||||||
// Bob will open a channel to Carol now.
|
// Bob will open a channel to Carol now.
|
||||||
ht.EnsureConnected(bob, carol)
|
ht.EnsureConnected(bob, carol)
|
||||||
|
|
||||||
p = lntemp.OpenChannelParams{
|
p = lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
}
|
}
|
||||||
fundingPoint2 := ht.OpenChannel(bob, carol, p)
|
fundingPoint2 := ht.OpenChannel(bob, carol, p)
|
||||||
@@ -891,7 +891,7 @@ func acceptChannel(t *testing.T, zeroConf bool, stream rpc.AcceptorClient) {
|
|||||||
// testZeroConfReorg tests that a reorg does not cause a zero-conf channel to
|
// testZeroConfReorg tests that a reorg does not cause a zero-conf channel to
|
||||||
// be deleted from the channel graph. This was previously the case due to logic
|
// be deleted from the channel graph. This was previously the case due to logic
|
||||||
// in the function DisconnectBlockAtHeight.
|
// in the function DisconnectBlockAtHeight.
|
||||||
func testZeroConfReorg(ht *lntemp.HarnessTest) {
|
func testZeroConfReorg(ht *lntest.HarnessTest) {
|
||||||
if ht.IsNeutrinoBackend() {
|
if ht.IsNeutrinoBackend() {
|
||||||
ht.Skipf("skipping zero-conf reorg test for neutrino backend")
|
ht.Skipf("skipping zero-conf reorg test for neutrino backend")
|
||||||
}
|
}
|
||||||
@@ -925,7 +925,7 @@ func testZeroConfReorg(ht *lntemp.HarnessTest) {
|
|||||||
go acceptChannel(ht.T, true, acceptStream)
|
go acceptChannel(ht.T, true, acceptStream)
|
||||||
|
|
||||||
// Open a private zero-conf anchors channel of 1M satoshis.
|
// Open a private zero-conf anchors channel of 1M satoshis.
|
||||||
params := lntemp.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: btcutil.Amount(1_000_000),
|
Amt: btcutil.Amount(1_000_000),
|
||||||
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
CommitmentType: lnrpc.CommitmentType_ANCHORS,
|
||||||
ZeroConf: true,
|
ZeroConf: true,
|
||||||
@@ -959,7 +959,7 @@ func testZeroConfReorg(ht *lntemp.HarnessTest) {
|
|||||||
// First, we'll setup a new miner that we can use to cause a reorg.
|
// First, we'll setup a new miner that we can use to cause a reorg.
|
||||||
tempLogDir := ".tempminerlogs"
|
tempLogDir := ".tempminerlogs"
|
||||||
logFilename := "output-open_channel_reorg-temp_miner.log"
|
logFilename := "output-open_channel_reorg-temp_miner.log"
|
||||||
tempMiner := lntemp.NewTempMiner(
|
tempMiner := lntest.NewTempMiner(
|
||||||
ht.Context(), ht.T, tempLogDir, logFilename,
|
ht.Context(), ht.T, tempLogDir, logFilename,
|
||||||
)
|
)
|
||||||
defer tempMiner.Stop()
|
defer tempMiner.Stop()
|
||||||
|
|||||||
File renamed without changes.
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/rpcclient"
|
"github.com/btcsuite/btcd/rpcclient"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
)
|
)
|
||||||
|
|
||||||
// logDirPattern is the pattern of the name of the temporary log directory.
|
// logDirPattern is the pattern of the name of the temporary log directory.
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/integration/rpctest"
|
"github.com/btcsuite/btcd/integration/rpctest"
|
||||||
"github.com/btcsuite/btcd/rpcclient"
|
"github.com/btcsuite/btcd/rpcclient"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
)
|
)
|
||||||
|
|
||||||
// logDirPattern is the pattern of the name of the temporary log directory.
|
// logDirPattern is the pattern of the name of the temporary log directory.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package lntemp
|
package lntest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lntemp
|
package lntest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lntemp
|
package lntest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -23,8 +23,8 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lntemp
|
package lntest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/integration/rpctest"
|
"github.com/btcsuite/btcd/integration/rpctest"
|
||||||
"github.com/btcsuite/btcd/rpcclient"
|
"github.com/btcsuite/btcd/rpcclient"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lntemp
|
package lntest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package lntemp
|
package lntest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/integration/rpctest"
|
"github.com/btcsuite/btcd/integration/rpctest"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lntest"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -85,7 +84,7 @@ func prepareMiner(ctxt context.Context, t *testing.T) *HarnessMiner {
|
|||||||
func prepareChainBackend(t *testing.T,
|
func prepareChainBackend(t *testing.T,
|
||||||
minerAddr string) (node.BackendConfig, func()) {
|
minerAddr string) (node.BackendConfig, func()) {
|
||||||
|
|
||||||
chainBackend, cleanUp, err := lntest.NewBackend(
|
chainBackend, cleanUp, err := NewBackend(
|
||||||
minerAddr, harnessNetParams,
|
minerAddr, harnessNetParams,
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "new backend")
|
require.NoError(t, err, "new backend")
|
||||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NeutrinoBackendConfig is an implementation of the BackendConfig interface
|
// NeutrinoBackendConfig is an implementation of the BackendConfig interface
|
||||||
|
|||||||
File renamed without changes.
@@ -18,7 +18,7 @@ import (
|
|||||||
|
|
||||||
"github.com/jackc/pgx/v4/pgxpool"
|
"github.com/jackc/pgx/v4/pgxpool"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/macaroons"
|
"github.com/lightningnetwork/lnd/macaroons"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lnutils"
|
"github.com/lightningnetwork/lnd/lnutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lntemp/rpc"
|
"github.com/lightningnetwork/lnd/lntest/rpc"
|
||||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/lightningnetwork/lnd/lnutils"
|
"github.com/lightningnetwork/lnd/lnutils"
|
||||||
)
|
)
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
package lntemp
|
package lntest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
Reference in new issue
Block a user