mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 23:01:53 +02:00
itest: break down wallet import account tests
This commit is contained in:
@@ -484,10 +484,6 @@ var allTestCases = []*lntest.TestCase{
|
|||||||
Name: "simple taproot channel activation",
|
Name: "simple taproot channel activation",
|
||||||
TestFunc: testSimpleTaprootChannelActivation,
|
TestFunc: testSimpleTaprootChannelActivation,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "wallet import account",
|
|
||||||
TestFunc: testWalletImportAccount,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "wallet import pubkey",
|
Name: "wallet import pubkey",
|
||||||
TestFunc: testWalletImportPubKey,
|
TestFunc: testWalletImportPubKey,
|
||||||
@@ -684,4 +680,5 @@ func init() {
|
|||||||
allTestCases = append(allTestCases, fundUtxoSelectionTestCases...)
|
allTestCases = append(allTestCases, fundUtxoSelectionTestCases...)
|
||||||
allTestCases = append(allTestCases, zeroConfPolicyTestCases...)
|
allTestCases = append(allTestCases, zeroConfPolicyTestCases...)
|
||||||
allTestCases = append(allTestCases, channelFeePolicyTestCases...)
|
allTestCases = append(allTestCases, channelFeePolicyTestCases...)
|
||||||
|
allTestCases = append(allTestCases, walletImportAccountTestCases...)
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,55 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// walletImportAccountTestCases tests that an imported account can fund
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//nolint:ll
|
||||||
|
var walletImportAccountTestCases = []*lntest.TestCase{
|
||||||
|
{
|
||||||
|
Name: "wallet import account standard BIP-0044",
|
||||||
|
TestFunc: func(ht *lntest.HarnessTest) {
|
||||||
|
testWalletImportAccountScenario(
|
||||||
|
ht, walletrpc.AddressType_WITNESS_PUBKEY_HASH,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "wallet import account standard BIP-0049",
|
||||||
|
TestFunc: func(ht *lntest.HarnessTest) {
|
||||||
|
testWalletImportAccountScenario(
|
||||||
|
ht, walletrpc.AddressType_NESTED_WITNESS_PUBKEY_HASH,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "wallet import account lnd BIP-0049 variant",
|
||||||
|
TestFunc: func(ht *lntest.HarnessTest) {
|
||||||
|
testWalletImportAccountScenario(
|
||||||
|
ht, walletrpc.AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "wallet import account standard BIP-0084",
|
||||||
|
TestFunc: func(ht *lntest.HarnessTest) {
|
||||||
|
testWalletImportAccountScenario(
|
||||||
|
ht, walletrpc.AddressType_WITNESS_PUBKEY_HASH,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "wallet import account standard BIP-0086",
|
||||||
|
TestFunc: func(ht *lntest.HarnessTest) {
|
||||||
|
testWalletImportAccountScenario(
|
||||||
|
ht, walletrpc.AddressType_TAPROOT_PUBKEY,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultAccount = lnwallet.DefaultAccountName
|
defaultAccount = lnwallet.DefaultAccountName
|
||||||
defaultImportedAccount = waddrmgr.ImportedAddrAccountName
|
defaultImportedAccount = waddrmgr.ImportedAddrAccountName
|
||||||
@@ -452,65 +501,6 @@ func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// testWalletImportAccount tests that an imported account can fund 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.
|
|
||||||
func testWalletImportAccount(ht *lntest.HarnessTest) {
|
|
||||||
testCases := []struct {
|
|
||||||
name string
|
|
||||||
addrType walletrpc.AddressType
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "standard BIP-0044",
|
|
||||||
addrType: walletrpc.AddressType_WITNESS_PUBKEY_HASH,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "standard BIP-0049",
|
|
||||||
addrType: walletrpc.
|
|
||||||
AddressType_NESTED_WITNESS_PUBKEY_HASH,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "lnd BIP-0049 variant",
|
|
||||||
addrType: walletrpc.
|
|
||||||
AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "standard BIP-0084",
|
|
||||||
addrType: walletrpc.AddressType_WITNESS_PUBKEY_HASH,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "standard BIP-0086",
|
|
||||||
addrType: walletrpc.AddressType_TAPROOT_PUBKEY,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
tc := tc
|
|
||||||
success := ht.Run(tc.name, func(tt *testing.T) {
|
|
||||||
testFunc := func(ht *lntest.HarnessTest) {
|
|
||||||
testWalletImportAccountScenario(
|
|
||||||
ht, tc.addrType,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
st := ht.Subtest(tt)
|
|
||||||
|
|
||||||
st.RunTestCase(&lntest.TestCase{
|
|
||||||
Name: tc.name,
|
|
||||||
TestFunc: testFunc,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
if !success {
|
|
||||||
// Log failure time to help relate the lnd logs to the
|
|
||||||
// failure.
|
|
||||||
ht.Logf("Failure time: %v", time.Now().Format(
|
|
||||||
"2006-01-02 15:04:05.000",
|
|
||||||
))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testWalletImportAccountScenario(ht *lntest.HarnessTest,
|
func testWalletImportAccountScenario(ht *lntest.HarnessTest,
|
||||||
addrType walletrpc.AddressType) {
|
addrType walletrpc.AddressType) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user